Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console dynamic field display #636

Open
wants to merge 2 commits into
base: master
from

Conversation

@Akshath-Singhal
Copy link
Contributor

commented Jun 8, 2019

This feature allows user to add fields for displaying data to the console dynamically using the following command:

console_add UNIQUE_IDENTIFIER DISPLAYNAME%variabletype MESSAGE_TYPE EXPRESSION ROW

eg. console_add WPBEAR TARBEAR%u NAV_CONTROLLER_OUTPUT (msg.target_bearing*10) 4

The above command will display the following

console

@Akshath-Singhal Akshath-Singhal changed the title Console Console dynamic field display Jun 8, 2019

@tridge
Copy link
Contributor

left a comment

Instead of requiring the user to put in the msg names just use this method:
https://github.com/ardupilot/MAVProxy/blob/master/MAVProxy/modules/lib/grapher.py#L466
that grabs the msg names for graphing.
similarly, please use mavutil.evaluate_expression(), like is done here:
https://github.com/ardupilot/MAVProxy/blob/master/MAVProxy/modules/lib/grapher.py#L346

MAVProxy/modules/mavproxy_console.py Outdated Show resolved Hide resolved
@@ -514,6 +526,11 @@ def mavlink_packet(self, msg):
alt_error = "%d%s" % (msg.alt_error, alt_error_sign)
self.console.set_status('AltError', 'AltError %s' % alt_error)
self.console.set_status('AspdError', 'AspdError %.1f%s' % (msg.aspd_error*0.01, aspd_error_sign))
for i in range(0,len(self.user_added)):

This comment has been minimized.

Copy link
@tridge

tridge Jun 8, 2019

Contributor

we only want to trigger on msgs that we know are in expressions the user has added, otherwise we waste a lot of cpu

MAVProxy/modules/mavproxy_console.py Outdated Show resolved Hide resolved
Console
Display user specified data in console.

@Akshath-Singhal Akshath-Singhal force-pushed the Akshath-Singhal:consolescript branch from ccff1ca to 4ca3626 Jun 9, 2019

eval instead of exec
check for message type
def cmd_add(self, args):
new_field = args[:]
self.user_added.append(new_field)
print self.user_added

This comment has been minimized.

Copy link
@tridge

tridge Aug 24, 2019

Contributor

need to use print() for py3

@@ -75,6 +77,11 @@ def __init__(self, mpstate):
self.vehicle_menu = MPMenuSubMenu('Vehicle', items=[])
self.add_menu(self.vehicle_menu)

def cmd_add(self, args):
new_field = args[:]
self.user_added.append(new_field)

This comment has been minimized.

Copy link
@tridge

tridge Aug 24, 2019

Contributor

better to create a new small class that has the broken out fields with names

if type in [row[2] for row in self.user_added]:
for i in range(0,len(self.user_added)):
if type == self.user_added[i][2]:
val = eval(self.user_added[i][3])

This comment has been minimized.

Copy link
@tridge

tridge Aug 24, 2019

Contributor

need to catch exceptions for eval()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.