id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
235,200
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/wxconsole.py
MessageConsole.close
def close(self): '''close the console''' self.close_event.set() if self.is_alive(): self.child.join(2)
python
def close(self): '''close the console''' self.close_event.set() if self.is_alive(): self.child.join(2)
[ "def", "close", "(", "self", ")", ":", "self", ".", "close_event", ".", "set", "(", ")", "if", "self", ".", "is_alive", "(", ")", ":", "self", ".", "child", ".", "join", "(", "2", ")" ]
close the console
[ "close", "the", "console" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/wxconsole.py#L74-L78
235,201
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.cmd_rally_add
def cmd_rally_add(self, args): '''handle rally add''' if len(args) < 1: alt = self.settings.rallyalt else: alt = float(args[0]) if len(args) < 2: break_alt = self.settings.rally_breakalt else: break_alt = float(args[1]) if len(args) < 3: flag = self.settings.rally_flags else: flag = int(args[2]) #currently only supporting autoland values: #True (nonzero) and False (zero) if (flag != 0): flag = 2 if not self.have_list: print("Please list rally points first") return if (self.rallyloader.rally_count() > 4): print ("Only 5 rally points possible per flight plan.") return try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return land_hdg = 0.0 self.rallyloader.create_and_append_rally_point(latlon[0] * 1e7, latlon[1] * 1e7, alt, break_alt, land_hdg, flag) self.send_rally_points() print("Added Rally point at %s %f %f, autoland: %s" % (str(latlon), alt, break_alt, bool(flag & 2)))
python
def cmd_rally_add(self, args): '''handle rally add''' if len(args) < 1: alt = self.settings.rallyalt else: alt = float(args[0]) if len(args) < 2: break_alt = self.settings.rally_breakalt else: break_alt = float(args[1]) if len(args) < 3: flag = self.settings.rally_flags else: flag = int(args[2]) #currently only supporting autoland values: #True (nonzero) and False (zero) if (flag != 0): flag = 2 if not self.have_list: print("Please list rally points first") return if (self.rallyloader.rally_count() > 4): print ("Only 5 rally points possible per flight plan.") return try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return land_hdg = 0.0 self.rallyloader.create_and_append_rally_point(latlon[0] * 1e7, latlon[1] * 1e7, alt, break_alt, land_hdg, flag) self.send_rally_points() print("Added Rally point at %s %f %f, autoland: %s" % (str(latlon), alt, break_alt, bool(flag & 2)))
[ "def", "cmd_rally_add", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "alt", "=", "self", ".", "settings", ".", "rallyalt", "else", ":", "alt", "=", "float", "(", "args", "[", "0", "]", ")", "if", "len", "(", "args", ")", "<", "2", ":", "break_alt", "=", "self", ".", "settings", ".", "rally_breakalt", "else", ":", "break_alt", "=", "float", "(", "args", "[", "1", "]", ")", "if", "len", "(", "args", ")", "<", "3", ":", "flag", "=", "self", ".", "settings", ".", "rally_flags", "else", ":", "flag", "=", "int", "(", "args", "[", "2", "]", ")", "#currently only supporting autoland values:", "#True (nonzero) and False (zero)", "if", "(", "flag", "!=", "0", ")", ":", "flag", "=", "2", "if", "not", "self", ".", "have_list", ":", "print", "(", "\"Please list rally points first\"", ")", "return", "if", "(", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ">", "4", ")", ":", "print", "(", "\"Only 5 rally points possible per flight plan.\"", ")", "return", "try", ":", "latlon", "=", "self", ".", "module", "(", "'map'", ")", ".", "click_position", "except", "Exception", ":", "print", "(", "\"No map available\"", ")", "return", "if", "latlon", "is", "None", ":", "print", "(", "\"No map click position available\"", ")", "return", "land_hdg", "=", "0.0", "self", ".", "rallyloader", ".", "create_and_append_rally_point", "(", "latlon", "[", "0", "]", "*", "1e7", ",", "latlon", "[", "1", "]", "*", "1e7", ",", "alt", ",", "break_alt", ",", "land_hdg", ",", "flag", ")", "self", ".", "send_rally_points", "(", ")", "print", "(", "\"Added Rally point at %s %f %f, autoland: %s\"", "%", "(", "str", "(", "latlon", ")", ",", "alt", ",", "break_alt", ",", "bool", "(", "flag", "&", "2", ")", ")", ")" ]
handle rally add
[ "handle", "rally", "add" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L72-L114
235,202
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.cmd_rally_alt
def cmd_rally_alt(self, args): '''handle rally alt change''' if (len(args) < 2): print("Usage: rally alt RALLYNUM newAlt <newBreakAlt>") return if not self.have_list: print("Please list rally points first") return idx = int(args[0]) if idx <= 0 or idx > self.rallyloader.rally_count(): print("Invalid rally point number %u" % idx) return new_alt = int(args[1]) new_break_alt = None if (len(args) > 2): new_break_alt = int(args[2]) self.rallyloader.set_alt(idx, new_alt, new_break_alt) self.send_rally_point(idx-1) self.fetch_rally_point(idx-1) self.rallyloader.reindex()
python
def cmd_rally_alt(self, args): '''handle rally alt change''' if (len(args) < 2): print("Usage: rally alt RALLYNUM newAlt <newBreakAlt>") return if not self.have_list: print("Please list rally points first") return idx = int(args[0]) if idx <= 0 or idx > self.rallyloader.rally_count(): print("Invalid rally point number %u" % idx) return new_alt = int(args[1]) new_break_alt = None if (len(args) > 2): new_break_alt = int(args[2]) self.rallyloader.set_alt(idx, new_alt, new_break_alt) self.send_rally_point(idx-1) self.fetch_rally_point(idx-1) self.rallyloader.reindex()
[ "def", "cmd_rally_alt", "(", "self", ",", "args", ")", ":", "if", "(", "len", "(", "args", ")", "<", "2", ")", ":", "print", "(", "\"Usage: rally alt RALLYNUM newAlt <newBreakAlt>\"", ")", "return", "if", "not", "self", ".", "have_list", ":", "print", "(", "\"Please list rally points first\"", ")", "return", "idx", "=", "int", "(", "args", "[", "0", "]", ")", "if", "idx", "<=", "0", "or", "idx", ">", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ":", "print", "(", "\"Invalid rally point number %u\"", "%", "idx", ")", "return", "new_alt", "=", "int", "(", "args", "[", "1", "]", ")", "new_break_alt", "=", "None", "if", "(", "len", "(", "args", ")", ">", "2", ")", ":", "new_break_alt", "=", "int", "(", "args", "[", "2", "]", ")", "self", ".", "rallyloader", ".", "set_alt", "(", "idx", ",", "new_alt", ",", "new_break_alt", ")", "self", ".", "send_rally_point", "(", "idx", "-", "1", ")", "self", ".", "fetch_rally_point", "(", "idx", "-", "1", ")", "self", ".", "rallyloader", ".", "reindex", "(", ")" ]
handle rally alt change
[ "handle", "rally", "alt", "change" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L116-L138
235,203
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.cmd_rally_move
def cmd_rally_move(self, args): '''handle rally move''' if len(args) < 1: print("Usage: rally move RALLYNUM") return if not self.have_list: print("Please list rally points first") return idx = int(args[0]) if idx <= 0 or idx > self.rallyloader.rally_count(): print("Invalid rally point number %u" % idx) return rpoint = self.rallyloader.rally_point(idx-1) try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return oldpos = (rpoint.lat*1e-7, rpoint.lng*1e-7) self.rallyloader.move(idx, latlon[0], latlon[1]) self.send_rally_point(idx-1) p = self.fetch_rally_point(idx-1) if p.lat != int(latlon[0]*1e7) or p.lng != int(latlon[1]*1e7): print("Rally move failed") return self.rallyloader.reindex() print("Moved rally point from %s to %s at %fm" % (str(oldpos), str(latlon), rpoint.alt))
python
def cmd_rally_move(self, args): '''handle rally move''' if len(args) < 1: print("Usage: rally move RALLYNUM") return if not self.have_list: print("Please list rally points first") return idx = int(args[0]) if idx <= 0 or idx > self.rallyloader.rally_count(): print("Invalid rally point number %u" % idx) return rpoint = self.rallyloader.rally_point(idx-1) try: latlon = self.module('map').click_position except Exception: print("No map available") return if latlon is None: print("No map click position available") return oldpos = (rpoint.lat*1e-7, rpoint.lng*1e-7) self.rallyloader.move(idx, latlon[0], latlon[1]) self.send_rally_point(idx-1) p = self.fetch_rally_point(idx-1) if p.lat != int(latlon[0]*1e7) or p.lng != int(latlon[1]*1e7): print("Rally move failed") return self.rallyloader.reindex() print("Moved rally point from %s to %s at %fm" % (str(oldpos), str(latlon), rpoint.alt))
[ "def", "cmd_rally_move", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "\"Usage: rally move RALLYNUM\"", ")", "return", "if", "not", "self", ".", "have_list", ":", "print", "(", "\"Please list rally points first\"", ")", "return", "idx", "=", "int", "(", "args", "[", "0", "]", ")", "if", "idx", "<=", "0", "or", "idx", ">", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ":", "print", "(", "\"Invalid rally point number %u\"", "%", "idx", ")", "return", "rpoint", "=", "self", ".", "rallyloader", ".", "rally_point", "(", "idx", "-", "1", ")", "try", ":", "latlon", "=", "self", ".", "module", "(", "'map'", ")", ".", "click_position", "except", "Exception", ":", "print", "(", "\"No map available\"", ")", "return", "if", "latlon", "is", "None", ":", "print", "(", "\"No map click position available\"", ")", "return", "oldpos", "=", "(", "rpoint", ".", "lat", "*", "1e-7", ",", "rpoint", ".", "lng", "*", "1e-7", ")", "self", ".", "rallyloader", ".", "move", "(", "idx", ",", "latlon", "[", "0", "]", ",", "latlon", "[", "1", "]", ")", "self", ".", "send_rally_point", "(", "idx", "-", "1", ")", "p", "=", "self", ".", "fetch_rally_point", "(", "idx", "-", "1", ")", "if", "p", ".", "lat", "!=", "int", "(", "latlon", "[", "0", "]", "*", "1e7", ")", "or", "p", ".", "lng", "!=", "int", "(", "latlon", "[", "1", "]", "*", "1e7", ")", ":", "print", "(", "\"Rally move failed\"", ")", "return", "self", ".", "rallyloader", ".", "reindex", "(", ")", "print", "(", "\"Moved rally point from %s to %s at %fm\"", "%", "(", "str", "(", "oldpos", ")", ",", "str", "(", "latlon", ")", ",", "rpoint", ".", "alt", ")", ")" ]
handle rally move
[ "handle", "rally", "move" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L140-L173
235,204
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.cmd_rally
def cmd_rally(self, args): '''rally point commands''' #TODO: add_land arg if len(args) < 1: self.print_usage() return elif args[0] == "add": self.cmd_rally_add(args[1:]) elif args[0] == "move": self.cmd_rally_move(args[1:]) elif args[0] == "clear": self.rallyloader.clear() self.mav_param.mavset(self.master,'RALLY_TOTAL',0,3) elif args[0] == "remove": if not self.have_list: print("Please list rally points first") return if (len(args) < 2): print("Usage: rally remove RALLYNUM") return self.rallyloader.remove(int(args[1])) self.send_rally_points() elif args[0] == "list": self.list_rally_points() self.have_list = True elif args[0] == "load": if (len(args) < 2): print("Usage: rally load filename") return try: self.rallyloader.load(args[1]) except Exception as msg: print("Unable to load %s - %s" % (args[1], msg)) return self.send_rally_points() self.have_list = True print("Loaded %u rally points from %s" % (self.rallyloader.rally_count(), args[1])) elif args[0] == "save": if (len(args) < 2): print("Usage: rally save filename") return self.rallyloader.save(args[1]) print("Saved rally file %s" % args[1]) elif args[0] == "alt": self.cmd_rally_alt(args[1:]) elif args[0] == "land": if (len(args) >= 2 and args[1] == "abort"): self.abort_ack_received = False self.abort_first_send_time = 0 self.abort_alt = self.settings.rally_breakalt if (len(args) >= 3): self.abort_alt = int(args[2]) else: self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component, mavutil.mavlink.MAV_CMD_DO_RALLY_LAND, 0, 0, 0, 0, 0, 0, 0, 0) else: self.print_usage()
python
def cmd_rally(self, args): '''rally point commands''' #TODO: add_land arg if len(args) < 1: self.print_usage() return elif args[0] == "add": self.cmd_rally_add(args[1:]) elif args[0] == "move": self.cmd_rally_move(args[1:]) elif args[0] == "clear": self.rallyloader.clear() self.mav_param.mavset(self.master,'RALLY_TOTAL',0,3) elif args[0] == "remove": if not self.have_list: print("Please list rally points first") return if (len(args) < 2): print("Usage: rally remove RALLYNUM") return self.rallyloader.remove(int(args[1])) self.send_rally_points() elif args[0] == "list": self.list_rally_points() self.have_list = True elif args[0] == "load": if (len(args) < 2): print("Usage: rally load filename") return try: self.rallyloader.load(args[1]) except Exception as msg: print("Unable to load %s - %s" % (args[1], msg)) return self.send_rally_points() self.have_list = True print("Loaded %u rally points from %s" % (self.rallyloader.rally_count(), args[1])) elif args[0] == "save": if (len(args) < 2): print("Usage: rally save filename") return self.rallyloader.save(args[1]) print("Saved rally file %s" % args[1]) elif args[0] == "alt": self.cmd_rally_alt(args[1:]) elif args[0] == "land": if (len(args) >= 2 and args[1] == "abort"): self.abort_ack_received = False self.abort_first_send_time = 0 self.abort_alt = self.settings.rally_breakalt if (len(args) >= 3): self.abort_alt = int(args[2]) else: self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component, mavutil.mavlink.MAV_CMD_DO_RALLY_LAND, 0, 0, 0, 0, 0, 0, 0, 0) else: self.print_usage()
[ "def", "cmd_rally", "(", "self", ",", "args", ")", ":", "#TODO: add_land arg", "if", "len", "(", "args", ")", "<", "1", ":", "self", ".", "print_usage", "(", ")", "return", "elif", "args", "[", "0", "]", "==", "\"add\"", ":", "self", ".", "cmd_rally_add", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"move\"", ":", "self", ".", "cmd_rally_move", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"clear\"", ":", "self", ".", "rallyloader", ".", "clear", "(", ")", "self", ".", "mav_param", ".", "mavset", "(", "self", ".", "master", ",", "'RALLY_TOTAL'", ",", "0", ",", "3", ")", "elif", "args", "[", "0", "]", "==", "\"remove\"", ":", "if", "not", "self", ".", "have_list", ":", "print", "(", "\"Please list rally points first\"", ")", "return", "if", "(", "len", "(", "args", ")", "<", "2", ")", ":", "print", "(", "\"Usage: rally remove RALLYNUM\"", ")", "return", "self", ".", "rallyloader", ".", "remove", "(", "int", "(", "args", "[", "1", "]", ")", ")", "self", ".", "send_rally_points", "(", ")", "elif", "args", "[", "0", "]", "==", "\"list\"", ":", "self", ".", "list_rally_points", "(", ")", "self", ".", "have_list", "=", "True", "elif", "args", "[", "0", "]", "==", "\"load\"", ":", "if", "(", "len", "(", "args", ")", "<", "2", ")", ":", "print", "(", "\"Usage: rally load filename\"", ")", "return", "try", ":", "self", ".", "rallyloader", ".", "load", "(", "args", "[", "1", "]", ")", "except", "Exception", "as", "msg", ":", "print", "(", "\"Unable to load %s - %s\"", "%", "(", "args", "[", "1", "]", ",", "msg", ")", ")", "return", "self", ".", "send_rally_points", "(", ")", "self", ".", "have_list", "=", "True", "print", "(", "\"Loaded %u rally points from %s\"", "%", "(", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ",", "args", "[", "1", "]", ")", ")", "elif", "args", "[", "0", "]", "==", "\"save\"", ":", "if", "(", "len", "(", "args", ")", "<", "2", ")", ":", "print", "(", "\"Usage: rally save filename\"", ")", "return", "self", ".", "rallyloader", ".", "save", "(", "args", "[", "1", "]", ")", "print", "(", "\"Saved rally file %s\"", "%", "args", "[", "1", "]", ")", "elif", "args", "[", "0", "]", "==", "\"alt\"", ":", "self", ".", "cmd_rally_alt", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"land\"", ":", "if", "(", "len", "(", "args", ")", ">=", "2", "and", "args", "[", "1", "]", "==", "\"abort\"", ")", ":", "self", ".", "abort_ack_received", "=", "False", "self", ".", "abort_first_send_time", "=", "0", "self", ".", "abort_alt", "=", "self", ".", "settings", ".", "rally_breakalt", "if", "(", "len", "(", "args", ")", ">=", "3", ")", ":", "self", ".", "abort_alt", "=", "int", "(", "args", "[", "2", "]", ")", "else", ":", "self", ".", "master", ".", "mav", ".", "command_long_send", "(", "self", ".", "settings", ".", "target_system", ",", "self", ".", "settings", ".", "target_component", ",", "mavutil", ".", "mavlink", ".", "MAV_CMD_DO_RALLY_LAND", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "self", ".", "print_usage", "(", ")" ]
rally point commands
[ "rally", "point", "commands" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L176-L251
235,205
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.mavlink_packet
def mavlink_packet(self, m): '''handle incoming mavlink packet''' type = m.get_type() if type in ['COMMAND_ACK']: if m.command == mavutil.mavlink.MAV_CMD_DO_GO_AROUND: if (m.result == 0 and self.abort_ack_received == False): self.say("Landing Abort Command Successfully Sent.") self.abort_ack_received = True elif (m.result != 0 and self.abort_ack_received == False): self.say("Landing Abort Command Unsuccessful.") elif m.command == mavutil.mavlink.MAV_CMD_DO_RALLY_LAND: if (m.result == 0): self.say("Landing.")
python
def mavlink_packet(self, m): '''handle incoming mavlink packet''' type = m.get_type() if type in ['COMMAND_ACK']: if m.command == mavutil.mavlink.MAV_CMD_DO_GO_AROUND: if (m.result == 0 and self.abort_ack_received == False): self.say("Landing Abort Command Successfully Sent.") self.abort_ack_received = True elif (m.result != 0 and self.abort_ack_received == False): self.say("Landing Abort Command Unsuccessful.") elif m.command == mavutil.mavlink.MAV_CMD_DO_RALLY_LAND: if (m.result == 0): self.say("Landing.")
[ "def", "mavlink_packet", "(", "self", ",", "m", ")", ":", "type", "=", "m", ".", "get_type", "(", ")", "if", "type", "in", "[", "'COMMAND_ACK'", "]", ":", "if", "m", ".", "command", "==", "mavutil", ".", "mavlink", ".", "MAV_CMD_DO_GO_AROUND", ":", "if", "(", "m", ".", "result", "==", "0", "and", "self", ".", "abort_ack_received", "==", "False", ")", ":", "self", ".", "say", "(", "\"Landing Abort Command Successfully Sent.\"", ")", "self", ".", "abort_ack_received", "=", "True", "elif", "(", "m", ".", "result", "!=", "0", "and", "self", ".", "abort_ack_received", "==", "False", ")", ":", "self", ".", "say", "(", "\"Landing Abort Command Unsuccessful.\"", ")", "elif", "m", ".", "command", "==", "mavutil", ".", "mavlink", ".", "MAV_CMD_DO_RALLY_LAND", ":", "if", "(", "m", ".", "result", "==", "0", ")", ":", "self", ".", "say", "(", "\"Landing.\"", ")" ]
handle incoming mavlink packet
[ "handle", "incoming", "mavlink", "packet" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L253-L266
235,206
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.send_rally_point
def send_rally_point(self, i): '''send rally points from fenceloader''' p = self.rallyloader.rally_point(i) p.target_system = self.target_system p.target_component = self.target_component self.master.mav.send(p)
python
def send_rally_point(self, i): '''send rally points from fenceloader''' p = self.rallyloader.rally_point(i) p.target_system = self.target_system p.target_component = self.target_component self.master.mav.send(p)
[ "def", "send_rally_point", "(", "self", ",", "i", ")", ":", "p", "=", "self", ".", "rallyloader", ".", "rally_point", "(", "i", ")", "p", ".", "target_system", "=", "self", ".", "target_system", "p", ".", "target_component", "=", "self", ".", "target_component", "self", ".", "master", ".", "mav", ".", "send", "(", "p", ")" ]
send rally points from fenceloader
[ "send", "rally", "points", "from", "fenceloader" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L268-L273
235,207
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
RallyModule.send_rally_points
def send_rally_points(self): '''send rally points from rallyloader''' self.mav_param.mavset(self.master,'RALLY_TOTAL',self.rallyloader.rally_count(),3) for i in range(self.rallyloader.rally_count()): self.send_rally_point(i)
python
def send_rally_points(self): '''send rally points from rallyloader''' self.mav_param.mavset(self.master,'RALLY_TOTAL',self.rallyloader.rally_count(),3) for i in range(self.rallyloader.rally_count()): self.send_rally_point(i)
[ "def", "send_rally_points", "(", "self", ")", ":", "self", ".", "mav_param", ".", "mavset", "(", "self", ".", "master", ",", "'RALLY_TOTAL'", ",", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ",", "3", ")", "for", "i", "in", "range", "(", "self", ".", "rallyloader", ".", "rally_count", "(", ")", ")", ":", "self", ".", "send_rally_point", "(", "i", ")" ]
send rally points from rallyloader
[ "send", "rally", "points", "from", "rallyloader" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L275-L280
235,208
JdeRobot/base
src/libs/comm_py/comm/ice/bumperIceClient.py
Bumper.getBumper
def getBumper(self): ''' Returns last Bumper. @return last JdeRobotTypes Bumper saved ''' if self.hasproxy(): self.lock.acquire() bumper = self.bumper self.lock.release() return bumper return None
python
def getBumper(self): ''' Returns last Bumper. @return last JdeRobotTypes Bumper saved ''' if self.hasproxy(): self.lock.acquire() bumper = self.bumper self.lock.release() return bumper return None
[ "def", "getBumper", "(", "self", ")", ":", "if", "self", ".", "hasproxy", "(", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "bumper", "=", "self", ".", "bumper", "self", ".", "lock", ".", "release", "(", ")", "return", "bumper", "return", "None" ]
Returns last Bumper. @return last JdeRobotTypes Bumper saved
[ "Returns", "last", "Bumper", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/bumperIceClient.py#L78-L91
235,209
JdeRobot/base
src/libs/comm_py/comm/ros/listenerRgbd.py
imageMsg2Image
def imageMsg2Image(img, bridge): ''' Translates from ROS Image to JderobotTypes Image. @param img: ROS Image to translate @param bridge: bridge to do translation @type img: sensor_msgs.msg.Image @type brige: CvBridge @return a JderobotTypes.Image translated from img ''' image = Image() image.width = img.width image.height = img.height image.format = "RGB8" image.timeStamp = img.header.stamp.secs + (img.header.stamp.nsecs *1e-9) cv_image=0 if (img.encoding == "32FC1"): gray_img_buff = bridge.imgmsg_to_cv2(img, "32FC1") cv_image = depthToRGB8(gray_img_buff) else: cv_image = bridge.imgmsg_to_cv2(img, "rgb8") image.data = cv_image return image
python
def imageMsg2Image(img, bridge): ''' Translates from ROS Image to JderobotTypes Image. @param img: ROS Image to translate @param bridge: bridge to do translation @type img: sensor_msgs.msg.Image @type brige: CvBridge @return a JderobotTypes.Image translated from img ''' image = Image() image.width = img.width image.height = img.height image.format = "RGB8" image.timeStamp = img.header.stamp.secs + (img.header.stamp.nsecs *1e-9) cv_image=0 if (img.encoding == "32FC1"): gray_img_buff = bridge.imgmsg_to_cv2(img, "32FC1") cv_image = depthToRGB8(gray_img_buff) else: cv_image = bridge.imgmsg_to_cv2(img, "rgb8") image.data = cv_image return image
[ "def", "imageMsg2Image", "(", "img", ",", "bridge", ")", ":", "image", "=", "Image", "(", ")", "image", ".", "width", "=", "img", ".", "width", "image", ".", "height", "=", "img", ".", "height", "image", ".", "format", "=", "\"RGB8\"", "image", ".", "timeStamp", "=", "img", ".", "header", ".", "stamp", ".", "secs", "+", "(", "img", ".", "header", ".", "stamp", ".", "nsecs", "*", "1e-9", ")", "cv_image", "=", "0", "if", "(", "img", ".", "encoding", "==", "\"32FC1\"", ")", ":", "gray_img_buff", "=", "bridge", ".", "imgmsg_to_cv2", "(", "img", ",", "\"32FC1\"", ")", "cv_image", "=", "depthToRGB8", "(", "gray_img_buff", ")", "else", ":", "cv_image", "=", "bridge", ".", "imgmsg_to_cv2", "(", "img", ",", "\"rgb8\"", ")", "image", ".", "data", "=", "cv_image", "return", "image" ]
Translates from ROS Image to JderobotTypes Image. @param img: ROS Image to translate @param bridge: bridge to do translation @type img: sensor_msgs.msg.Image @type brige: CvBridge @return a JderobotTypes.Image translated from img
[ "Translates", "from", "ROS", "Image", "to", "JderobotTypes", "Image", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerRgbd.py#L9-L35
235,210
JdeRobot/base
src/libs/comm_py/comm/ros/listenerRgbd.py
Images2Rgbd
def Images2Rgbd(rgb, d): ''' Translates from ROS Images to JderobotTypes Rgbd. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS @return a Rgbd translated from Images ''' data = Rgbd() data.color=imageMsg2Image(rgb) data.depth=imageMsg2Image(d) data.timeStamp = rgb.header.stamp.secs + (rgb.header.stamp.nsecs *1e-9) return data
python
def Images2Rgbd(rgb, d): ''' Translates from ROS Images to JderobotTypes Rgbd. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS @return a Rgbd translated from Images ''' data = Rgbd() data.color=imageMsg2Image(rgb) data.depth=imageMsg2Image(d) data.timeStamp = rgb.header.stamp.secs + (rgb.header.stamp.nsecs *1e-9) return data
[ "def", "Images2Rgbd", "(", "rgb", ",", "d", ")", ":", "data", "=", "Rgbd", "(", ")", "data", ".", "color", "=", "imageMsg2Image", "(", "rgb", ")", "data", ".", "depth", "=", "imageMsg2Image", "(", "d", ")", "data", ".", "timeStamp", "=", "rgb", ".", "header", ".", "stamp", ".", "secs", "+", "(", "rgb", ".", "header", ".", "stamp", ".", "nsecs", "*", "1e-9", ")", "return", "data" ]
Translates from ROS Images to JderobotTypes Rgbd. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS @return a Rgbd translated from Images
[ "Translates", "from", "ROS", "Images", "to", "JderobotTypes", "Rgbd", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerRgbd.py#L39-L58
235,211
JdeRobot/base
src/libs/comm_py/comm/ros/listenerRgbd.py
ListenerRgbd.__callback
def __callback (self, rgb, d): ''' Callback function to receive and save Rgbd Scans. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS ''' data = Images2Rgbd(rgb, d) self.lock.acquire() self.data = data self.lock.release()
python
def __callback (self, rgb, d): ''' Callback function to receive and save Rgbd Scans. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS ''' data = Images2Rgbd(rgb, d) self.lock.acquire() self.data = data self.lock.release()
[ "def", "__callback", "(", "self", ",", "rgb", ",", "d", ")", ":", "data", "=", "Images2Rgbd", "(", "rgb", ",", "d", ")", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "data", "=", "data", "self", ".", "lock", ".", "release", "(", ")" ]
Callback function to receive and save Rgbd Scans. @param rgb: ROS color Image to translate @param d: ROS depth image to translate @type rgb: ImageROS @type d: ImageROS
[ "Callback", "function", "to", "receive", "and", "save", "Rgbd", "Scans", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerRgbd.py#L84-L101
235,212
JdeRobot/base
src/libs/comm_py/comm/ros/listenerRgbd.py
ListenerRgbd.getRgbdData
def getRgbdData(self): ''' Returns last RgbdData. @return last JdeRobotTypes Rgbd saved ''' self.lock.acquire() data = self.data self.lock.release() return data
python
def getRgbdData(self): ''' Returns last RgbdData. @return last JdeRobotTypes Rgbd saved ''' self.lock.acquire() data = self.data self.lock.release() return data
[ "def", "getRgbdData", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "data", "=", "self", ".", "data", "self", ".", "lock", ".", "release", "(", ")", "return", "data" ]
Returns last RgbdData. @return last JdeRobotTypes Rgbd saved
[ "Returns", "last", "RgbdData", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerRgbd.py#L121-L132
235,213
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.fence_fetch_point_send
def fence_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False): ''' Request a current fence point from MAV target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 1, 0 is for return point) (uint8_t) ''' return self.send(self.fence_fetch_point_encode(target_system, target_component, idx), force_mavlink1=force_mavlink1)
python
def fence_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False): ''' Request a current fence point from MAV target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 1, 0 is for return point) (uint8_t) ''' return self.send(self.fence_fetch_point_encode(target_system, target_component, idx), force_mavlink1=force_mavlink1)
[ "def", "fence_fetch_point_send", "(", "self", ",", "target_system", ",", "target_component", ",", "idx", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "fence_fetch_point_encode", "(", "target_system", ",", "target_component", ",", "idx", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Request a current fence point from MAV target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 1, 0 is for return point) (uint8_t)
[ "Request", "a", "current", "fence", "point", "from", "MAV" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10005-L10014
235,214
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.hwstatus_send
def hwstatus_send(self, Vcc, I2Cerr, force_mavlink1=False): ''' Status of key hardware Vcc : board voltage (mV) (uint16_t) I2Cerr : I2C error count (uint8_t) ''' return self.send(self.hwstatus_encode(Vcc, I2Cerr), force_mavlink1=force_mavlink1)
python
def hwstatus_send(self, Vcc, I2Cerr, force_mavlink1=False): ''' Status of key hardware Vcc : board voltage (mV) (uint16_t) I2Cerr : I2C error count (uint8_t) ''' return self.send(self.hwstatus_encode(Vcc, I2Cerr), force_mavlink1=force_mavlink1)
[ "def", "hwstatus_send", "(", "self", ",", "Vcc", ",", "I2Cerr", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "hwstatus_encode", "(", "Vcc", ",", "I2Cerr", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Status of key hardware Vcc : board voltage (mV) (uint16_t) I2Cerr : I2C error count (uint8_t)
[ "Status", "of", "key", "hardware" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10120-L10128
235,215
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data16_send
def data16_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 16 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data16_encode(type, len, data), force_mavlink1=force_mavlink1)
python
def data16_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 16 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data16_encode(type, len, data), force_mavlink1=force_mavlink1)
[ "def", "data16_send", "(", "self", ",", "type", ",", "len", ",", "data", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "data16_encode", "(", "type", ",", "len", ",", "data", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Data packet, size 16 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
[ "Data", "packet", "size", "16" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10229-L10238
235,216
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data32_send
def data32_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 32 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data32_encode(type, len, data), force_mavlink1=force_mavlink1)
python
def data32_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 32 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data32_encode(type, len, data), force_mavlink1=force_mavlink1)
[ "def", "data32_send", "(", "self", ",", "type", ",", "len", ",", "data", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "data32_encode", "(", "type", ",", "len", ",", "data", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Data packet, size 32 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
[ "Data", "packet", "size", "32" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10251-L10260
235,217
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data64_send
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data64_encode(type, len, data), force_mavlink1=force_mavlink1)
python
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data64_encode(type, len, data), force_mavlink1=force_mavlink1)
[ "def", "data64_send", "(", "self", ",", "type", ",", "len", ",", "data", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "data64_encode", "(", "type", ",", "len", ",", "data", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
[ "Data", "packet", "size", "64" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10273-L10282
235,218
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data96_send
def data96_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 96 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data96_encode(type, len, data), force_mavlink1=force_mavlink1)
python
def data96_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 96 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data96_encode(type, len, data), force_mavlink1=force_mavlink1)
[ "def", "data96_send", "(", "self", ",", "type", ",", "len", ",", "data", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "data96_encode", "(", "type", ",", "len", ",", "data", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Data packet, size 96 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
[ "Data", "packet", "size", "96" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10295-L10304
235,219
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.rally_fetch_point_send
def rally_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False): ''' Request a current rally point from MAV. MAV should respond with a RALLY_POINT message. MAV should not respond if the request is invalid. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 0) (uint8_t) ''' return self.send(self.rally_fetch_point_encode(target_system, target_component, idx), force_mavlink1=force_mavlink1)
python
def rally_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False): ''' Request a current rally point from MAV. MAV should respond with a RALLY_POINT message. MAV should not respond if the request is invalid. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 0) (uint8_t) ''' return self.send(self.rally_fetch_point_encode(target_system, target_component, idx), force_mavlink1=force_mavlink1)
[ "def", "rally_fetch_point_send", "(", "self", ",", "target_system", ",", "target_component", ",", "idx", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "rally_fetch_point_encode", "(", "target_system", ",", "target_component", ",", "idx", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Request a current rally point from MAV. MAV should respond with a RALLY_POINT message. MAV should not respond if the request is invalid. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) idx : point index (first point is 0) (uint8_t)
[ "Request", "a", "current", "rally", "point", "from", "MAV", ".", "MAV", "should", "respond", "with", "a", "RALLY_POINT", "message", ".", "MAV", "should", "not", "respond", "if", "the", "request", "is", "invalid", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10417-L10428
235,220
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.battery2_send
def battery2_send(self, voltage, current_battery, force_mavlink1=False): ''' 2nd Battery status voltage : voltage in millivolts (uint16_t) current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current (int16_t) ''' return self.send(self.battery2_encode(voltage, current_battery), force_mavlink1=force_mavlink1)
python
def battery2_send(self, voltage, current_battery, force_mavlink1=False): ''' 2nd Battery status voltage : voltage in millivolts (uint16_t) current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current (int16_t) ''' return self.send(self.battery2_encode(voltage, current_battery), force_mavlink1=force_mavlink1)
[ "def", "battery2_send", "(", "self", ",", "voltage", ",", "current_battery", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "battery2_encode", "(", "voltage", ",", "current_battery", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
2nd Battery status voltage : voltage in millivolts (uint16_t) current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current (int16_t)
[ "2nd", "Battery", "status" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10572-L10580
235,221
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.gopro_heartbeat_send
def gopro_heartbeat_send(self, status, capture_mode, flags, force_mavlink1=False): ''' Heartbeat from a HeroBus attached GoPro status : Status (uint8_t) capture_mode : Current capture mode (uint8_t) flags : additional status bits (uint8_t) ''' return self.send(self.gopro_heartbeat_encode(status, capture_mode, flags), force_mavlink1=force_mavlink1)
python
def gopro_heartbeat_send(self, status, capture_mode, flags, force_mavlink1=False): ''' Heartbeat from a HeroBus attached GoPro status : Status (uint8_t) capture_mode : Current capture mode (uint8_t) flags : additional status bits (uint8_t) ''' return self.send(self.gopro_heartbeat_encode(status, capture_mode, flags), force_mavlink1=force_mavlink1)
[ "def", "gopro_heartbeat_send", "(", "self", ",", "status", ",", "capture_mode", ",", "flags", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "gopro_heartbeat_encode", "(", "status", ",", "capture_mode", ",", "flags", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Heartbeat from a HeroBus attached GoPro status : Status (uint8_t) capture_mode : Current capture mode (uint8_t) flags : additional status bits (uint8_t)
[ "Heartbeat", "from", "a", "HeroBus", "attached", "GoPro" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10957-L10966
235,222
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.gopro_get_request_send
def gopro_get_request_send(self, target_system, target_component, cmd_id, force_mavlink1=False): ''' Request a GOPRO_COMMAND response from the GoPro target_system : System ID (uint8_t) target_component : Component ID (uint8_t) cmd_id : Command ID (uint8_t) ''' return self.send(self.gopro_get_request_encode(target_system, target_component, cmd_id), force_mavlink1=force_mavlink1)
python
def gopro_get_request_send(self, target_system, target_component, cmd_id, force_mavlink1=False): ''' Request a GOPRO_COMMAND response from the GoPro target_system : System ID (uint8_t) target_component : Component ID (uint8_t) cmd_id : Command ID (uint8_t) ''' return self.send(self.gopro_get_request_encode(target_system, target_component, cmd_id), force_mavlink1=force_mavlink1)
[ "def", "gopro_get_request_send", "(", "self", ",", "target_system", ",", "target_component", ",", "cmd_id", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "gopro_get_request_encode", "(", "target_system", ",", "target_component", ",", "cmd_id", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Request a GOPRO_COMMAND response from the GoPro target_system : System ID (uint8_t) target_component : Component ID (uint8_t) cmd_id : Command ID (uint8_t)
[ "Request", "a", "GOPRO_COMMAND", "response", "from", "the", "GoPro" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10979-L10988
235,223
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.gopro_get_response_send
def gopro_get_response_send(self, cmd_id, status, value, force_mavlink1=False): ''' Response from a GOPRO_COMMAND get request cmd_id : Command ID (uint8_t) status : Status (uint8_t) value : Value (uint8_t) ''' return self.send(self.gopro_get_response_encode(cmd_id, status, value), force_mavlink1=force_mavlink1)
python
def gopro_get_response_send(self, cmd_id, status, value, force_mavlink1=False): ''' Response from a GOPRO_COMMAND get request cmd_id : Command ID (uint8_t) status : Status (uint8_t) value : Value (uint8_t) ''' return self.send(self.gopro_get_response_encode(cmd_id, status, value), force_mavlink1=force_mavlink1)
[ "def", "gopro_get_response_send", "(", "self", ",", "cmd_id", ",", "status", ",", "value", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "gopro_get_response_encode", "(", "cmd_id", ",", "status", ",", "value", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Response from a GOPRO_COMMAND get request cmd_id : Command ID (uint8_t) status : Status (uint8_t) value : Value (uint8_t)
[ "Response", "from", "a", "GOPRO_COMMAND", "get", "request" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L11001-L11010
235,224
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.gopro_set_response_send
def gopro_set_response_send(self, cmd_id, status, force_mavlink1=False): ''' Response from a GOPRO_COMMAND set request cmd_id : Command ID (uint8_t) status : Status (uint8_t) ''' return self.send(self.gopro_set_response_encode(cmd_id, status), force_mavlink1=force_mavlink1)
python
def gopro_set_response_send(self, cmd_id, status, force_mavlink1=False): ''' Response from a GOPRO_COMMAND set request cmd_id : Command ID (uint8_t) status : Status (uint8_t) ''' return self.send(self.gopro_set_response_encode(cmd_id, status), force_mavlink1=force_mavlink1)
[ "def", "gopro_set_response_send", "(", "self", ",", "cmd_id", ",", "status", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "gopro_set_response_encode", "(", "cmd_id", ",", "status", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Response from a GOPRO_COMMAND set request cmd_id : Command ID (uint8_t) status : Status (uint8_t)
[ "Response", "from", "a", "GOPRO_COMMAND", "set", "request" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L11046-L11054
235,225
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.rpm_send
def rpm_send(self, rpm1, rpm2, force_mavlink1=False): ''' RPM sensor output rpm1 : RPM Sensor1 (float) rpm2 : RPM Sensor2 (float) ''' return self.send(self.rpm_encode(rpm1, rpm2), force_mavlink1=force_mavlink1)
python
def rpm_send(self, rpm1, rpm2, force_mavlink1=False): ''' RPM sensor output rpm1 : RPM Sensor1 (float) rpm2 : RPM Sensor2 (float) ''' return self.send(self.rpm_encode(rpm1, rpm2), force_mavlink1=force_mavlink1)
[ "def", "rpm_send", "(", "self", ",", "rpm1", ",", "rpm2", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "rpm_encode", "(", "rpm1", ",", "rpm2", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
RPM sensor output rpm1 : RPM Sensor1 (float) rpm2 : RPM Sensor2 (float)
[ "RPM", "sensor", "output" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L11066-L11074
235,226
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.convert
def convert(self, value, fromunits, tounits): '''convert a value from one set of units to another''' if fromunits == tounits: return value if (fromunits,tounits) in self.unitmap: return value * self.unitmap[(fromunits,tounits)] if (tounits,fromunits) in self.unitmap: return value / self.unitmap[(tounits,fromunits)] raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
python
def convert(self, value, fromunits, tounits): '''convert a value from one set of units to another''' if fromunits == tounits: return value if (fromunits,tounits) in self.unitmap: return value * self.unitmap[(fromunits,tounits)] if (tounits,fromunits) in self.unitmap: return value / self.unitmap[(tounits,fromunits)] raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
[ "def", "convert", "(", "self", ",", "value", ",", "fromunits", ",", "tounits", ")", ":", "if", "fromunits", "==", "tounits", ":", "return", "value", "if", "(", "fromunits", ",", "tounits", ")", "in", "self", ".", "unitmap", ":", "return", "value", "*", "self", ".", "unitmap", "[", "(", "fromunits", ",", "tounits", ")", "]", "if", "(", "tounits", ",", "fromunits", ")", "in", "self", ".", "unitmap", ":", "return", "value", "/", "self", ".", "unitmap", "[", "(", "tounits", ",", "fromunits", ")", "]", "raise", "fgFDMError", "(", "\"unknown unit mapping (%s,%s)\"", "%", "(", "fromunits", ",", "tounits", ")", ")" ]
convert a value from one set of units to another
[ "convert", "a", "value", "from", "one", "set", "of", "units", "to", "another" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L149-L157
235,227
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.units
def units(self, varname): '''return the default units of a variable''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) return self.mapping.vars[varname].units
python
def units(self, varname): '''return the default units of a variable''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) return self.mapping.vars[varname].units
[ "def", "units", "(", "self", ",", "varname", ")", ":", "if", "not", "varname", "in", "self", ".", "mapping", ".", "vars", ":", "raise", "fgFDMError", "(", "'Unknown variable %s'", "%", "varname", ")", "return", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "units" ]
return the default units of a variable
[ "return", "the", "default", "units", "of", "a", "variable" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L160-L164
235,228
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.variables
def variables(self): '''return a list of available variables''' return sorted(list(self.mapping.vars.keys()), key = lambda v : self.mapping.vars[v].index)
python
def variables(self): '''return a list of available variables''' return sorted(list(self.mapping.vars.keys()), key = lambda v : self.mapping.vars[v].index)
[ "def", "variables", "(", "self", ")", ":", "return", "sorted", "(", "list", "(", "self", ".", "mapping", ".", "vars", ".", "keys", "(", ")", ")", ",", "key", "=", "lambda", "v", ":", "self", ".", "mapping", ".", "vars", "[", "v", "]", ".", "index", ")" ]
return a list of available variables
[ "return", "a", "list", "of", "available", "variables" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L167-L170
235,229
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.get
def get(self, varname, idx=0, units=None): '''get a variable value''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) if idx >= self.mapping.vars[varname].arraylength: raise fgFDMError('index of %s beyond end of array idx=%u arraylength=%u' % ( varname, idx, self.mapping.vars[varname].arraylength)) value = self.values[self.mapping.vars[varname].index + idx] if units: value = self.convert(value, self.mapping.vars[varname].units, units) return value
python
def get(self, varname, idx=0, units=None): '''get a variable value''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) if idx >= self.mapping.vars[varname].arraylength: raise fgFDMError('index of %s beyond end of array idx=%u arraylength=%u' % ( varname, idx, self.mapping.vars[varname].arraylength)) value = self.values[self.mapping.vars[varname].index + idx] if units: value = self.convert(value, self.mapping.vars[varname].units, units) return value
[ "def", "get", "(", "self", ",", "varname", ",", "idx", "=", "0", ",", "units", "=", "None", ")", ":", "if", "not", "varname", "in", "self", ".", "mapping", ".", "vars", ":", "raise", "fgFDMError", "(", "'Unknown variable %s'", "%", "varname", ")", "if", "idx", ">=", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "arraylength", ":", "raise", "fgFDMError", "(", "'index of %s beyond end of array idx=%u arraylength=%u'", "%", "(", "varname", ",", "idx", ",", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "arraylength", ")", ")", "value", "=", "self", ".", "values", "[", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "index", "+", "idx", "]", "if", "units", ":", "value", "=", "self", ".", "convert", "(", "value", ",", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "units", ",", "units", ")", "return", "value" ]
get a variable value
[ "get", "a", "variable", "value" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L173-L183
235,230
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.set
def set(self, varname, value, idx=0, units=None): '''set a variable value''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) if idx >= self.mapping.vars[varname].arraylength: raise fgFDMError('index of %s beyond end of array idx=%u arraylength=%u' % ( varname, idx, self.mapping.vars[varname].arraylength)) if units: value = self.convert(value, units, self.mapping.vars[varname].units) # avoid range errors when packing into 4 byte floats if math.isinf(value) or math.isnan(value) or math.fabs(value) > 3.4e38: value = 0 self.values[self.mapping.vars[varname].index + idx] = value
python
def set(self, varname, value, idx=0, units=None): '''set a variable value''' if not varname in self.mapping.vars: raise fgFDMError('Unknown variable %s' % varname) if idx >= self.mapping.vars[varname].arraylength: raise fgFDMError('index of %s beyond end of array idx=%u arraylength=%u' % ( varname, idx, self.mapping.vars[varname].arraylength)) if units: value = self.convert(value, units, self.mapping.vars[varname].units) # avoid range errors when packing into 4 byte floats if math.isinf(value) or math.isnan(value) or math.fabs(value) > 3.4e38: value = 0 self.values[self.mapping.vars[varname].index + idx] = value
[ "def", "set", "(", "self", ",", "varname", ",", "value", ",", "idx", "=", "0", ",", "units", "=", "None", ")", ":", "if", "not", "varname", "in", "self", ".", "mapping", ".", "vars", ":", "raise", "fgFDMError", "(", "'Unknown variable %s'", "%", "varname", ")", "if", "idx", ">=", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "arraylength", ":", "raise", "fgFDMError", "(", "'index of %s beyond end of array idx=%u arraylength=%u'", "%", "(", "varname", ",", "idx", ",", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "arraylength", ")", ")", "if", "units", ":", "value", "=", "self", ".", "convert", "(", "value", ",", "units", ",", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "units", ")", "# avoid range errors when packing into 4 byte floats", "if", "math", ".", "isinf", "(", "value", ")", "or", "math", ".", "isnan", "(", "value", ")", "or", "math", ".", "fabs", "(", "value", ")", ">", "3.4e38", ":", "value", "=", "0", "self", ".", "values", "[", "self", ".", "mapping", ".", "vars", "[", "varname", "]", ".", "index", "+", "idx", "]", "=", "value" ]
set a variable value
[ "set", "a", "variable", "value" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L185-L197
235,231
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.parse
def parse(self, buf): '''parse a FD FDM buffer''' try: t = struct.unpack(self.pack_string, buf) except struct.error as msg: raise fgFDMError('unable to parse - %s' % msg) self.values = list(t)
python
def parse(self, buf): '''parse a FD FDM buffer''' try: t = struct.unpack(self.pack_string, buf) except struct.error as msg: raise fgFDMError('unable to parse - %s' % msg) self.values = list(t)
[ "def", "parse", "(", "self", ",", "buf", ")", ":", "try", ":", "t", "=", "struct", ".", "unpack", "(", "self", ".", "pack_string", ",", "buf", ")", "except", "struct", ".", "error", "as", "msg", ":", "raise", "fgFDMError", "(", "'unable to parse - %s'", "%", "msg", ")", "self", ".", "values", "=", "list", "(", "t", ")" ]
parse a FD FDM buffer
[ "parse", "a", "FD", "FDM", "buffer" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L199-L205
235,232
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py
fgFDM.pack
def pack(self): '''pack a FD FDM buffer from current values''' for i in range(len(self.values)): if math.isnan(self.values[i]): self.values[i] = 0 return struct.pack(self.pack_string, *self.values)
python
def pack(self): '''pack a FD FDM buffer from current values''' for i in range(len(self.values)): if math.isnan(self.values[i]): self.values[i] = 0 return struct.pack(self.pack_string, *self.values)
[ "def", "pack", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "values", ")", ")", ":", "if", "math", ".", "isnan", "(", "self", ".", "values", "[", "i", "]", ")", ":", "self", ".", "values", "[", "i", "]", "=", "0", "return", "struct", ".", "pack", "(", "self", ".", "pack_string", ",", "*", "self", ".", "values", ")" ]
pack a FD FDM buffer from current values
[ "pack", "a", "FD", "FDM", "buffer", "from", "current", "values" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/fgFDM.py#L207-L212
235,233
JdeRobot/base
src/drivers/drone/pose3d.py
quat2Yaw
def quat2Yaw(qw, qx, qy, qz): ''' Translates from Quaternion to Yaw. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Yaw value translated from Quaternion ''' rotateZa0=2.0*(qx*qy + qw*qz) rotateZa1=qw*qw + qx*qx - qy*qy - qz*qz rotateZ=0.0 if(rotateZa0 != 0.0 and rotateZa1 != 0.0): rotateZ=atan2(rotateZa0,rotateZa1) return rotateZ
python
def quat2Yaw(qw, qx, qy, qz): ''' Translates from Quaternion to Yaw. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Yaw value translated from Quaternion ''' rotateZa0=2.0*(qx*qy + qw*qz) rotateZa1=qw*qw + qx*qx - qy*qy - qz*qz rotateZ=0.0 if(rotateZa0 != 0.0 and rotateZa1 != 0.0): rotateZ=atan2(rotateZa0,rotateZa1) return rotateZ
[ "def", "quat2Yaw", "(", "qw", ",", "qx", ",", "qy", ",", "qz", ")", ":", "rotateZa0", "=", "2.0", "*", "(", "qx", "*", "qy", "+", "qw", "*", "qz", ")", "rotateZa1", "=", "qw", "*", "qw", "+", "qx", "*", "qx", "-", "qy", "*", "qy", "-", "qz", "*", "qz", "rotateZ", "=", "0.0", "if", "(", "rotateZa0", "!=", "0.0", "and", "rotateZa1", "!=", "0.0", ")", ":", "rotateZ", "=", "atan2", "(", "rotateZa0", ",", "rotateZa1", ")", "return", "rotateZ" ]
Translates from Quaternion to Yaw. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Yaw value translated from Quaternion
[ "Translates", "from", "Quaternion", "to", "Yaw", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/drone/pose3d.py#L7-L23
235,234
JdeRobot/base
src/drivers/drone/pose3d.py
quat2Pitch
def quat2Pitch(qw, qx, qy, qz): ''' Translates from Quaternion to Pitch. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Pitch value translated from Quaternion ''' rotateYa0=-2.0*(qx*qz - qw*qy) rotateY=0.0 if(rotateYa0 >= 1.0): rotateY = pi/2.0 elif(rotateYa0 <= -1.0): rotateY = -pi/2.0 else: rotateY = asin(rotateYa0) return rotateY
python
def quat2Pitch(qw, qx, qy, qz): ''' Translates from Quaternion to Pitch. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Pitch value translated from Quaternion ''' rotateYa0=-2.0*(qx*qz - qw*qy) rotateY=0.0 if(rotateYa0 >= 1.0): rotateY = pi/2.0 elif(rotateYa0 <= -1.0): rotateY = -pi/2.0 else: rotateY = asin(rotateYa0) return rotateY
[ "def", "quat2Pitch", "(", "qw", ",", "qx", ",", "qy", ",", "qz", ")", ":", "rotateYa0", "=", "-", "2.0", "*", "(", "qx", "*", "qz", "-", "qw", "*", "qy", ")", "rotateY", "=", "0.0", "if", "(", "rotateYa0", ">=", "1.0", ")", ":", "rotateY", "=", "pi", "/", "2.0", "elif", "(", "rotateYa0", "<=", "-", "1.0", ")", ":", "rotateY", "=", "-", "pi", "/", "2.0", "else", ":", "rotateY", "=", "asin", "(", "rotateYa0", ")", "return", "rotateY" ]
Translates from Quaternion to Pitch. @param qw,qx,qy,qz: Quaternion values @type qw,qx,qy,qz: float @return Pitch value translated from Quaternion
[ "Translates", "from", "Quaternion", "to", "Pitch", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/drone/pose3d.py#L25-L46
235,235
JdeRobot/base
src/drivers/drone/pose3d.py
odometry2Pose3D
def odometry2Pose3D(odom): ''' Translates from ROS Odometry to JderobotTypes Pose3d. @param odom: ROS Odometry to translate @type odom: Odometry @return a Pose3d translated from odom ''' pose = Pose3d() ori = odom.pose.pose.orientation pose.x = odom.pose.pose.position.x pose.y = odom.pose.pose.position.y pose.z = odom.pose.pose.position.z #pose.h = odom.pose.pose.position.h pose.yaw = quat2Yaw(ori.w, ori.x, ori.y, ori.z) pose.pitch = quat2Pitch(ori.w, ori.x, ori.y, ori.z) pose.roll = quat2Roll(ori.w, ori.x, ori.y, ori.z) pose.q = [ori.w, ori.x, ori.y, ori.z] pose.timeStamp = odom.header.stamp.secs + (odom.header.stamp.nsecs *1e-9) return pose
python
def odometry2Pose3D(odom): ''' Translates from ROS Odometry to JderobotTypes Pose3d. @param odom: ROS Odometry to translate @type odom: Odometry @return a Pose3d translated from odom ''' pose = Pose3d() ori = odom.pose.pose.orientation pose.x = odom.pose.pose.position.x pose.y = odom.pose.pose.position.y pose.z = odom.pose.pose.position.z #pose.h = odom.pose.pose.position.h pose.yaw = quat2Yaw(ori.w, ori.x, ori.y, ori.z) pose.pitch = quat2Pitch(ori.w, ori.x, ori.y, ori.z) pose.roll = quat2Roll(ori.w, ori.x, ori.y, ori.z) pose.q = [ori.w, ori.x, ori.y, ori.z] pose.timeStamp = odom.header.stamp.secs + (odom.header.stamp.nsecs *1e-9) return pose
[ "def", "odometry2Pose3D", "(", "odom", ")", ":", "pose", "=", "Pose3d", "(", ")", "ori", "=", "odom", ".", "pose", ".", "pose", ".", "orientation", "pose", ".", "x", "=", "odom", ".", "pose", ".", "pose", ".", "position", ".", "x", "pose", ".", "y", "=", "odom", ".", "pose", ".", "pose", ".", "position", ".", "y", "pose", ".", "z", "=", "odom", ".", "pose", ".", "pose", ".", "position", ".", "z", "#pose.h = odom.pose.pose.position.h", "pose", ".", "yaw", "=", "quat2Yaw", "(", "ori", ".", "w", ",", "ori", ".", "x", ",", "ori", ".", "y", ",", "ori", ".", "z", ")", "pose", ".", "pitch", "=", "quat2Pitch", "(", "ori", ".", "w", ",", "ori", ".", "x", ",", "ori", ".", "y", ",", "ori", ".", "z", ")", "pose", ".", "roll", "=", "quat2Roll", "(", "ori", ".", "w", ",", "ori", ".", "x", ",", "ori", ".", "y", ",", "ori", ".", "z", ")", "pose", ".", "q", "=", "[", "ori", ".", "w", ",", "ori", ".", "x", ",", "ori", ".", "y", ",", "ori", ".", "z", "]", "pose", ".", "timeStamp", "=", "odom", ".", "header", ".", "stamp", ".", "secs", "+", "(", "odom", ".", "header", ".", "stamp", ".", "nsecs", "*", "1e-9", ")", "return", "pose" ]
Translates from ROS Odometry to JderobotTypes Pose3d. @param odom: ROS Odometry to translate @type odom: Odometry @return a Pose3d translated from odom
[ "Translates", "from", "ROS", "Odometry", "to", "JderobotTypes", "Pose3d", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/drone/pose3d.py#L68-L92
235,236
JdeRobot/base
src/drivers/drone/pose3d.py
ListenerPose3d.__callback
def __callback (self, odom): ''' Callback function to receive and save Pose3d. @param odom: ROS Odometry received @type odom: Odometry ''' pose = odometry2Pose3D(odom) self.lock.acquire() self.data = pose self.lock.release()
python
def __callback (self, odom): ''' Callback function to receive and save Pose3d. @param odom: ROS Odometry received @type odom: Odometry ''' pose = odometry2Pose3D(odom) self.lock.acquire() self.data = pose self.lock.release()
[ "def", "__callback", "(", "self", ",", "odom", ")", ":", "pose", "=", "odometry2Pose3D", "(", "odom", ")", "self", ".", "lock", ".", "acquire", "(", ")", "self", ".", "data", "=", "pose", "self", ".", "lock", ".", "release", "(", ")" ]
Callback function to receive and save Pose3d. @param odom: ROS Odometry received @type odom: Odometry
[ "Callback", "function", "to", "receive", "and", "save", "Pose3d", "." ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/drone/pose3d.py#L135-L148
235,237
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipObject.clip
def clip(self, px, py, w, h, img): '''clip an area for display on the map''' sx = 0 sy = 0 if px < 0: sx = -px w += px px = 0 if py < 0: sy = -py h += py py = 0 if px+w > img.width: w = img.width - px if py+h > img.height: h = img.height - py return (px, py, sx, sy, w, h)
python
def clip(self, px, py, w, h, img): '''clip an area for display on the map''' sx = 0 sy = 0 if px < 0: sx = -px w += px px = 0 if py < 0: sy = -py h += py py = 0 if px+w > img.width: w = img.width - px if py+h > img.height: h = img.height - py return (px, py, sx, sy, w, h)
[ "def", "clip", "(", "self", ",", "px", ",", "py", ",", "w", ",", "h", ",", "img", ")", ":", "sx", "=", "0", "sy", "=", "0", "if", "px", "<", "0", ":", "sx", "=", "-", "px", "w", "+=", "px", "px", "=", "0", "if", "py", "<", "0", ":", "sy", "=", "-", "py", "h", "+=", "py", "py", "=", "0", "if", "px", "+", "w", ">", "img", ".", "width", ":", "w", "=", "img", ".", "width", "-", "px", "if", "py", "+", "h", ">", "img", ".", "height", ":", "h", "=", "img", ".", "height", "-", "py", "return", "(", "px", ",", "py", ",", "sx", ",", "sy", ",", "w", ",", "h", ")" ]
clip an area for display on the map
[ "clip", "an", "area", "for", "display", "on", "the", "map" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L33-L50
235,238
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipObject.update_position
def update_position(self, newpos): '''update object position''' if getattr(self, 'trail', None) is not None: self.trail.update_position(newpos) self.latlon = newpos.latlon if hasattr(self, 'rotation'): self.rotation = newpos.rotation
python
def update_position(self, newpos): '''update object position''' if getattr(self, 'trail', None) is not None: self.trail.update_position(newpos) self.latlon = newpos.latlon if hasattr(self, 'rotation'): self.rotation = newpos.rotation
[ "def", "update_position", "(", "self", ",", "newpos", ")", ":", "if", "getattr", "(", "self", ",", "'trail'", ",", "None", ")", "is", "not", "None", ":", "self", ".", "trail", ".", "update_position", "(", "newpos", ")", "self", ".", "latlon", "=", "newpos", ".", "latlon", "if", "hasattr", "(", "self", ",", "'rotation'", ")", ":", "self", ".", "rotation", "=", "newpos", ".", "rotation" ]
update object position
[ "update", "object", "position" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L56-L62
235,239
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipPolygon.clicked
def clicked(self, px, py): '''see if the polygon has been clicked on. Consider it clicked if the pixel is within 6 of the point ''' if self.hidden: return None for i in range(len(self._pix_points)): if self._pix_points[i] is None: continue (pixx,pixy) = self._pix_points[i] if abs(px - pixx) < 6 and abs(py - pixy) < 6: self._selected_vertex = i return math.sqrt((px - pixx)**2 + (py - pixy)**2) return None
python
def clicked(self, px, py): '''see if the polygon has been clicked on. Consider it clicked if the pixel is within 6 of the point ''' if self.hidden: return None for i in range(len(self._pix_points)): if self._pix_points[i] is None: continue (pixx,pixy) = self._pix_points[i] if abs(px - pixx) < 6 and abs(py - pixy) < 6: self._selected_vertex = i return math.sqrt((px - pixx)**2 + (py - pixy)**2) return None
[ "def", "clicked", "(", "self", ",", "px", ",", "py", ")", ":", "if", "self", ".", "hidden", ":", "return", "None", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_pix_points", ")", ")", ":", "if", "self", ".", "_pix_points", "[", "i", "]", "is", "None", ":", "continue", "(", "pixx", ",", "pixy", ")", "=", "self", ".", "_pix_points", "[", "i", "]", "if", "abs", "(", "px", "-", "pixx", ")", "<", "6", "and", "abs", "(", "py", "-", "pixy", ")", "<", "6", ":", "self", ".", "_selected_vertex", "=", "i", "return", "math", ".", "sqrt", "(", "(", "px", "-", "pixx", ")", "**", "2", "+", "(", "py", "-", "pixy", ")", "**", "2", ")", "return", "None" ]
see if the polygon has been clicked on. Consider it clicked if the pixel is within 6 of the point
[ "see", "if", "the", "polygon", "has", "been", "clicked", "on", ".", "Consider", "it", "clicked", "if", "the", "pixel", "is", "within", "6", "of", "the", "point" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L181-L194
235,240
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipThumbnail.clicked
def clicked(self, px, py): '''see if the image has been clicked on''' if self.hidden: return None if (abs(px - self.posx) > self.width/2 or abs(py - self.posy) > self.height/2): return None return math.sqrt((px-self.posx)**2 + (py-self.posy)**2)
python
def clicked(self, px, py): '''see if the image has been clicked on''' if self.hidden: return None if (abs(px - self.posx) > self.width/2 or abs(py - self.posy) > self.height/2): return None return math.sqrt((px-self.posx)**2 + (py-self.posy)**2)
[ "def", "clicked", "(", "self", ",", "px", ",", "py", ")", ":", "if", "self", ".", "hidden", ":", "return", "None", "if", "(", "abs", "(", "px", "-", "self", ".", "posx", ")", ">", "self", ".", "width", "/", "2", "or", "abs", "(", "py", "-", "self", ".", "posy", ")", ">", "self", ".", "height", "/", "2", ")", ":", "return", "None", "return", "math", ".", "sqrt", "(", "(", "px", "-", "self", ".", "posx", ")", "**", "2", "+", "(", "py", "-", "self", ".", "posy", ")", "**", "2", ")" ]
see if the image has been clicked on
[ "see", "if", "the", "image", "has", "been", "clicked", "on" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L304-L311
235,241
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipInfoImage.draw
def draw(self, parent, box): '''redraw the image''' import wx from MAVProxy.modules.lib import mp_widgets if self.imgpanel is None: self.imgpanel = mp_widgets.ImagePanel(parent, self.img()) box.Add(self.imgpanel, flag=wx.LEFT, border=0) box.Layout()
python
def draw(self, parent, box): '''redraw the image''' import wx from MAVProxy.modules.lib import mp_widgets if self.imgpanel is None: self.imgpanel = mp_widgets.ImagePanel(parent, self.img()) box.Add(self.imgpanel, flag=wx.LEFT, border=0) box.Layout()
[ "def", "draw", "(", "self", ",", "parent", ",", "box", ")", ":", "import", "wx", "from", "MAVProxy", ".", "modules", ".", "lib", "import", "mp_widgets", "if", "self", ".", "imgpanel", "is", "None", ":", "self", ".", "imgpanel", "=", "mp_widgets", ".", "ImagePanel", "(", "parent", ",", "self", ".", "img", "(", ")", ")", "box", ".", "Add", "(", "self", ".", "imgpanel", ",", "flag", "=", "wx", ".", "LEFT", ",", "border", "=", "0", ")", "box", ".", "Layout", "(", ")" ]
redraw the image
[ "redraw", "the", "image" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L464-L471
235,242
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipInfoText._resize
def _resize(self): '''calculate and set text size, handling multi-line''' lines = self.text.split('\n') xsize, ysize = 0, 0 for line in lines: size = self.textctrl.GetTextExtent(line) xsize = max(xsize, size[0]) ysize = ysize + size[1] xsize = int(xsize*1.2) self.textctrl.SetSize((xsize, ysize)) self.textctrl.SetMinSize((xsize, ysize))
python
def _resize(self): '''calculate and set text size, handling multi-line''' lines = self.text.split('\n') xsize, ysize = 0, 0 for line in lines: size = self.textctrl.GetTextExtent(line) xsize = max(xsize, size[0]) ysize = ysize + size[1] xsize = int(xsize*1.2) self.textctrl.SetSize((xsize, ysize)) self.textctrl.SetMinSize((xsize, ysize))
[ "def", "_resize", "(", "self", ")", ":", "lines", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "xsize", ",", "ysize", "=", "0", ",", "0", "for", "line", "in", "lines", ":", "size", "=", "self", ".", "textctrl", ".", "GetTextExtent", "(", "line", ")", "xsize", "=", "max", "(", "xsize", ",", "size", "[", "0", "]", ")", "ysize", "=", "ysize", "+", "size", "[", "1", "]", "xsize", "=", "int", "(", "xsize", "*", "1.2", ")", "self", ".", "textctrl", ".", "SetSize", "(", "(", "xsize", ",", "ysize", ")", ")", "self", ".", "textctrl", ".", "SetMinSize", "(", "(", "xsize", ",", "ysize", ")", ")" ]
calculate and set text size, handling multi-line
[ "calculate", "and", "set", "text", "size", "handling", "multi", "-", "line" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L489-L499
235,243
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
SlipInfoText.draw
def draw(self, parent, box): '''redraw the text''' import wx if self.textctrl is None: self.textctrl = wx.TextCtrl(parent, style=wx.TE_MULTILINE|wx.TE_READONLY) self.textctrl.WriteText(self.text) self._resize() box.Add(self.textctrl, flag=wx.LEFT, border=0) box.Layout()
python
def draw(self, parent, box): '''redraw the text''' import wx if self.textctrl is None: self.textctrl = wx.TextCtrl(parent, style=wx.TE_MULTILINE|wx.TE_READONLY) self.textctrl.WriteText(self.text) self._resize() box.Add(self.textctrl, flag=wx.LEFT, border=0) box.Layout()
[ "def", "draw", "(", "self", ",", "parent", ",", "box", ")", ":", "import", "wx", "if", "self", ".", "textctrl", "is", "None", ":", "self", ".", "textctrl", "=", "wx", ".", "TextCtrl", "(", "parent", ",", "style", "=", "wx", ".", "TE_MULTILINE", "|", "wx", ".", "TE_READONLY", ")", "self", ".", "textctrl", ".", "WriteText", "(", "self", ".", "text", ")", "self", ".", "_resize", "(", ")", "box", ".", "Add", "(", "self", ".", "textctrl", ",", "flag", "=", "wx", ".", "LEFT", ",", "border", "=", "0", ")", "box", ".", "Layout", "(", ")" ]
redraw the text
[ "redraw", "the", "text" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L502-L510
235,244
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py
App.button
def button(self, name, filename, command): '''add a button''' try: img = LoadImage(filename) b = Tkinter.Button(self.frame, image=img, command=command) b.image = img except Exception: b = Tkinter.Button(self.frame, text=filename, command=command) b.pack(side=Tkinter.LEFT) self.buttons[name] = b
python
def button(self, name, filename, command): '''add a button''' try: img = LoadImage(filename) b = Tkinter.Button(self.frame, image=img, command=command) b.image = img except Exception: b = Tkinter.Button(self.frame, text=filename, command=command) b.pack(side=Tkinter.LEFT) self.buttons[name] = b
[ "def", "button", "(", "self", ",", "name", ",", "filename", ",", "command", ")", ":", "try", ":", "img", "=", "LoadImage", "(", "filename", ")", "b", "=", "Tkinter", ".", "Button", "(", "self", ".", "frame", ",", "image", "=", "img", ",", "command", "=", "command", ")", "b", ".", "image", "=", "img", "except", "Exception", ":", "b", "=", "Tkinter", ".", "Button", "(", "self", ".", "frame", ",", "text", "=", "filename", ",", "command", "=", "command", ")", "b", ".", "pack", "(", "side", "=", "Tkinter", ".", "LEFT", ")", "self", ".", "buttons", "[", "name", "]", "=", "b" ]
add a button
[ "add", "a", "button" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py#L100-L109
235,245
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py
App.find_message
def find_message(self): '''find the next valid message''' while True: self.msg = self.mlog.recv_match(condition=args.condition) if self.msg is not None and self.msg.get_type() != 'BAD_DATA': break if self.mlog.f.tell() > self.filesize - 10: self.paused = True break self.last_timestamp = getattr(self.msg, '_timestamp')
python
def find_message(self): '''find the next valid message''' while True: self.msg = self.mlog.recv_match(condition=args.condition) if self.msg is not None and self.msg.get_type() != 'BAD_DATA': break if self.mlog.f.tell() > self.filesize - 10: self.paused = True break self.last_timestamp = getattr(self.msg, '_timestamp')
[ "def", "find_message", "(", "self", ")", ":", "while", "True", ":", "self", ".", "msg", "=", "self", ".", "mlog", ".", "recv_match", "(", "condition", "=", "args", ".", "condition", ")", "if", "self", ".", "msg", "is", "not", "None", "and", "self", ".", "msg", ".", "get_type", "(", ")", "!=", "'BAD_DATA'", ":", "break", "if", "self", ".", "mlog", ".", "f", ".", "tell", "(", ")", ">", "self", ".", "filesize", "-", "10", ":", "self", ".", "paused", "=", "True", "break", "self", ".", "last_timestamp", "=", "getattr", "(", "self", ".", "msg", ",", "'_timestamp'", ")" ]
find the next valid message
[ "find", "the", "next", "valid", "message" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py#L139-L148
235,246
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py
App.slew
def slew(self, value): '''move to a given position in the file''' if float(value) != self.filepos: pos = float(value) * self.filesize self.mlog.f.seek(int(pos)) self.find_message()
python
def slew(self, value): '''move to a given position in the file''' if float(value) != self.filepos: pos = float(value) * self.filesize self.mlog.f.seek(int(pos)) self.find_message()
[ "def", "slew", "(", "self", ",", "value", ")", ":", "if", "float", "(", "value", ")", "!=", "self", ".", "filepos", ":", "pos", "=", "float", "(", "value", ")", "*", "self", ".", "filesize", "self", ".", "mlog", ".", "f", ".", "seek", "(", "int", "(", "pos", ")", ")", "self", ".", "find_message", "(", ")" ]
move to a given position in the file
[ "move", "to", "a", "given", "position", "in", "the", "file" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py#L150-L155
235,247
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/live_graph_ui.py
GraphFrame.draw_plot
def draw_plot(self): """ Redraws the plot """ import numpy, pylab state = self.state if len(self.data[0]) == 0: print("no data to plot") return vhigh = max(self.data[0]) vlow = min(self.data[0]) for i in range(1,len(self.plot_data)): vhigh = max(vhigh, max(self.data[i])) vlow = min(vlow, min(self.data[i])) ymin = vlow - 0.05*(vhigh-vlow) ymax = vhigh + 0.05*(vhigh-vlow) if ymin == ymax: ymax = ymin + 0.1 ymin = ymin - 0.1 self.axes.set_ybound(lower=ymin, upper=ymax) self.axes.grid(True, color='gray') pylab.setp(self.axes.get_xticklabels(), visible=True) pylab.setp(self.axes.get_legend().get_texts(), fontsize='small') for i in range(len(self.plot_data)): ydata = numpy.array(self.data[i]) xdata = self.xdata if len(ydata) < len(self.xdata): xdata = xdata[-len(ydata):] self.plot_data[i].set_xdata(xdata) self.plot_data[i].set_ydata(ydata) self.canvas.draw()
python
def draw_plot(self): """ Redraws the plot """ import numpy, pylab state = self.state if len(self.data[0]) == 0: print("no data to plot") return vhigh = max(self.data[0]) vlow = min(self.data[0]) for i in range(1,len(self.plot_data)): vhigh = max(vhigh, max(self.data[i])) vlow = min(vlow, min(self.data[i])) ymin = vlow - 0.05*(vhigh-vlow) ymax = vhigh + 0.05*(vhigh-vlow) if ymin == ymax: ymax = ymin + 0.1 ymin = ymin - 0.1 self.axes.set_ybound(lower=ymin, upper=ymax) self.axes.grid(True, color='gray') pylab.setp(self.axes.get_xticklabels(), visible=True) pylab.setp(self.axes.get_legend().get_texts(), fontsize='small') for i in range(len(self.plot_data)): ydata = numpy.array(self.data[i]) xdata = self.xdata if len(ydata) < len(self.xdata): xdata = xdata[-len(ydata):] self.plot_data[i].set_xdata(xdata) self.plot_data[i].set_ydata(ydata) self.canvas.draw()
[ "def", "draw_plot", "(", "self", ")", ":", "import", "numpy", ",", "pylab", "state", "=", "self", ".", "state", "if", "len", "(", "self", ".", "data", "[", "0", "]", ")", "==", "0", ":", "print", "(", "\"no data to plot\"", ")", "return", "vhigh", "=", "max", "(", "self", ".", "data", "[", "0", "]", ")", "vlow", "=", "min", "(", "self", ".", "data", "[", "0", "]", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "plot_data", ")", ")", ":", "vhigh", "=", "max", "(", "vhigh", ",", "max", "(", "self", ".", "data", "[", "i", "]", ")", ")", "vlow", "=", "min", "(", "vlow", ",", "min", "(", "self", ".", "data", "[", "i", "]", ")", ")", "ymin", "=", "vlow", "-", "0.05", "*", "(", "vhigh", "-", "vlow", ")", "ymax", "=", "vhigh", "+", "0.05", "*", "(", "vhigh", "-", "vlow", ")", "if", "ymin", "==", "ymax", ":", "ymax", "=", "ymin", "+", "0.1", "ymin", "=", "ymin", "-", "0.1", "self", ".", "axes", ".", "set_ybound", "(", "lower", "=", "ymin", ",", "upper", "=", "ymax", ")", "self", ".", "axes", ".", "grid", "(", "True", ",", "color", "=", "'gray'", ")", "pylab", ".", "setp", "(", "self", ".", "axes", ".", "get_xticklabels", "(", ")", ",", "visible", "=", "True", ")", "pylab", ".", "setp", "(", "self", ".", "axes", ".", "get_legend", "(", ")", ".", "get_texts", "(", ")", ",", "fontsize", "=", "'small'", ")", "for", "i", "in", "range", "(", "len", "(", "self", ".", "plot_data", ")", ")", ":", "ydata", "=", "numpy", ".", "array", "(", "self", ".", "data", "[", "i", "]", ")", "xdata", "=", "self", ".", "xdata", "if", "len", "(", "ydata", ")", "<", "len", "(", "self", ".", "xdata", ")", ":", "xdata", "=", "xdata", "[", "-", "len", "(", "ydata", ")", ":", "]", "self", ".", "plot_data", "[", "i", "]", ".", "set_xdata", "(", "xdata", ")", "self", ".", "plot_data", "[", "i", "]", ".", "set_ydata", "(", "ydata", ")", "self", ".", "canvas", ".", "draw", "(", ")" ]
Redraws the plot
[ "Redraws", "the", "plot" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/live_graph_ui.py#L90-L124
235,248
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
set_close_on_exec
def set_close_on_exec(fd): '''set the clone on exec flag on a file descriptor. Ignore exceptions''' try: import fcntl flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags |= fcntl.FD_CLOEXEC fcntl.fcntl(fd, fcntl.F_SETFD, flags) except Exception: pass
python
def set_close_on_exec(fd): '''set the clone on exec flag on a file descriptor. Ignore exceptions''' try: import fcntl flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags |= fcntl.FD_CLOEXEC fcntl.fcntl(fd, fcntl.F_SETFD, flags) except Exception: pass
[ "def", "set_close_on_exec", "(", "fd", ")", ":", "try", ":", "import", "fcntl", "flags", "=", "fcntl", ".", "fcntl", "(", "fd", ",", "fcntl", ".", "F_GETFD", ")", "flags", "|=", "fcntl", ".", "FD_CLOEXEC", "fcntl", ".", "fcntl", "(", "fd", ",", "fcntl", ".", "F_SETFD", ",", "flags", ")", "except", "Exception", ":", "pass" ]
set the clone on exec flag on a file descriptor. Ignore exceptions
[ "set", "the", "clone", "on", "exec", "flag", "on", "a", "file", "descriptor", ".", "Ignore", "exceptions" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L768-L776
235,249
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavlink_connection
def mavlink_connection(device, baud=115200, source_system=255, planner_format=None, write=False, append=False, robust_parsing=True, notimestamps=False, input=True, dialect=None, autoreconnect=False, zero_time_base=False, retries=3, use_native=default_native): '''open a serial, UDP, TCP or file mavlink connection''' global mavfile_global if dialect is not None: set_dialect(dialect) if device.startswith('tcp:'): return mavtcp(device[4:], source_system=source_system, retries=retries, use_native=use_native) if device.startswith('tcpin:'): return mavtcpin(device[6:], source_system=source_system, retries=retries, use_native=use_native) if device.startswith('udpin:'): return mavudp(device[6:], input=True, source_system=source_system, use_native=use_native) if device.startswith('udpout:'): return mavudp(device[7:], input=False, source_system=source_system, use_native=use_native) if device.startswith('udpbcast:'): return mavudp(device[9:], input=False, source_system=source_system, use_native=use_native, broadcast=True) # For legacy purposes we accept the following syntax and let the caller to specify direction if device.startswith('udp:'): return mavudp(device[4:], input=input, source_system=source_system, use_native=use_native) if device.lower().endswith('.bin') or device.lower().endswith('.px4log'): # support dataflash logs from pymavlink import DFReader m = DFReader.DFReader_binary(device, zero_time_base=zero_time_base) mavfile_global = m return m if device.endswith('.log'): # support dataflash text logs from pymavlink import DFReader if DFReader.DFReader_is_text_log(device): m = DFReader.DFReader_text(device, zero_time_base=zero_time_base) mavfile_global = m return m # list of suffixes to prevent setting DOS paths as UDP sockets logsuffixes = ['mavlink', 'log', 'raw', 'tlog' ] suffix = device.split('.')[-1].lower() if device.find(':') != -1 and not suffix in logsuffixes: return mavudp(device, source_system=source_system, input=input, use_native=use_native) if os.path.isfile(device): if device.endswith(".elf") or device.find("/bin/") != -1: print("executing '%s'" % device) return mavchildexec(device, source_system=source_system, use_native=use_native) else: return mavlogfile(device, planner_format=planner_format, write=write, append=append, robust_parsing=robust_parsing, notimestamps=notimestamps, source_system=source_system, use_native=use_native) return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native)
python
def mavlink_connection(device, baud=115200, source_system=255, planner_format=None, write=False, append=False, robust_parsing=True, notimestamps=False, input=True, dialect=None, autoreconnect=False, zero_time_base=False, retries=3, use_native=default_native): '''open a serial, UDP, TCP or file mavlink connection''' global mavfile_global if dialect is not None: set_dialect(dialect) if device.startswith('tcp:'): return mavtcp(device[4:], source_system=source_system, retries=retries, use_native=use_native) if device.startswith('tcpin:'): return mavtcpin(device[6:], source_system=source_system, retries=retries, use_native=use_native) if device.startswith('udpin:'): return mavudp(device[6:], input=True, source_system=source_system, use_native=use_native) if device.startswith('udpout:'): return mavudp(device[7:], input=False, source_system=source_system, use_native=use_native) if device.startswith('udpbcast:'): return mavudp(device[9:], input=False, source_system=source_system, use_native=use_native, broadcast=True) # For legacy purposes we accept the following syntax and let the caller to specify direction if device.startswith('udp:'): return mavudp(device[4:], input=input, source_system=source_system, use_native=use_native) if device.lower().endswith('.bin') or device.lower().endswith('.px4log'): # support dataflash logs from pymavlink import DFReader m = DFReader.DFReader_binary(device, zero_time_base=zero_time_base) mavfile_global = m return m if device.endswith('.log'): # support dataflash text logs from pymavlink import DFReader if DFReader.DFReader_is_text_log(device): m = DFReader.DFReader_text(device, zero_time_base=zero_time_base) mavfile_global = m return m # list of suffixes to prevent setting DOS paths as UDP sockets logsuffixes = ['mavlink', 'log', 'raw', 'tlog' ] suffix = device.split('.')[-1].lower() if device.find(':') != -1 and not suffix in logsuffixes: return mavudp(device, source_system=source_system, input=input, use_native=use_native) if os.path.isfile(device): if device.endswith(".elf") or device.find("/bin/") != -1: print("executing '%s'" % device) return mavchildexec(device, source_system=source_system, use_native=use_native) else: return mavlogfile(device, planner_format=planner_format, write=write, append=append, robust_parsing=robust_parsing, notimestamps=notimestamps, source_system=source_system, use_native=use_native) return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native)
[ "def", "mavlink_connection", "(", "device", ",", "baud", "=", "115200", ",", "source_system", "=", "255", ",", "planner_format", "=", "None", ",", "write", "=", "False", ",", "append", "=", "False", ",", "robust_parsing", "=", "True", ",", "notimestamps", "=", "False", ",", "input", "=", "True", ",", "dialect", "=", "None", ",", "autoreconnect", "=", "False", ",", "zero_time_base", "=", "False", ",", "retries", "=", "3", ",", "use_native", "=", "default_native", ")", ":", "global", "mavfile_global", "if", "dialect", "is", "not", "None", ":", "set_dialect", "(", "dialect", ")", "if", "device", ".", "startswith", "(", "'tcp:'", ")", ":", "return", "mavtcp", "(", "device", "[", "4", ":", "]", ",", "source_system", "=", "source_system", ",", "retries", "=", "retries", ",", "use_native", "=", "use_native", ")", "if", "device", ".", "startswith", "(", "'tcpin:'", ")", ":", "return", "mavtcpin", "(", "device", "[", "6", ":", "]", ",", "source_system", "=", "source_system", ",", "retries", "=", "retries", ",", "use_native", "=", "use_native", ")", "if", "device", ".", "startswith", "(", "'udpin:'", ")", ":", "return", "mavudp", "(", "device", "[", "6", ":", "]", ",", "input", "=", "True", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ")", "if", "device", ".", "startswith", "(", "'udpout:'", ")", ":", "return", "mavudp", "(", "device", "[", "7", ":", "]", ",", "input", "=", "False", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ")", "if", "device", ".", "startswith", "(", "'udpbcast:'", ")", ":", "return", "mavudp", "(", "device", "[", "9", ":", "]", ",", "input", "=", "False", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ",", "broadcast", "=", "True", ")", "# For legacy purposes we accept the following syntax and let the caller to specify direction", "if", "device", ".", "startswith", "(", "'udp:'", ")", ":", "return", "mavudp", "(", "device", "[", "4", ":", "]", ",", "input", "=", "input", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ")", "if", "device", ".", "lower", "(", ")", ".", "endswith", "(", "'.bin'", ")", "or", "device", ".", "lower", "(", ")", ".", "endswith", "(", "'.px4log'", ")", ":", "# support dataflash logs", "from", "pymavlink", "import", "DFReader", "m", "=", "DFReader", ".", "DFReader_binary", "(", "device", ",", "zero_time_base", "=", "zero_time_base", ")", "mavfile_global", "=", "m", "return", "m", "if", "device", ".", "endswith", "(", "'.log'", ")", ":", "# support dataflash text logs", "from", "pymavlink", "import", "DFReader", "if", "DFReader", ".", "DFReader_is_text_log", "(", "device", ")", ":", "m", "=", "DFReader", ".", "DFReader_text", "(", "device", ",", "zero_time_base", "=", "zero_time_base", ")", "mavfile_global", "=", "m", "return", "m", "# list of suffixes to prevent setting DOS paths as UDP sockets", "logsuffixes", "=", "[", "'mavlink'", ",", "'log'", ",", "'raw'", ",", "'tlog'", "]", "suffix", "=", "device", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", ".", "lower", "(", ")", "if", "device", ".", "find", "(", "':'", ")", "!=", "-", "1", "and", "not", "suffix", "in", "logsuffixes", ":", "return", "mavudp", "(", "device", ",", "source_system", "=", "source_system", ",", "input", "=", "input", ",", "use_native", "=", "use_native", ")", "if", "os", ".", "path", ".", "isfile", "(", "device", ")", ":", "if", "device", ".", "endswith", "(", "\".elf\"", ")", "or", "device", ".", "find", "(", "\"/bin/\"", ")", "!=", "-", "1", ":", "print", "(", "\"executing '%s'\"", "%", "device", ")", "return", "mavchildexec", "(", "device", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ")", "else", ":", "return", "mavlogfile", "(", "device", ",", "planner_format", "=", "planner_format", ",", "write", "=", "write", ",", "append", "=", "append", ",", "robust_parsing", "=", "robust_parsing", ",", "notimestamps", "=", "notimestamps", ",", "source_system", "=", "source_system", ",", "use_native", "=", "use_native", ")", "return", "mavserial", "(", "device", ",", "baud", "=", "baud", ",", "source_system", "=", "source_system", ",", "autoreconnect", "=", "autoreconnect", ",", "use_native", "=", "use_native", ")" ]
open a serial, UDP, TCP or file mavlink connection
[ "open", "a", "serial", "UDP", "TCP", "or", "file", "mavlink", "connection" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1192-L1244
235,250
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
is_printable
def is_printable(c): '''see if a character is printable''' global have_ascii if have_ascii: return ascii.isprint(c) if isinstance(c, int): ic = c else: ic = ord(c) return ic >= 32 and ic <= 126
python
def is_printable(c): '''see if a character is printable''' global have_ascii if have_ascii: return ascii.isprint(c) if isinstance(c, int): ic = c else: ic = ord(c) return ic >= 32 and ic <= 126
[ "def", "is_printable", "(", "c", ")", ":", "global", "have_ascii", "if", "have_ascii", ":", "return", "ascii", ".", "isprint", "(", "c", ")", "if", "isinstance", "(", "c", ",", "int", ")", ":", "ic", "=", "c", "else", ":", "ic", "=", "ord", "(", "c", ")", "return", "ic", ">=", "32", "and", "ic", "<=", "126" ]
see if a character is printable
[ "see", "if", "a", "character", "is", "printable" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1276-L1285
235,251
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
auto_detect_serial_win32
def auto_detect_serial_win32(preferred_list=['*']): '''try to auto-detect serial ports on win32''' try: from serial.tools.list_ports_windows import comports list = sorted(comports()) except: return [] ret = [] others = [] for port, description, hwid in list: matches = False p = SerialPort(port, description=description, hwid=hwid) for preferred in preferred_list: if fnmatch.fnmatch(description, preferred) or fnmatch.fnmatch(hwid, preferred): matches = True if matches: ret.append(p) else: others.append(p) if len(ret) > 0: return ret # now the rest ret.extend(others) return ret
python
def auto_detect_serial_win32(preferred_list=['*']): '''try to auto-detect serial ports on win32''' try: from serial.tools.list_ports_windows import comports list = sorted(comports()) except: return [] ret = [] others = [] for port, description, hwid in list: matches = False p = SerialPort(port, description=description, hwid=hwid) for preferred in preferred_list: if fnmatch.fnmatch(description, preferred) or fnmatch.fnmatch(hwid, preferred): matches = True if matches: ret.append(p) else: others.append(p) if len(ret) > 0: return ret # now the rest ret.extend(others) return ret
[ "def", "auto_detect_serial_win32", "(", "preferred_list", "=", "[", "'*'", "]", ")", ":", "try", ":", "from", "serial", ".", "tools", ".", "list_ports_windows", "import", "comports", "list", "=", "sorted", "(", "comports", "(", ")", ")", "except", ":", "return", "[", "]", "ret", "=", "[", "]", "others", "=", "[", "]", "for", "port", ",", "description", ",", "hwid", "in", "list", ":", "matches", "=", "False", "p", "=", "SerialPort", "(", "port", ",", "description", "=", "description", ",", "hwid", "=", "hwid", ")", "for", "preferred", "in", "preferred_list", ":", "if", "fnmatch", ".", "fnmatch", "(", "description", ",", "preferred", ")", "or", "fnmatch", ".", "fnmatch", "(", "hwid", ",", "preferred", ")", ":", "matches", "=", "True", "if", "matches", ":", "ret", ".", "append", "(", "p", ")", "else", ":", "others", ".", "append", "(", "p", ")", "if", "len", "(", "ret", ")", ">", "0", ":", "return", "ret", "# now the rest", "ret", ".", "extend", "(", "others", ")", "return", "ret" ]
try to auto-detect serial ports on win32
[ "try", "to", "auto", "-", "detect", "serial", "ports", "on", "win32" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1309-L1332
235,252
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
auto_detect_serial_unix
def auto_detect_serial_unix(preferred_list=['*']): '''try to auto-detect serial ports on unix''' import glob glist = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob('/dev/serial/by-id/*') ret = [] others = [] # try preferred ones first for d in glist: matches = False for preferred in preferred_list: if fnmatch.fnmatch(d, preferred): matches = True if matches: ret.append(SerialPort(d)) else: others.append(SerialPort(d)) if len(ret) > 0: return ret ret.extend(others) return ret
python
def auto_detect_serial_unix(preferred_list=['*']): '''try to auto-detect serial ports on unix''' import glob glist = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob('/dev/serial/by-id/*') ret = [] others = [] # try preferred ones first for d in glist: matches = False for preferred in preferred_list: if fnmatch.fnmatch(d, preferred): matches = True if matches: ret.append(SerialPort(d)) else: others.append(SerialPort(d)) if len(ret) > 0: return ret ret.extend(others) return ret
[ "def", "auto_detect_serial_unix", "(", "preferred_list", "=", "[", "'*'", "]", ")", ":", "import", "glob", "glist", "=", "glob", ".", "glob", "(", "'/dev/ttyS*'", ")", "+", "glob", ".", "glob", "(", "'/dev/ttyUSB*'", ")", "+", "glob", ".", "glob", "(", "'/dev/ttyACM*'", ")", "+", "glob", ".", "glob", "(", "'/dev/serial/by-id/*'", ")", "ret", "=", "[", "]", "others", "=", "[", "]", "# try preferred ones first", "for", "d", "in", "glist", ":", "matches", "=", "False", "for", "preferred", "in", "preferred_list", ":", "if", "fnmatch", ".", "fnmatch", "(", "d", ",", "preferred", ")", ":", "matches", "=", "True", "if", "matches", ":", "ret", ".", "append", "(", "SerialPort", "(", "d", ")", ")", "else", ":", "others", ".", "append", "(", "SerialPort", "(", "d", ")", ")", "if", "len", "(", "ret", ")", ">", "0", ":", "return", "ret", "ret", ".", "extend", "(", "others", ")", "return", "ret" ]
try to auto-detect serial ports on unix
[ "try", "to", "auto", "-", "detect", "serial", "ports", "on", "unix" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1337-L1356
235,253
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
auto_detect_serial
def auto_detect_serial(preferred_list=['*']): '''try to auto-detect serial port''' # see if if os.name == 'nt': return auto_detect_serial_win32(preferred_list=preferred_list) return auto_detect_serial_unix(preferred_list=preferred_list)
python
def auto_detect_serial(preferred_list=['*']): '''try to auto-detect serial port''' # see if if os.name == 'nt': return auto_detect_serial_win32(preferred_list=preferred_list) return auto_detect_serial_unix(preferred_list=preferred_list)
[ "def", "auto_detect_serial", "(", "preferred_list", "=", "[", "'*'", "]", ")", ":", "# see if ", "if", "os", ".", "name", "==", "'nt'", ":", "return", "auto_detect_serial_win32", "(", "preferred_list", "=", "preferred_list", ")", "return", "auto_detect_serial_unix", "(", "preferred_list", "=", "preferred_list", ")" ]
try to auto-detect serial port
[ "try", "to", "auto", "-", "detect", "serial", "port" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1358-L1363
235,254
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mode_string_v09
def mode_string_v09(msg): '''mode string for 0.9 protocol''' mode = msg.mode nav_mode = msg.nav_mode MAV_MODE_UNINIT = 0 MAV_MODE_MANUAL = 2 MAV_MODE_GUIDED = 3 MAV_MODE_AUTO = 4 MAV_MODE_TEST1 = 5 MAV_MODE_TEST2 = 6 MAV_MODE_TEST3 = 7 MAV_NAV_GROUNDED = 0 MAV_NAV_LIFTOFF = 1 MAV_NAV_HOLD = 2 MAV_NAV_WAYPOINT = 3 MAV_NAV_VECTOR = 4 MAV_NAV_RETURNING = 5 MAV_NAV_LANDING = 6 MAV_NAV_LOST = 7 MAV_NAV_LOITER = 8 cmode = (mode, nav_mode) mapping = { (MAV_MODE_UNINIT, MAV_NAV_GROUNDED) : "INITIALISING", (MAV_MODE_MANUAL, MAV_NAV_VECTOR) : "MANUAL", (MAV_MODE_TEST3, MAV_NAV_VECTOR) : "CIRCLE", (MAV_MODE_GUIDED, MAV_NAV_VECTOR) : "GUIDED", (MAV_MODE_TEST1, MAV_NAV_VECTOR) : "STABILIZE", (MAV_MODE_TEST2, MAV_NAV_LIFTOFF) : "FBWA", (MAV_MODE_AUTO, MAV_NAV_WAYPOINT) : "AUTO", (MAV_MODE_AUTO, MAV_NAV_RETURNING) : "RTL", (MAV_MODE_AUTO, MAV_NAV_LOITER) : "LOITER", (MAV_MODE_AUTO, MAV_NAV_LIFTOFF) : "TAKEOFF", (MAV_MODE_AUTO, MAV_NAV_LANDING) : "LANDING", (MAV_MODE_AUTO, MAV_NAV_HOLD) : "LOITER", (MAV_MODE_GUIDED, MAV_NAV_VECTOR) : "GUIDED", (MAV_MODE_GUIDED, MAV_NAV_WAYPOINT) : "GUIDED", (100, MAV_NAV_VECTOR) : "STABILIZE", (101, MAV_NAV_VECTOR) : "ACRO", (102, MAV_NAV_VECTOR) : "ALT_HOLD", (107, MAV_NAV_VECTOR) : "CIRCLE", (109, MAV_NAV_VECTOR) : "LAND", } if cmode in mapping: return mapping[cmode] return "Mode(%s,%s)" % cmode
python
def mode_string_v09(msg): '''mode string for 0.9 protocol''' mode = msg.mode nav_mode = msg.nav_mode MAV_MODE_UNINIT = 0 MAV_MODE_MANUAL = 2 MAV_MODE_GUIDED = 3 MAV_MODE_AUTO = 4 MAV_MODE_TEST1 = 5 MAV_MODE_TEST2 = 6 MAV_MODE_TEST3 = 7 MAV_NAV_GROUNDED = 0 MAV_NAV_LIFTOFF = 1 MAV_NAV_HOLD = 2 MAV_NAV_WAYPOINT = 3 MAV_NAV_VECTOR = 4 MAV_NAV_RETURNING = 5 MAV_NAV_LANDING = 6 MAV_NAV_LOST = 7 MAV_NAV_LOITER = 8 cmode = (mode, nav_mode) mapping = { (MAV_MODE_UNINIT, MAV_NAV_GROUNDED) : "INITIALISING", (MAV_MODE_MANUAL, MAV_NAV_VECTOR) : "MANUAL", (MAV_MODE_TEST3, MAV_NAV_VECTOR) : "CIRCLE", (MAV_MODE_GUIDED, MAV_NAV_VECTOR) : "GUIDED", (MAV_MODE_TEST1, MAV_NAV_VECTOR) : "STABILIZE", (MAV_MODE_TEST2, MAV_NAV_LIFTOFF) : "FBWA", (MAV_MODE_AUTO, MAV_NAV_WAYPOINT) : "AUTO", (MAV_MODE_AUTO, MAV_NAV_RETURNING) : "RTL", (MAV_MODE_AUTO, MAV_NAV_LOITER) : "LOITER", (MAV_MODE_AUTO, MAV_NAV_LIFTOFF) : "TAKEOFF", (MAV_MODE_AUTO, MAV_NAV_LANDING) : "LANDING", (MAV_MODE_AUTO, MAV_NAV_HOLD) : "LOITER", (MAV_MODE_GUIDED, MAV_NAV_VECTOR) : "GUIDED", (MAV_MODE_GUIDED, MAV_NAV_WAYPOINT) : "GUIDED", (100, MAV_NAV_VECTOR) : "STABILIZE", (101, MAV_NAV_VECTOR) : "ACRO", (102, MAV_NAV_VECTOR) : "ALT_HOLD", (107, MAV_NAV_VECTOR) : "CIRCLE", (109, MAV_NAV_VECTOR) : "LAND", } if cmode in mapping: return mapping[cmode] return "Mode(%s,%s)" % cmode
[ "def", "mode_string_v09", "(", "msg", ")", ":", "mode", "=", "msg", ".", "mode", "nav_mode", "=", "msg", ".", "nav_mode", "MAV_MODE_UNINIT", "=", "0", "MAV_MODE_MANUAL", "=", "2", "MAV_MODE_GUIDED", "=", "3", "MAV_MODE_AUTO", "=", "4", "MAV_MODE_TEST1", "=", "5", "MAV_MODE_TEST2", "=", "6", "MAV_MODE_TEST3", "=", "7", "MAV_NAV_GROUNDED", "=", "0", "MAV_NAV_LIFTOFF", "=", "1", "MAV_NAV_HOLD", "=", "2", "MAV_NAV_WAYPOINT", "=", "3", "MAV_NAV_VECTOR", "=", "4", "MAV_NAV_RETURNING", "=", "5", "MAV_NAV_LANDING", "=", "6", "MAV_NAV_LOST", "=", "7", "MAV_NAV_LOITER", "=", "8", "cmode", "=", "(", "mode", ",", "nav_mode", ")", "mapping", "=", "{", "(", "MAV_MODE_UNINIT", ",", "MAV_NAV_GROUNDED", ")", ":", "\"INITIALISING\"", ",", "(", "MAV_MODE_MANUAL", ",", "MAV_NAV_VECTOR", ")", ":", "\"MANUAL\"", ",", "(", "MAV_MODE_TEST3", ",", "MAV_NAV_VECTOR", ")", ":", "\"CIRCLE\"", ",", "(", "MAV_MODE_GUIDED", ",", "MAV_NAV_VECTOR", ")", ":", "\"GUIDED\"", ",", "(", "MAV_MODE_TEST1", ",", "MAV_NAV_VECTOR", ")", ":", "\"STABILIZE\"", ",", "(", "MAV_MODE_TEST2", ",", "MAV_NAV_LIFTOFF", ")", ":", "\"FBWA\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_WAYPOINT", ")", ":", "\"AUTO\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_RETURNING", ")", ":", "\"RTL\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_LOITER", ")", ":", "\"LOITER\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_LIFTOFF", ")", ":", "\"TAKEOFF\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_LANDING", ")", ":", "\"LANDING\"", ",", "(", "MAV_MODE_AUTO", ",", "MAV_NAV_HOLD", ")", ":", "\"LOITER\"", ",", "(", "MAV_MODE_GUIDED", ",", "MAV_NAV_VECTOR", ")", ":", "\"GUIDED\"", ",", "(", "MAV_MODE_GUIDED", ",", "MAV_NAV_WAYPOINT", ")", ":", "\"GUIDED\"", ",", "(", "100", ",", "MAV_NAV_VECTOR", ")", ":", "\"STABILIZE\"", ",", "(", "101", ",", "MAV_NAV_VECTOR", ")", ":", "\"ACRO\"", ",", "(", "102", ",", "MAV_NAV_VECTOR", ")", ":", "\"ALT_HOLD\"", ",", "(", "107", ",", "MAV_NAV_VECTOR", ")", ":", "\"CIRCLE\"", ",", "(", "109", ",", "MAV_NAV_VECTOR", ")", ":", "\"LAND\"", ",", "}", "if", "cmode", "in", "mapping", ":", "return", "mapping", "[", "cmode", "]", "return", "\"Mode(%s,%s)\"", "%", "cmode" ]
mode string for 0.9 protocol
[ "mode", "string", "for", "0", ".", "9", "protocol" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1365-L1412
235,255
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mode_mapping_bynumber
def mode_mapping_bynumber(mav_type): '''return dictionary mapping mode numbers to name, or None if unknown''' map = None if mav_type in [mavlink.MAV_TYPE_QUADROTOR, mavlink.MAV_TYPE_HELICOPTER, mavlink.MAV_TYPE_HEXAROTOR, mavlink.MAV_TYPE_OCTOROTOR, mavlink.MAV_TYPE_COAXIAL, mavlink.MAV_TYPE_TRICOPTER]: map = mode_mapping_acm if mav_type == mavlink.MAV_TYPE_FIXED_WING: map = mode_mapping_apm if mav_type == mavlink.MAV_TYPE_GROUND_ROVER: map = mode_mapping_rover if mav_type == mavlink.MAV_TYPE_ANTENNA_TRACKER: map = mode_mapping_tracker if map is None: return None return map
python
def mode_mapping_bynumber(mav_type): '''return dictionary mapping mode numbers to name, or None if unknown''' map = None if mav_type in [mavlink.MAV_TYPE_QUADROTOR, mavlink.MAV_TYPE_HELICOPTER, mavlink.MAV_TYPE_HEXAROTOR, mavlink.MAV_TYPE_OCTOROTOR, mavlink.MAV_TYPE_COAXIAL, mavlink.MAV_TYPE_TRICOPTER]: map = mode_mapping_acm if mav_type == mavlink.MAV_TYPE_FIXED_WING: map = mode_mapping_apm if mav_type == mavlink.MAV_TYPE_GROUND_ROVER: map = mode_mapping_rover if mav_type == mavlink.MAV_TYPE_ANTENNA_TRACKER: map = mode_mapping_tracker if map is None: return None return map
[ "def", "mode_mapping_bynumber", "(", "mav_type", ")", ":", "map", "=", "None", "if", "mav_type", "in", "[", "mavlink", ".", "MAV_TYPE_QUADROTOR", ",", "mavlink", ".", "MAV_TYPE_HELICOPTER", ",", "mavlink", ".", "MAV_TYPE_HEXAROTOR", ",", "mavlink", ".", "MAV_TYPE_OCTOROTOR", ",", "mavlink", ".", "MAV_TYPE_COAXIAL", ",", "mavlink", ".", "MAV_TYPE_TRICOPTER", "]", ":", "map", "=", "mode_mapping_acm", "if", "mav_type", "==", "mavlink", ".", "MAV_TYPE_FIXED_WING", ":", "map", "=", "mode_mapping_apm", "if", "mav_type", "==", "mavlink", ".", "MAV_TYPE_GROUND_ROVER", ":", "map", "=", "mode_mapping_rover", "if", "mav_type", "==", "mavlink", ".", "MAV_TYPE_ANTENNA_TRACKER", ":", "map", "=", "mode_mapping_tracker", "if", "map", "is", "None", ":", "return", "None", "return", "map" ]
return dictionary mapping mode numbers to name, or None if unknown
[ "return", "dictionary", "mapping", "mode", "numbers", "to", "name", "or", "None", "if", "unknown" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1595-L1613
235,256
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mode_string_v10
def mode_string_v10(msg): '''mode string for 1.0 protocol, from heartbeat''' if msg.autopilot == mavlink.MAV_AUTOPILOT_PX4: return interpret_px4_mode(msg.base_mode, msg.custom_mode) if not msg.base_mode & mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED: return "Mode(0x%08x)" % msg.base_mode if msg.type in [ mavlink.MAV_TYPE_QUADROTOR, mavlink.MAV_TYPE_HEXAROTOR, mavlink.MAV_TYPE_OCTOROTOR, mavlink.MAV_TYPE_TRICOPTER, mavlink.MAV_TYPE_COAXIAL, mavlink.MAV_TYPE_HELICOPTER ]: if msg.custom_mode in mode_mapping_acm: return mode_mapping_acm[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_FIXED_WING: if msg.custom_mode in mode_mapping_apm: return mode_mapping_apm[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_GROUND_ROVER: if msg.custom_mode in mode_mapping_rover: return mode_mapping_rover[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_ANTENNA_TRACKER: if msg.custom_mode in mode_mapping_tracker: return mode_mapping_tracker[msg.custom_mode] return "Mode(%u)" % msg.custom_mode
python
def mode_string_v10(msg): '''mode string for 1.0 protocol, from heartbeat''' if msg.autopilot == mavlink.MAV_AUTOPILOT_PX4: return interpret_px4_mode(msg.base_mode, msg.custom_mode) if not msg.base_mode & mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED: return "Mode(0x%08x)" % msg.base_mode if msg.type in [ mavlink.MAV_TYPE_QUADROTOR, mavlink.MAV_TYPE_HEXAROTOR, mavlink.MAV_TYPE_OCTOROTOR, mavlink.MAV_TYPE_TRICOPTER, mavlink.MAV_TYPE_COAXIAL, mavlink.MAV_TYPE_HELICOPTER ]: if msg.custom_mode in mode_mapping_acm: return mode_mapping_acm[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_FIXED_WING: if msg.custom_mode in mode_mapping_apm: return mode_mapping_apm[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_GROUND_ROVER: if msg.custom_mode in mode_mapping_rover: return mode_mapping_rover[msg.custom_mode] if msg.type == mavlink.MAV_TYPE_ANTENNA_TRACKER: if msg.custom_mode in mode_mapping_tracker: return mode_mapping_tracker[msg.custom_mode] return "Mode(%u)" % msg.custom_mode
[ "def", "mode_string_v10", "(", "msg", ")", ":", "if", "msg", ".", "autopilot", "==", "mavlink", ".", "MAV_AUTOPILOT_PX4", ":", "return", "interpret_px4_mode", "(", "msg", ".", "base_mode", ",", "msg", ".", "custom_mode", ")", "if", "not", "msg", ".", "base_mode", "&", "mavlink", ".", "MAV_MODE_FLAG_CUSTOM_MODE_ENABLED", ":", "return", "\"Mode(0x%08x)\"", "%", "msg", ".", "base_mode", "if", "msg", ".", "type", "in", "[", "mavlink", ".", "MAV_TYPE_QUADROTOR", ",", "mavlink", ".", "MAV_TYPE_HEXAROTOR", ",", "mavlink", ".", "MAV_TYPE_OCTOROTOR", ",", "mavlink", ".", "MAV_TYPE_TRICOPTER", ",", "mavlink", ".", "MAV_TYPE_COAXIAL", ",", "mavlink", ".", "MAV_TYPE_HELICOPTER", "]", ":", "if", "msg", ".", "custom_mode", "in", "mode_mapping_acm", ":", "return", "mode_mapping_acm", "[", "msg", ".", "custom_mode", "]", "if", "msg", ".", "type", "==", "mavlink", ".", "MAV_TYPE_FIXED_WING", ":", "if", "msg", ".", "custom_mode", "in", "mode_mapping_apm", ":", "return", "mode_mapping_apm", "[", "msg", ".", "custom_mode", "]", "if", "msg", ".", "type", "==", "mavlink", ".", "MAV_TYPE_GROUND_ROVER", ":", "if", "msg", ".", "custom_mode", "in", "mode_mapping_rover", ":", "return", "mode_mapping_rover", "[", "msg", ".", "custom_mode", "]", "if", "msg", ".", "type", "==", "mavlink", ".", "MAV_TYPE_ANTENNA_TRACKER", ":", "if", "msg", ".", "custom_mode", "in", "mode_mapping_tracker", ":", "return", "mode_mapping_tracker", "[", "msg", ".", "custom_mode", "]", "return", "\"Mode(%u)\"", "%", "msg", ".", "custom_mode" ]
mode string for 1.0 protocol, from heartbeat
[ "mode", "string", "for", "1", ".", "0", "protocol", "from", "heartbeat" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1616-L1637
235,257
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.auto_mavlink_version
def auto_mavlink_version(self, buf): '''auto-switch mavlink protocol version''' global mavlink if len(buf) == 0: return try: magic = ord(buf[0]) except: magic = buf[0] if not magic in [ 85, 254, 253 ]: return self.first_byte = False if self.WIRE_PROTOCOL_VERSION == "0.9" and magic == 254: self.WIRE_PROTOCOL_VERSION = "1.0" set_dialect(current_dialect) elif self.WIRE_PROTOCOL_VERSION == "1.0" and magic == 85: self.WIRE_PROTOCOL_VERSION = "0.9" os.environ['MAVLINK09'] = '1' set_dialect(current_dialect) elif self.WIRE_PROTOCOL_VERSION != "2.0" and magic == 253: self.WIRE_PROTOCOL_VERSION = "2.0" os.environ['MAVLINK20'] = '1' set_dialect(current_dialect) else: return # switch protocol (callback, callback_args, callback_kwargs) = (self.mav.callback, self.mav.callback_args, self.mav.callback_kwargs) self.mav = mavlink.MAVLink(self, srcSystem=self.source_system) self.mav.robust_parsing = self.robust_parsing self.WIRE_PROTOCOL_VERSION = mavlink.WIRE_PROTOCOL_VERSION (self.mav.callback, self.mav.callback_args, self.mav.callback_kwargs) = (callback, callback_args, callback_kwargs)
python
def auto_mavlink_version(self, buf): '''auto-switch mavlink protocol version''' global mavlink if len(buf) == 0: return try: magic = ord(buf[0]) except: magic = buf[0] if not magic in [ 85, 254, 253 ]: return self.first_byte = False if self.WIRE_PROTOCOL_VERSION == "0.9" and magic == 254: self.WIRE_PROTOCOL_VERSION = "1.0" set_dialect(current_dialect) elif self.WIRE_PROTOCOL_VERSION == "1.0" and magic == 85: self.WIRE_PROTOCOL_VERSION = "0.9" os.environ['MAVLINK09'] = '1' set_dialect(current_dialect) elif self.WIRE_PROTOCOL_VERSION != "2.0" and magic == 253: self.WIRE_PROTOCOL_VERSION = "2.0" os.environ['MAVLINK20'] = '1' set_dialect(current_dialect) else: return # switch protocol (callback, callback_args, callback_kwargs) = (self.mav.callback, self.mav.callback_args, self.mav.callback_kwargs) self.mav = mavlink.MAVLink(self, srcSystem=self.source_system) self.mav.robust_parsing = self.robust_parsing self.WIRE_PROTOCOL_VERSION = mavlink.WIRE_PROTOCOL_VERSION (self.mav.callback, self.mav.callback_args, self.mav.callback_kwargs) = (callback, callback_args, callback_kwargs)
[ "def", "auto_mavlink_version", "(", "self", ",", "buf", ")", ":", "global", "mavlink", "if", "len", "(", "buf", ")", "==", "0", ":", "return", "try", ":", "magic", "=", "ord", "(", "buf", "[", "0", "]", ")", "except", ":", "magic", "=", "buf", "[", "0", "]", "if", "not", "magic", "in", "[", "85", ",", "254", ",", "253", "]", ":", "return", "self", ".", "first_byte", "=", "False", "if", "self", ".", "WIRE_PROTOCOL_VERSION", "==", "\"0.9\"", "and", "magic", "==", "254", ":", "self", ".", "WIRE_PROTOCOL_VERSION", "=", "\"1.0\"", "set_dialect", "(", "current_dialect", ")", "elif", "self", ".", "WIRE_PROTOCOL_VERSION", "==", "\"1.0\"", "and", "magic", "==", "85", ":", "self", ".", "WIRE_PROTOCOL_VERSION", "=", "\"0.9\"", "os", ".", "environ", "[", "'MAVLINK09'", "]", "=", "'1'", "set_dialect", "(", "current_dialect", ")", "elif", "self", ".", "WIRE_PROTOCOL_VERSION", "!=", "\"2.0\"", "and", "magic", "==", "253", ":", "self", ".", "WIRE_PROTOCOL_VERSION", "=", "\"2.0\"", "os", ".", "environ", "[", "'MAVLINK20'", "]", "=", "'1'", "set_dialect", "(", "current_dialect", ")", "else", ":", "return", "# switch protocol ", "(", "callback", ",", "callback_args", ",", "callback_kwargs", ")", "=", "(", "self", ".", "mav", ".", "callback", ",", "self", ".", "mav", ".", "callback_args", ",", "self", ".", "mav", ".", "callback_kwargs", ")", "self", ".", "mav", "=", "mavlink", ".", "MAVLink", "(", "self", ",", "srcSystem", "=", "self", ".", "source_system", ")", "self", ".", "mav", ".", "robust_parsing", "=", "self", ".", "robust_parsing", "self", ".", "WIRE_PROTOCOL_VERSION", "=", "mavlink", ".", "WIRE_PROTOCOL_VERSION", "(", "self", ".", "mav", ".", "callback", ",", "self", ".", "mav", ".", "callback_args", ",", "self", ".", "mav", ".", "callback_kwargs", ")", "=", "(", "callback", ",", "callback_args", ",", "callback_kwargs", ")" ]
auto-switch mavlink protocol version
[ "auto", "-", "switch", "mavlink", "protocol", "version" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L154-L188
235,258
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.select
def select(self, timeout): '''wait for up to timeout seconds for more data''' if self.fd is None: time.sleep(min(timeout,0.5)) return True try: (rin, win, xin) = select.select([self.fd], [], [], timeout) except select.error: return False return len(rin) == 1
python
def select(self, timeout): '''wait for up to timeout seconds for more data''' if self.fd is None: time.sleep(min(timeout,0.5)) return True try: (rin, win, xin) = select.select([self.fd], [], [], timeout) except select.error: return False return len(rin) == 1
[ "def", "select", "(", "self", ",", "timeout", ")", ":", "if", "self", ".", "fd", "is", "None", ":", "time", ".", "sleep", "(", "min", "(", "timeout", ",", "0.5", ")", ")", "return", "True", "try", ":", "(", "rin", ",", "win", ",", "xin", ")", "=", "select", ".", "select", "(", "[", "self", ".", "fd", "]", ",", "[", "]", ",", "[", "]", ",", "timeout", ")", "except", "select", ".", "error", ":", "return", "False", "return", "len", "(", "rin", ")", "==", "1" ]
wait for up to timeout seconds for more data
[ "wait", "for", "up", "to", "timeout", "seconds", "for", "more", "data" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L203-L212
235,259
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.packet_loss
def packet_loss(self): '''packet loss as a percentage''' if self.mav_count == 0: return 0 return (100.0*self.mav_loss)/(self.mav_count+self.mav_loss)
python
def packet_loss(self): '''packet loss as a percentage''' if self.mav_count == 0: return 0 return (100.0*self.mav_loss)/(self.mav_count+self.mav_loss)
[ "def", "packet_loss", "(", "self", ")", ":", "if", "self", ".", "mav_count", "==", "0", ":", "return", "0", "return", "(", "100.0", "*", "self", ".", "mav_loss", ")", "/", "(", "self", ".", "mav_count", "+", "self", ".", "mav_loss", ")" ]
packet loss as a percentage
[ "packet", "loss", "as", "a", "percentage" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L295-L299
235,260
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.recv_match
def recv_match(self, condition=None, type=None, blocking=False, timeout=None): '''recv the next MAVLink message that matches the given condition type can be a string or a list of strings''' if type is not None and not isinstance(type, list): type = [type] start_time = time.time() while True: if timeout is not None: now = time.time() if now < start_time: start_time = now # If an external process rolls back system time, we should not spin forever. if start_time + timeout < time.time(): return None m = self.recv_msg() if m is None: if blocking: for hook in self.idle_hooks: hook(self) if timeout is None: self.select(0.05) else: self.select(timeout/2) continue return None if type is not None and not m.get_type() in type: continue if not evaluate_condition(condition, self.messages): continue return m
python
def recv_match(self, condition=None, type=None, blocking=False, timeout=None): '''recv the next MAVLink message that matches the given condition type can be a string or a list of strings''' if type is not None and not isinstance(type, list): type = [type] start_time = time.time() while True: if timeout is not None: now = time.time() if now < start_time: start_time = now # If an external process rolls back system time, we should not spin forever. if start_time + timeout < time.time(): return None m = self.recv_msg() if m is None: if blocking: for hook in self.idle_hooks: hook(self) if timeout is None: self.select(0.05) else: self.select(timeout/2) continue return None if type is not None and not m.get_type() in type: continue if not evaluate_condition(condition, self.messages): continue return m
[ "def", "recv_match", "(", "self", ",", "condition", "=", "None", ",", "type", "=", "None", ",", "blocking", "=", "False", ",", "timeout", "=", "None", ")", ":", "if", "type", "is", "not", "None", "and", "not", "isinstance", "(", "type", ",", "list", ")", ":", "type", "=", "[", "type", "]", "start_time", "=", "time", ".", "time", "(", ")", "while", "True", ":", "if", "timeout", "is", "not", "None", ":", "now", "=", "time", ".", "time", "(", ")", "if", "now", "<", "start_time", ":", "start_time", "=", "now", "# If an external process rolls back system time, we should not spin forever.", "if", "start_time", "+", "timeout", "<", "time", ".", "time", "(", ")", ":", "return", "None", "m", "=", "self", ".", "recv_msg", "(", ")", "if", "m", "is", "None", ":", "if", "blocking", ":", "for", "hook", "in", "self", ".", "idle_hooks", ":", "hook", "(", "self", ")", "if", "timeout", "is", "None", ":", "self", ".", "select", "(", "0.05", ")", "else", ":", "self", ".", "select", "(", "timeout", "/", "2", ")", "continue", "return", "None", "if", "type", "is", "not", "None", "and", "not", "m", ".", "get_type", "(", ")", "in", "type", ":", "continue", "if", "not", "evaluate_condition", "(", "condition", ",", "self", ".", "messages", ")", ":", "continue", "return", "m" ]
recv the next MAVLink message that matches the given condition type can be a string or a list of strings
[ "recv", "the", "next", "MAVLink", "message", "that", "matches", "the", "given", "condition", "type", "can", "be", "a", "string", "or", "a", "list", "of", "strings" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L331-L359
235,261
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.setup_logfile
def setup_logfile(self, logfile, mode='w'): '''start logging to the given logfile, with timestamps''' self.logfile = open(logfile, mode=mode)
python
def setup_logfile(self, logfile, mode='w'): '''start logging to the given logfile, with timestamps''' self.logfile = open(logfile, mode=mode)
[ "def", "setup_logfile", "(", "self", ",", "logfile", ",", "mode", "=", "'w'", ")", ":", "self", ".", "logfile", "=", "open", "(", "logfile", ",", "mode", "=", "mode", ")" ]
start logging to the given logfile, with timestamps
[ "start", "logging", "to", "the", "given", "logfile", "with", "timestamps" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L373-L375
235,262
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.setup_logfile_raw
def setup_logfile_raw(self, logfile, mode='w'): '''start logging raw bytes to the given logfile, without timestamps''' self.logfile_raw = open(logfile, mode=mode)
python
def setup_logfile_raw(self, logfile, mode='w'): '''start logging raw bytes to the given logfile, without timestamps''' self.logfile_raw = open(logfile, mode=mode)
[ "def", "setup_logfile_raw", "(", "self", ",", "logfile", ",", "mode", "=", "'w'", ")", ":", "self", ".", "logfile_raw", "=", "open", "(", "logfile", ",", "mode", "=", "mode", ")" ]
start logging raw bytes to the given logfile, without timestamps
[ "start", "logging", "raw", "bytes", "to", "the", "given", "logfile", "without", "timestamps" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L377-L379
235,263
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.param_fetch_all
def param_fetch_all(self): '''initiate fetch of all parameters''' if time.time() - getattr(self, 'param_fetch_start', 0) < 2.0: # don't fetch too often return self.param_fetch_start = time.time() self.param_fetch_in_progress = True self.mav.param_request_list_send(self.target_system, self.target_component)
python
def param_fetch_all(self): '''initiate fetch of all parameters''' if time.time() - getattr(self, 'param_fetch_start', 0) < 2.0: # don't fetch too often return self.param_fetch_start = time.time() self.param_fetch_in_progress = True self.mav.param_request_list_send(self.target_system, self.target_component)
[ "def", "param_fetch_all", "(", "self", ")", ":", "if", "time", ".", "time", "(", ")", "-", "getattr", "(", "self", ",", "'param_fetch_start'", ",", "0", ")", "<", "2.0", ":", "# don't fetch too often", "return", "self", ".", "param_fetch_start", "=", "time", ".", "time", "(", ")", "self", ".", "param_fetch_in_progress", "=", "True", "self", ".", "mav", ".", "param_request_list_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ")" ]
initiate fetch of all parameters
[ "initiate", "fetch", "of", "all", "parameters" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L385-L392
235,264
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.param_fetch_one
def param_fetch_one(self, name): '''initiate fetch of one parameter''' try: idx = int(name) self.mav.param_request_read_send(self.target_system, self.target_component, "", idx) except Exception: self.mav.param_request_read_send(self.target_system, self.target_component, name, -1)
python
def param_fetch_one(self, name): '''initiate fetch of one parameter''' try: idx = int(name) self.mav.param_request_read_send(self.target_system, self.target_component, "", idx) except Exception: self.mav.param_request_read_send(self.target_system, self.target_component, name, -1)
[ "def", "param_fetch_one", "(", "self", ",", "name", ")", ":", "try", ":", "idx", "=", "int", "(", "name", ")", "self", ".", "mav", ".", "param_request_read_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "\"\"", ",", "idx", ")", "except", "Exception", ":", "self", ".", "mav", ".", "param_request_read_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "name", ",", "-", "1", ")" ]
initiate fetch of one parameter
[ "initiate", "fetch", "of", "one", "parameter" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L394-L400
235,265
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.time_since
def time_since(self, mtype): '''return the time since the last message of type mtype was received''' if not mtype in self.messages: return time.time() - self.start_time return time.time() - self.messages[mtype]._timestamp
python
def time_since(self, mtype): '''return the time since the last message of type mtype was received''' if not mtype in self.messages: return time.time() - self.start_time return time.time() - self.messages[mtype]._timestamp
[ "def", "time_since", "(", "self", ",", "mtype", ")", ":", "if", "not", "mtype", "in", "self", ".", "messages", ":", "return", "time", ".", "time", "(", ")", "-", "self", ".", "start_time", "return", "time", ".", "time", "(", ")", "-", "self", ".", "messages", "[", "mtype", "]", ".", "_timestamp" ]
return the time since the last message of type mtype was received
[ "return", "the", "time", "since", "the", "last", "message", "of", "type", "mtype", "was", "received" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L402-L406
235,266
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.param_set_send
def param_set_send(self, parm_name, parm_value, parm_type=None): '''wrapper for parameter set''' if self.mavlink10(): if parm_type == None: parm_type = mavlink.MAVLINK_TYPE_FLOAT self.mav.param_set_send(self.target_system, self.target_component, parm_name, parm_value, parm_type) else: self.mav.param_set_send(self.target_system, self.target_component, parm_name, parm_value)
python
def param_set_send(self, parm_name, parm_value, parm_type=None): '''wrapper for parameter set''' if self.mavlink10(): if parm_type == None: parm_type = mavlink.MAVLINK_TYPE_FLOAT self.mav.param_set_send(self.target_system, self.target_component, parm_name, parm_value, parm_type) else: self.mav.param_set_send(self.target_system, self.target_component, parm_name, parm_value)
[ "def", "param_set_send", "(", "self", ",", "parm_name", ",", "parm_value", ",", "parm_type", "=", "None", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "if", "parm_type", "==", "None", ":", "parm_type", "=", "mavlink", ".", "MAVLINK_TYPE_FLOAT", "self", ".", "mav", ".", "param_set_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "parm_name", ",", "parm_value", ",", "parm_type", ")", "else", ":", "self", ".", "mav", ".", "param_set_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "parm_name", ",", "parm_value", ")" ]
wrapper for parameter set
[ "wrapper", "for", "parameter", "set" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L408-L417
235,267
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_request_list_send
def waypoint_request_list_send(self): '''wrapper for waypoint_request_list_send''' if self.mavlink10(): self.mav.mission_request_list_send(self.target_system, self.target_component) else: self.mav.waypoint_request_list_send(self.target_system, self.target_component)
python
def waypoint_request_list_send(self): '''wrapper for waypoint_request_list_send''' if self.mavlink10(): self.mav.mission_request_list_send(self.target_system, self.target_component) else: self.mav.waypoint_request_list_send(self.target_system, self.target_component)
[ "def", "waypoint_request_list_send", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "mission_request_list_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ")", "else", ":", "self", ".", "mav", ".", "waypoint_request_list_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ")" ]
wrapper for waypoint_request_list_send
[ "wrapper", "for", "waypoint_request_list_send" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L419-L424
235,268
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_clear_all_send
def waypoint_clear_all_send(self): '''wrapper for waypoint_clear_all_send''' if self.mavlink10(): self.mav.mission_clear_all_send(self.target_system, self.target_component) else: self.mav.waypoint_clear_all_send(self.target_system, self.target_component)
python
def waypoint_clear_all_send(self): '''wrapper for waypoint_clear_all_send''' if self.mavlink10(): self.mav.mission_clear_all_send(self.target_system, self.target_component) else: self.mav.waypoint_clear_all_send(self.target_system, self.target_component)
[ "def", "waypoint_clear_all_send", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "mission_clear_all_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ")", "else", ":", "self", ".", "mav", ".", "waypoint_clear_all_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ")" ]
wrapper for waypoint_clear_all_send
[ "wrapper", "for", "waypoint_clear_all_send" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L426-L431
235,269
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_request_send
def waypoint_request_send(self, seq): '''wrapper for waypoint_request_send''' if self.mavlink10(): self.mav.mission_request_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_request_send(self.target_system, self.target_component, seq)
python
def waypoint_request_send(self, seq): '''wrapper for waypoint_request_send''' if self.mavlink10(): self.mav.mission_request_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_request_send(self.target_system, self.target_component, seq)
[ "def", "waypoint_request_send", "(", "self", ",", "seq", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "mission_request_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")", "else", ":", "self", ".", "mav", ".", "waypoint_request_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")" ]
wrapper for waypoint_request_send
[ "wrapper", "for", "waypoint_request_send" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L433-L438
235,270
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_set_current_send
def waypoint_set_current_send(self, seq): '''wrapper for waypoint_set_current_send''' if self.mavlink10(): self.mav.mission_set_current_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_set_current_send(self.target_system, self.target_component, seq)
python
def waypoint_set_current_send(self, seq): '''wrapper for waypoint_set_current_send''' if self.mavlink10(): self.mav.mission_set_current_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_set_current_send(self.target_system, self.target_component, seq)
[ "def", "waypoint_set_current_send", "(", "self", ",", "seq", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "mission_set_current_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")", "else", ":", "self", ".", "mav", ".", "waypoint_set_current_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")" ]
wrapper for waypoint_set_current_send
[ "wrapper", "for", "waypoint_set_current_send" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L440-L445
235,271
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_current
def waypoint_current(self): '''return current waypoint''' if self.mavlink10(): m = self.recv_match(type='MISSION_CURRENT', blocking=True) else: m = self.recv_match(type='WAYPOINT_CURRENT', blocking=True) return m.seq
python
def waypoint_current(self): '''return current waypoint''' if self.mavlink10(): m = self.recv_match(type='MISSION_CURRENT', blocking=True) else: m = self.recv_match(type='WAYPOINT_CURRENT', blocking=True) return m.seq
[ "def", "waypoint_current", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "m", "=", "self", ".", "recv_match", "(", "type", "=", "'MISSION_CURRENT'", ",", "blocking", "=", "True", ")", "else", ":", "m", "=", "self", ".", "recv_match", "(", "type", "=", "'WAYPOINT_CURRENT'", ",", "blocking", "=", "True", ")", "return", "m", ".", "seq" ]
return current waypoint
[ "return", "current", "waypoint" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L447-L453
235,272
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.waypoint_count_send
def waypoint_count_send(self, seq): '''wrapper for waypoint_count_send''' if self.mavlink10(): self.mav.mission_count_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_count_send(self.target_system, self.target_component, seq)
python
def waypoint_count_send(self, seq): '''wrapper for waypoint_count_send''' if self.mavlink10(): self.mav.mission_count_send(self.target_system, self.target_component, seq) else: self.mav.waypoint_count_send(self.target_system, self.target_component, seq)
[ "def", "waypoint_count_send", "(", "self", ",", "seq", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "mission_count_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")", "else", ":", "self", ".", "mav", ".", "waypoint_count_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "seq", ")" ]
wrapper for waypoint_count_send
[ "wrapper", "for", "waypoint_count_send" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L455-L460
235,273
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode_auto
def set_mode_auto(self): '''enter auto mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_MISSION_START, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_SET_AUTO = 13 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_SET_AUTO)
python
def set_mode_auto(self): '''enter auto mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_MISSION_START, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_SET_AUTO = 13 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_SET_AUTO)
[ "def", "set_mode_auto", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_MISSION_START", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "MAV_ACTION_SET_AUTO", "=", "13", "self", ".", "mav", ".", "action_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "MAV_ACTION_SET_AUTO", ")" ]
enter auto mode
[ "enter", "auto", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L482-L489
235,274
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode
def set_mode(self, mode, custom_mode = 0, custom_sub_mode = 0): '''set arbitrary flight mode''' mav_autopilot = self.field('HEARTBEAT', 'autopilot', None) if mav_autopilot == mavlink.MAV_AUTOPILOT_PX4: self.set_mode_px4(mode, custom_mode, custom_sub_mode) else: self.set_mode_apm(mode)
python
def set_mode(self, mode, custom_mode = 0, custom_sub_mode = 0): '''set arbitrary flight mode''' mav_autopilot = self.field('HEARTBEAT', 'autopilot', None) if mav_autopilot == mavlink.MAV_AUTOPILOT_PX4: self.set_mode_px4(mode, custom_mode, custom_sub_mode) else: self.set_mode_apm(mode)
[ "def", "set_mode", "(", "self", ",", "mode", ",", "custom_mode", "=", "0", ",", "custom_sub_mode", "=", "0", ")", ":", "mav_autopilot", "=", "self", ".", "field", "(", "'HEARTBEAT'", ",", "'autopilot'", ",", "None", ")", "if", "mav_autopilot", "==", "mavlink", ".", "MAV_AUTOPILOT_PX4", ":", "self", ".", "set_mode_px4", "(", "mode", ",", "custom_mode", ",", "custom_sub_mode", ")", "else", ":", "self", ".", "set_mode_apm", "(", "mode", ")" ]
set arbitrary flight mode
[ "set", "arbitrary", "flight", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L543-L549
235,275
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode_rtl
def set_mode_rtl(self): '''enter RTL mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_RETURN_TO_LAUNCH, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_RETURN = 3 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_RETURN)
python
def set_mode_rtl(self): '''enter RTL mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_RETURN_TO_LAUNCH, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_RETURN = 3 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_RETURN)
[ "def", "set_mode_rtl", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_NAV_RETURN_TO_LAUNCH", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "MAV_ACTION_RETURN", "=", "3", "self", ".", "mav", ".", "action_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "MAV_ACTION_RETURN", ")" ]
enter RTL mode
[ "enter", "RTL", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L551-L558
235,276
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode_manual
def set_mode_manual(self): '''enter MANUAL mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_MODE, 0, mavlink.MAV_MODE_MANUAL_ARMED, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_SET_MANUAL = 12 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_SET_MANUAL)
python
def set_mode_manual(self): '''enter MANUAL mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_MODE, 0, mavlink.MAV_MODE_MANUAL_ARMED, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_SET_MANUAL = 12 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_SET_MANUAL)
[ "def", "set_mode_manual", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_DO_SET_MODE", ",", "0", ",", "mavlink", ".", "MAV_MODE_MANUAL_ARMED", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "MAV_ACTION_SET_MANUAL", "=", "12", "self", ".", "mav", ".", "action_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "MAV_ACTION_SET_MANUAL", ")" ]
enter MANUAL mode
[ "enter", "MANUAL", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L560-L569
235,277
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode_fbwa
def set_mode_fbwa(self): '''enter FBWA mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_MODE, 0, mavlink.MAV_MODE_STABILIZE_ARMED, 0, 0, 0, 0, 0, 0) else: print("Forcing FBWA not supported")
python
def set_mode_fbwa(self): '''enter FBWA mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_MODE, 0, mavlink.MAV_MODE_STABILIZE_ARMED, 0, 0, 0, 0, 0, 0) else: print("Forcing FBWA not supported")
[ "def", "set_mode_fbwa", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_DO_SET_MODE", ",", "0", ",", "mavlink", ".", "MAV_MODE_STABILIZE_ARMED", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "print", "(", "\"Forcing FBWA not supported\"", ")" ]
enter FBWA mode
[ "enter", "FBWA", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L571-L579
235,278
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_mode_loiter
def set_mode_loiter(self): '''enter LOITER mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_LOITER_UNLIM, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_LOITER = 27 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_LOITER)
python
def set_mode_loiter(self): '''enter LOITER mode''' if self.mavlink10(): self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_LOITER_UNLIM, 0, 0, 0, 0, 0, 0, 0, 0) else: MAV_ACTION_LOITER = 27 self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_LOITER)
[ "def", "set_mode_loiter", "(", "self", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_NAV_LOITER_UNLIM", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "else", ":", "MAV_ACTION_LOITER", "=", "27", "self", ".", "mav", ".", "action_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "MAV_ACTION_LOITER", ")" ]
enter LOITER mode
[ "enter", "LOITER", "mode" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L581-L588
235,279
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_servo
def set_servo(self, channel, pwm): '''set a servo value''' self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_SERVO, 0, channel, pwm, 0, 0, 0, 0, 0)
python
def set_servo(self, channel, pwm): '''set a servo value''' self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_DO_SET_SERVO, 0, channel, pwm, 0, 0, 0, 0, 0)
[ "def", "set_servo", "(", "self", ",", "channel", ",", "pwm", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_DO_SET_SERVO", ",", "0", ",", "channel", ",", "pwm", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")" ]
set a servo value
[ "set", "a", "servo", "value" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L590-L595
235,280
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.set_relay
def set_relay(self, relay_pin=0, state=True): '''Set relay_pin to value of state''' if self.mavlink10(): self.mav.command_long_send( self.target_system, # target_system self.target_component, # target_component mavlink.MAV_CMD_DO_SET_RELAY, # command 0, # Confirmation relay_pin, # Relay Number int(state), # state (1 to indicate arm) 0, # param3 (all other params meaningless) 0, # param4 0, # param5 0, # param6 0) # param7 else: print("Setting relays not supported.")
python
def set_relay(self, relay_pin=0, state=True): '''Set relay_pin to value of state''' if self.mavlink10(): self.mav.command_long_send( self.target_system, # target_system self.target_component, # target_component mavlink.MAV_CMD_DO_SET_RELAY, # command 0, # Confirmation relay_pin, # Relay Number int(state), # state (1 to indicate arm) 0, # param3 (all other params meaningless) 0, # param4 0, # param5 0, # param6 0) # param7 else: print("Setting relays not supported.")
[ "def", "set_relay", "(", "self", ",", "relay_pin", "=", "0", ",", "state", "=", "True", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "# target_system", "self", ".", "target_component", ",", "# target_component", "mavlink", ".", "MAV_CMD_DO_SET_RELAY", ",", "# command", "0", ",", "# Confirmation", "relay_pin", ",", "# Relay Number", "int", "(", "state", ")", ",", "# state (1 to indicate arm)", "0", ",", "# param3 (all other params meaningless)", "0", ",", "# param4", "0", ",", "# param5", "0", ",", "# param6", "0", ")", "# param7", "else", ":", "print", "(", "\"Setting relays not supported.\"", ")" ]
Set relay_pin to value of state
[ "Set", "relay_pin", "to", "value", "of", "state" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L598-L614
235,281
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.reboot_autopilot
def reboot_autopilot(self, hold_in_bootloader=False): '''reboot the autopilot''' if self.mavlink10(): if hold_in_bootloader: param1 = 3 else: param1 = 1 self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 0, param1, 0, 0, 0, 0, 0, 0) # send an old style reboot immediately afterwards in case it is an older firmware # that doesn't understand the new convention self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 0, 1, 0, 0, 0, 0, 0, 0)
python
def reboot_autopilot(self, hold_in_bootloader=False): '''reboot the autopilot''' if self.mavlink10(): if hold_in_bootloader: param1 = 3 else: param1 = 1 self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 0, param1, 0, 0, 0, 0, 0, 0) # send an old style reboot immediately afterwards in case it is an older firmware # that doesn't understand the new convention self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 0, 1, 0, 0, 0, 0, 0, 0)
[ "def", "reboot_autopilot", "(", "self", ",", "hold_in_bootloader", "=", "False", ")", ":", "if", "self", ".", "mavlink10", "(", ")", ":", "if", "hold_in_bootloader", ":", "param1", "=", "3", "else", ":", "param1", "=", "1", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN", ",", "0", ",", "param1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", "# send an old style reboot immediately afterwards in case it is an older firmware", "# that doesn't understand the new convention", "self", ".", "mav", ".", "command_long_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "mavlink", ".", "MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")" ]
reboot the autopilot
[ "reboot", "the", "autopilot" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L632-L646
235,282
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.location
def location(self, relative_alt=False): '''return current location''' self.wait_gps_fix() # wait for another VFR_HUD, to ensure we have correct altitude self.recv_match(type='VFR_HUD', blocking=True) self.recv_match(type='GLOBAL_POSITION_INT', blocking=True) if relative_alt: alt = self.messages['GLOBAL_POSITION_INT'].relative_alt*0.001 else: alt = self.messages['VFR_HUD'].alt return location(self.messages['GPS_RAW_INT'].lat*1.0e-7, self.messages['GPS_RAW_INT'].lon*1.0e-7, alt, self.messages['VFR_HUD'].heading)
python
def location(self, relative_alt=False): '''return current location''' self.wait_gps_fix() # wait for another VFR_HUD, to ensure we have correct altitude self.recv_match(type='VFR_HUD', blocking=True) self.recv_match(type='GLOBAL_POSITION_INT', blocking=True) if relative_alt: alt = self.messages['GLOBAL_POSITION_INT'].relative_alt*0.001 else: alt = self.messages['VFR_HUD'].alt return location(self.messages['GPS_RAW_INT'].lat*1.0e-7, self.messages['GPS_RAW_INT'].lon*1.0e-7, alt, self.messages['VFR_HUD'].heading)
[ "def", "location", "(", "self", ",", "relative_alt", "=", "False", ")", ":", "self", ".", "wait_gps_fix", "(", ")", "# wait for another VFR_HUD, to ensure we have correct altitude", "self", ".", "recv_match", "(", "type", "=", "'VFR_HUD'", ",", "blocking", "=", "True", ")", "self", ".", "recv_match", "(", "type", "=", "'GLOBAL_POSITION_INT'", ",", "blocking", "=", "True", ")", "if", "relative_alt", ":", "alt", "=", "self", ".", "messages", "[", "'GLOBAL_POSITION_INT'", "]", ".", "relative_alt", "*", "0.001", "else", ":", "alt", "=", "self", ".", "messages", "[", "'VFR_HUD'", "]", ".", "alt", "return", "location", "(", "self", ".", "messages", "[", "'GPS_RAW_INT'", "]", ".", "lat", "*", "1.0e-7", ",", "self", ".", "messages", "[", "'GPS_RAW_INT'", "]", ".", "lon", "*", "1.0e-7", ",", "alt", ",", "self", ".", "messages", "[", "'VFR_HUD'", "]", ".", "heading", ")" ]
return current location
[ "return", "current", "location" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L657-L670
235,283
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.motors_armed
def motors_armed(self): '''return true if motors armed''' if not 'HEARTBEAT' in self.messages: return False m = self.messages['HEARTBEAT'] return (m.base_mode & mavlink.MAV_MODE_FLAG_SAFETY_ARMED) != 0
python
def motors_armed(self): '''return true if motors armed''' if not 'HEARTBEAT' in self.messages: return False m = self.messages['HEARTBEAT'] return (m.base_mode & mavlink.MAV_MODE_FLAG_SAFETY_ARMED) != 0
[ "def", "motors_armed", "(", "self", ")", ":", "if", "not", "'HEARTBEAT'", "in", "self", ".", "messages", ":", "return", "False", "m", "=", "self", ".", "messages", "[", "'HEARTBEAT'", "]", "return", "(", "m", ".", "base_mode", "&", "mavlink", ".", "MAV_MODE_FLAG_SAFETY_ARMED", ")", "!=", "0" ]
return true if motors armed
[ "return", "true", "if", "motors", "armed" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L704-L709
235,284
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.field
def field(self, type, field, default=None): '''convenient function for returning an arbitrary MAVLink field with a default''' if not type in self.messages: return default return getattr(self.messages[type], field, default)
python
def field(self, type, field, default=None): '''convenient function for returning an arbitrary MAVLink field with a default''' if not type in self.messages: return default return getattr(self.messages[type], field, default)
[ "def", "field", "(", "self", ",", "type", ",", "field", ",", "default", "=", "None", ")", ":", "if", "not", "type", "in", "self", ".", "messages", ":", "return", "default", "return", "getattr", "(", "self", ".", "messages", "[", "type", "]", ",", "field", ",", "default", ")" ]
convenient function for returning an arbitrary MAVLink field with a default
[ "convenient", "function", "for", "returning", "an", "arbitrary", "MAVLink", "field", "with", "a", "default" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L726-L731
235,285
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.setup_signing
def setup_signing(self, secret_key, sign_outgoing=True, allow_unsigned_callback=None, initial_timestamp=None, link_id=None): '''setup for MAVLink2 signing''' self.mav.signing.secret_key = secret_key self.mav.signing.sign_outgoing = sign_outgoing self.mav.signing.allow_unsigned_callback = allow_unsigned_callback if link_id is None: # auto-increment the link_id for each link global global_link_id link_id = global_link_id global_link_id = min(global_link_id + 1, 255) self.mav.signing.link_id = link_id if initial_timestamp is None: # timestamp is time since 1/1/2015 epoch_offset = 1420070400 now = max(time.time(), epoch_offset) initial_timestamp = now - epoch_offset initial_timestamp = int(initial_timestamp * 100 * 1000) # initial_timestamp is in 10usec units self.mav.signing.timestamp = initial_timestamp
python
def setup_signing(self, secret_key, sign_outgoing=True, allow_unsigned_callback=None, initial_timestamp=None, link_id=None): '''setup for MAVLink2 signing''' self.mav.signing.secret_key = secret_key self.mav.signing.sign_outgoing = sign_outgoing self.mav.signing.allow_unsigned_callback = allow_unsigned_callback if link_id is None: # auto-increment the link_id for each link global global_link_id link_id = global_link_id global_link_id = min(global_link_id + 1, 255) self.mav.signing.link_id = link_id if initial_timestamp is None: # timestamp is time since 1/1/2015 epoch_offset = 1420070400 now = max(time.time(), epoch_offset) initial_timestamp = now - epoch_offset initial_timestamp = int(initial_timestamp * 100 * 1000) # initial_timestamp is in 10usec units self.mav.signing.timestamp = initial_timestamp
[ "def", "setup_signing", "(", "self", ",", "secret_key", ",", "sign_outgoing", "=", "True", ",", "allow_unsigned_callback", "=", "None", ",", "initial_timestamp", "=", "None", ",", "link_id", "=", "None", ")", ":", "self", ".", "mav", ".", "signing", ".", "secret_key", "=", "secret_key", "self", ".", "mav", ".", "signing", ".", "sign_outgoing", "=", "sign_outgoing", "self", ".", "mav", ".", "signing", ".", "allow_unsigned_callback", "=", "allow_unsigned_callback", "if", "link_id", "is", "None", ":", "# auto-increment the link_id for each link", "global", "global_link_id", "link_id", "=", "global_link_id", "global_link_id", "=", "min", "(", "global_link_id", "+", "1", ",", "255", ")", "self", ".", "mav", ".", "signing", ".", "link_id", "=", "link_id", "if", "initial_timestamp", "is", "None", ":", "# timestamp is time since 1/1/2015", "epoch_offset", "=", "1420070400", "now", "=", "max", "(", "time", ".", "time", "(", ")", ",", "epoch_offset", ")", "initial_timestamp", "=", "now", "-", "epoch_offset", "initial_timestamp", "=", "int", "(", "initial_timestamp", "*", "100", "*", "1000", ")", "# initial_timestamp is in 10usec units", "self", ".", "mav", ".", "signing", ".", "timestamp", "=", "initial_timestamp" ]
setup for MAVLink2 signing
[ "setup", "for", "MAVLink2", "signing" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L740-L758
235,286
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavfile.disable_signing
def disable_signing(self): '''disable MAVLink2 signing''' self.mav.signing.secret_key = None self.mav.signing.sign_outgoing = False self.mav.signing.allow_unsigned_callback = None self.mav.signing.link_id = 0 self.mav.signing.timestamp = 0
python
def disable_signing(self): '''disable MAVLink2 signing''' self.mav.signing.secret_key = None self.mav.signing.sign_outgoing = False self.mav.signing.allow_unsigned_callback = None self.mav.signing.link_id = 0 self.mav.signing.timestamp = 0
[ "def", "disable_signing", "(", "self", ")", ":", "self", ".", "mav", ".", "signing", ".", "secret_key", "=", "None", "self", ".", "mav", ".", "signing", ".", "sign_outgoing", "=", "False", "self", ".", "mav", ".", "signing", ".", "allow_unsigned_callback", "=", "None", "self", ".", "mav", ".", "signing", ".", "link_id", "=", "0", "self", ".", "mav", ".", "signing", ".", "timestamp", "=", "0" ]
disable MAVLink2 signing
[ "disable", "MAVLink2", "signing" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L760-L766
235,287
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavlogfile.scan_timestamp
def scan_timestamp(self, tbuf): '''scan forward looking in a tlog for a timestamp in a reasonable range''' while True: (tusec,) = struct.unpack('>Q', tbuf) t = tusec * 1.0e-6 if abs(t - self._last_timestamp) <= 3*24*60*60: break c = self.f.read(1) if len(c) != 1: break tbuf = tbuf[1:] + c return t
python
def scan_timestamp(self, tbuf): '''scan forward looking in a tlog for a timestamp in a reasonable range''' while True: (tusec,) = struct.unpack('>Q', tbuf) t = tusec * 1.0e-6 if abs(t - self._last_timestamp) <= 3*24*60*60: break c = self.f.read(1) if len(c) != 1: break tbuf = tbuf[1:] + c return t
[ "def", "scan_timestamp", "(", "self", ",", "tbuf", ")", ":", "while", "True", ":", "(", "tusec", ",", ")", "=", "struct", ".", "unpack", "(", "'>Q'", ",", "tbuf", ")", "t", "=", "tusec", "*", "1.0e-6", "if", "abs", "(", "t", "-", "self", ".", "_last_timestamp", ")", "<=", "3", "*", "24", "*", "60", "*", "60", ":", "break", "c", "=", "self", ".", "f", ".", "read", "(", "1", ")", "if", "len", "(", "c", ")", "!=", "1", ":", "break", "tbuf", "=", "tbuf", "[", "1", ":", "]", "+", "c", "return", "t" ]
scan forward looking in a tlog for a timestamp in a reasonable range
[ "scan", "forward", "looking", "in", "a", "tlog", "for", "a", "timestamp", "in", "a", "reasonable", "range" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1073-L1084
235,288
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavlogfile.pre_message
def pre_message(self): '''read timestamp if needed''' # read the timestamp if self.filesize != 0: self.percent = (100.0 * self.f.tell()) / self.filesize if self.notimestamps: return if self.planner_format: tbuf = self.f.read(21) if len(tbuf) != 21 or tbuf[0] != '-' or tbuf[20] != ':': raise RuntimeError('bad planner timestamp %s' % tbuf) hnsec = self._two64 + float(tbuf[0:20]) t = hnsec * 1.0e-7 # convert to seconds t -= 719163 * 24 * 60 * 60 # convert to 1970 base self._link = 0 else: tbuf = self.f.read(8) if len(tbuf) != 8: return (tusec,) = struct.unpack('>Q', tbuf) t = tusec * 1.0e-6 if (self._last_timestamp is not None and self._last_message.get_type() == "BAD_DATA" and abs(t - self._last_timestamp) > 3*24*60*60): t = self.scan_timestamp(tbuf) self._link = tusec & 0x3 self._timestamp = t
python
def pre_message(self): '''read timestamp if needed''' # read the timestamp if self.filesize != 0: self.percent = (100.0 * self.f.tell()) / self.filesize if self.notimestamps: return if self.planner_format: tbuf = self.f.read(21) if len(tbuf) != 21 or tbuf[0] != '-' or tbuf[20] != ':': raise RuntimeError('bad planner timestamp %s' % tbuf) hnsec = self._two64 + float(tbuf[0:20]) t = hnsec * 1.0e-7 # convert to seconds t -= 719163 * 24 * 60 * 60 # convert to 1970 base self._link = 0 else: tbuf = self.f.read(8) if len(tbuf) != 8: return (tusec,) = struct.unpack('>Q', tbuf) t = tusec * 1.0e-6 if (self._last_timestamp is not None and self._last_message.get_type() == "BAD_DATA" and abs(t - self._last_timestamp) > 3*24*60*60): t = self.scan_timestamp(tbuf) self._link = tusec & 0x3 self._timestamp = t
[ "def", "pre_message", "(", "self", ")", ":", "# read the timestamp", "if", "self", ".", "filesize", "!=", "0", ":", "self", ".", "percent", "=", "(", "100.0", "*", "self", ".", "f", ".", "tell", "(", ")", ")", "/", "self", ".", "filesize", "if", "self", ".", "notimestamps", ":", "return", "if", "self", ".", "planner_format", ":", "tbuf", "=", "self", ".", "f", ".", "read", "(", "21", ")", "if", "len", "(", "tbuf", ")", "!=", "21", "or", "tbuf", "[", "0", "]", "!=", "'-'", "or", "tbuf", "[", "20", "]", "!=", "':'", ":", "raise", "RuntimeError", "(", "'bad planner timestamp %s'", "%", "tbuf", ")", "hnsec", "=", "self", ".", "_two64", "+", "float", "(", "tbuf", "[", "0", ":", "20", "]", ")", "t", "=", "hnsec", "*", "1.0e-7", "# convert to seconds", "t", "-=", "719163", "*", "24", "*", "60", "*", "60", "# convert to 1970 base", "self", ".", "_link", "=", "0", "else", ":", "tbuf", "=", "self", ".", "f", ".", "read", "(", "8", ")", "if", "len", "(", "tbuf", ")", "!=", "8", ":", "return", "(", "tusec", ",", ")", "=", "struct", ".", "unpack", "(", "'>Q'", ",", "tbuf", ")", "t", "=", "tusec", "*", "1.0e-6", "if", "(", "self", ".", "_last_timestamp", "is", "not", "None", "and", "self", ".", "_last_message", ".", "get_type", "(", ")", "==", "\"BAD_DATA\"", "and", "abs", "(", "t", "-", "self", ".", "_last_timestamp", ")", ">", "3", "*", "24", "*", "60", "*", "60", ")", ":", "t", "=", "self", ".", "scan_timestamp", "(", "tbuf", ")", "self", ".", "_link", "=", "tusec", "&", "0x3", "self", ".", "_timestamp", "=", "t" ]
read timestamp if needed
[ "read", "timestamp", "if", "needed" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1087-L1113
235,289
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
mavlogfile.post_message
def post_message(self, msg): '''add timestamp to message''' # read the timestamp super(mavlogfile, self).post_message(msg) if self.planner_format: self.f.read(1) # trailing newline self.timestamp = msg._timestamp self._last_message = msg if msg.get_type() != "BAD_DATA": self._last_timestamp = msg._timestamp msg._link = self._link
python
def post_message(self, msg): '''add timestamp to message''' # read the timestamp super(mavlogfile, self).post_message(msg) if self.planner_format: self.f.read(1) # trailing newline self.timestamp = msg._timestamp self._last_message = msg if msg.get_type() != "BAD_DATA": self._last_timestamp = msg._timestamp msg._link = self._link
[ "def", "post_message", "(", "self", ",", "msg", ")", ":", "# read the timestamp", "super", "(", "mavlogfile", ",", "self", ")", ".", "post_message", "(", "msg", ")", "if", "self", ".", "planner_format", ":", "self", ".", "f", ".", "read", "(", "1", ")", "# trailing newline", "self", ".", "timestamp", "=", "msg", ".", "_timestamp", "self", ".", "_last_message", "=", "msg", "if", "msg", ".", "get_type", "(", ")", "!=", "\"BAD_DATA\"", ":", "self", ".", "_last_timestamp", "=", "msg", ".", "_timestamp", "msg", ".", "_link", "=", "self", ".", "_link" ]
add timestamp to message
[ "add", "timestamp", "to", "message" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1115-L1125
235,290
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
periodic_event.trigger
def trigger(self): '''return True if we should trigger now''' tnow = time.time() if tnow < self.last_time: print("Warning, time moved backwards. Restarting timer.") self.last_time = tnow if self.last_time + (1.0/self.frequency) <= tnow: self.last_time = tnow return True return False
python
def trigger(self): '''return True if we should trigger now''' tnow = time.time() if tnow < self.last_time: print("Warning, time moved backwards. Restarting timer.") self.last_time = tnow if self.last_time + (1.0/self.frequency) <= tnow: self.last_time = tnow return True return False
[ "def", "trigger", "(", "self", ")", ":", "tnow", "=", "time", ".", "time", "(", ")", "if", "tnow", "<", "self", ".", "last_time", ":", "print", "(", "\"Warning, time moved backwards. Restarting timer.\"", ")", "self", ".", "last_time", "=", "tnow", "if", "self", ".", "last_time", "+", "(", "1.0", "/", "self", ".", "frequency", ")", "<=", "tnow", ":", "self", ".", "last_time", "=", "tnow", "return", "True", "return", "False" ]
return True if we should trigger now
[ "return", "True", "if", "we", "should", "trigger", "now" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1256-L1267
235,291
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
MavlinkSerialPort.write
def write(self, b): '''write some bytes''' from . import mavutil self.debug("sending '%s' (0x%02x) of len %u\n" % (b, ord(b[0]), len(b)), 2) while len(b) > 0: n = len(b) if n > 70: n = 70 buf = [ord(x) for x in b[:n]] buf.extend([0]*(70-len(buf))) self.mav.mav.serial_control_send(self.port, mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE | mavutil.mavlink.SERIAL_CONTROL_FLAG_RESPOND, 0, 0, n, buf) b = b[n:]
python
def write(self, b): '''write some bytes''' from . import mavutil self.debug("sending '%s' (0x%02x) of len %u\n" % (b, ord(b[0]), len(b)), 2) while len(b) > 0: n = len(b) if n > 70: n = 70 buf = [ord(x) for x in b[:n]] buf.extend([0]*(70-len(buf))) self.mav.mav.serial_control_send(self.port, mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE | mavutil.mavlink.SERIAL_CONTROL_FLAG_RESPOND, 0, 0, n, buf) b = b[n:]
[ "def", "write", "(", "self", ",", "b", ")", ":", "from", ".", "import", "mavutil", "self", ".", "debug", "(", "\"sending '%s' (0x%02x) of len %u\\n\"", "%", "(", "b", ",", "ord", "(", "b", "[", "0", "]", ")", ",", "len", "(", "b", ")", ")", ",", "2", ")", "while", "len", "(", "b", ")", ">", "0", ":", "n", "=", "len", "(", "b", ")", "if", "n", ">", "70", ":", "n", "=", "70", "buf", "=", "[", "ord", "(", "x", ")", "for", "x", "in", "b", "[", ":", "n", "]", "]", "buf", ".", "extend", "(", "[", "0", "]", "*", "(", "70", "-", "len", "(", "buf", ")", ")", ")", "self", ".", "mav", ".", "mav", ".", "serial_control_send", "(", "self", ".", "port", ",", "mavutil", ".", "mavlink", ".", "SERIAL_CONTROL_FLAG_EXCLUSIVE", "|", "mavutil", ".", "mavlink", ".", "SERIAL_CONTROL_FLAG_RESPOND", ",", "0", ",", "0", ",", "n", ",", "buf", ")", "b", "=", "b", "[", "n", ":", "]" ]
write some bytes
[ "write", "some", "bytes" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1696-L1713
235,292
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
MavlinkSerialPort._recv
def _recv(self): '''read some bytes into self.buf''' from . import mavutil start_time = time.time() while time.time() < start_time + self.timeout: m = self.mav.recv_match(condition='SERIAL_CONTROL.count!=0', type='SERIAL_CONTROL', blocking=False, timeout=0) if m is not None and m.count != 0: break self.mav.mav.serial_control_send(self.port, mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE | mavutil.mavlink.SERIAL_CONTROL_FLAG_RESPOND, 0, 0, 0, [0]*70) m = self.mav.recv_match(condition='SERIAL_CONTROL.count!=0', type='SERIAL_CONTROL', blocking=True, timeout=0.01) if m is not None and m.count != 0: break if m is not None: if self._debug > 2: print(m) data = m.data[:m.count] self.buf += ''.join(str(chr(x)) for x in data)
python
def _recv(self): '''read some bytes into self.buf''' from . import mavutil start_time = time.time() while time.time() < start_time + self.timeout: m = self.mav.recv_match(condition='SERIAL_CONTROL.count!=0', type='SERIAL_CONTROL', blocking=False, timeout=0) if m is not None and m.count != 0: break self.mav.mav.serial_control_send(self.port, mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE | mavutil.mavlink.SERIAL_CONTROL_FLAG_RESPOND, 0, 0, 0, [0]*70) m = self.mav.recv_match(condition='SERIAL_CONTROL.count!=0', type='SERIAL_CONTROL', blocking=True, timeout=0.01) if m is not None and m.count != 0: break if m is not None: if self._debug > 2: print(m) data = m.data[:m.count] self.buf += ''.join(str(chr(x)) for x in data)
[ "def", "_recv", "(", "self", ")", ":", "from", ".", "import", "mavutil", "start_time", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "<", "start_time", "+", "self", ".", "timeout", ":", "m", "=", "self", ".", "mav", ".", "recv_match", "(", "condition", "=", "'SERIAL_CONTROL.count!=0'", ",", "type", "=", "'SERIAL_CONTROL'", ",", "blocking", "=", "False", ",", "timeout", "=", "0", ")", "if", "m", "is", "not", "None", "and", "m", ".", "count", "!=", "0", ":", "break", "self", ".", "mav", ".", "mav", ".", "serial_control_send", "(", "self", ".", "port", ",", "mavutil", ".", "mavlink", ".", "SERIAL_CONTROL_FLAG_EXCLUSIVE", "|", "mavutil", ".", "mavlink", ".", "SERIAL_CONTROL_FLAG_RESPOND", ",", "0", ",", "0", ",", "0", ",", "[", "0", "]", "*", "70", ")", "m", "=", "self", ".", "mav", ".", "recv_match", "(", "condition", "=", "'SERIAL_CONTROL.count!=0'", ",", "type", "=", "'SERIAL_CONTROL'", ",", "blocking", "=", "True", ",", "timeout", "=", "0.01", ")", "if", "m", "is", "not", "None", "and", "m", ".", "count", "!=", "0", ":", "break", "if", "m", "is", "not", "None", ":", "if", "self", ".", "_debug", ">", "2", ":", "print", "(", "m", ")", "data", "=", "m", ".", "data", "[", ":", "m", ".", "count", "]", "self", ".", "buf", "+=", "''", ".", "join", "(", "str", "(", "chr", "(", "x", ")", ")", "for", "x", "in", "data", ")" ]
read some bytes into self.buf
[ "read", "some", "bytes", "into", "self", ".", "buf" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1715-L1738
235,293
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
MavlinkSerialPort.read
def read(self, n): '''read some bytes''' if len(self.buf) == 0: self._recv() if len(self.buf) > 0: if n > len(self.buf): n = len(self.buf) ret = self.buf[:n] self.buf = self.buf[n:] if self._debug >= 2: for b in ret: self.debug("read 0x%x" % ord(b), 2) return ret return ''
python
def read(self, n): '''read some bytes''' if len(self.buf) == 0: self._recv() if len(self.buf) > 0: if n > len(self.buf): n = len(self.buf) ret = self.buf[:n] self.buf = self.buf[n:] if self._debug >= 2: for b in ret: self.debug("read 0x%x" % ord(b), 2) return ret return ''
[ "def", "read", "(", "self", ",", "n", ")", ":", "if", "len", "(", "self", ".", "buf", ")", "==", "0", ":", "self", ".", "_recv", "(", ")", "if", "len", "(", "self", ".", "buf", ")", ">", "0", ":", "if", "n", ">", "len", "(", "self", ".", "buf", ")", ":", "n", "=", "len", "(", "self", ".", "buf", ")", "ret", "=", "self", ".", "buf", "[", ":", "n", "]", "self", ".", "buf", "=", "self", ".", "buf", "[", "n", ":", "]", "if", "self", ".", "_debug", ">=", "2", ":", "for", "b", "in", "ret", ":", "self", ".", "debug", "(", "\"read 0x%x\"", "%", "ord", "(", "b", ")", ",", "2", ")", "return", "ret", "return", "''" ]
read some bytes
[ "read", "some", "bytes" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1740-L1753
235,294
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
MavlinkSerialPort.flushInput
def flushInput(self): '''flush any pending input''' self.buf = '' saved_timeout = self.timeout self.timeout = 0.5 self._recv() self.timeout = saved_timeout self.buf = '' self.debug("flushInput")
python
def flushInput(self): '''flush any pending input''' self.buf = '' saved_timeout = self.timeout self.timeout = 0.5 self._recv() self.timeout = saved_timeout self.buf = '' self.debug("flushInput")
[ "def", "flushInput", "(", "self", ")", ":", "self", ".", "buf", "=", "''", "saved_timeout", "=", "self", ".", "timeout", "self", ".", "timeout", "=", "0.5", "self", ".", "_recv", "(", ")", "self", ".", "timeout", "=", "saved_timeout", "self", ".", "buf", "=", "''", "self", ".", "debug", "(", "\"flushInput\"", ")" ]
flush any pending input
[ "flush", "any", "pending", "input" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1755-L1763
235,295
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py
NSHModule.stop
def stop(self): '''stop nsh input''' self.mpstate.rl.set_prompt(self.status.flightmode + "> ") self.mpstate.functions.input_handler = None self.started = False # unlock the port mav = self.master.mav mav.serial_control_send(self.serial_settings.port, 0, 0, self.serial_settings.baudrate, 0, [0]*70)
python
def stop(self): '''stop nsh input''' self.mpstate.rl.set_prompt(self.status.flightmode + "> ") self.mpstate.functions.input_handler = None self.started = False # unlock the port mav = self.master.mav mav.serial_control_send(self.serial_settings.port, 0, 0, self.serial_settings.baudrate, 0, [0]*70)
[ "def", "stop", "(", "self", ")", ":", "self", ".", "mpstate", ".", "rl", ".", "set_prompt", "(", "self", ".", "status", ".", "flightmode", "+", "\"> \"", ")", "self", ".", "mpstate", ".", "functions", ".", "input_handler", "=", "None", "self", ".", "started", "=", "False", "# unlock the port", "mav", "=", "self", ".", "master", ".", "mav", "mav", ".", "serial_control_send", "(", "self", ".", "serial_settings", ".", "port", ",", "0", ",", "0", ",", "self", ".", "serial_settings", ".", "baudrate", ",", "0", ",", "[", "0", "]", "*", "70", ")" ]
stop nsh input
[ "stop", "nsh", "input" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py#L38-L48
235,296
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py
NSHModule.cmd_nsh
def cmd_nsh(self, args): '''nsh shell commands''' usage = "Usage: nsh <start|stop|set>" if len(args) < 1: print(usage) return if args[0] == "start": self.mpstate.functions.input_handler = self.send self.started = True self.mpstate.rl.set_prompt("") elif args[0] == "stop": self.stop() elif args[0] == "set": self.serial_settings.command(args[1:]) else: print(usage)
python
def cmd_nsh(self, args): '''nsh shell commands''' usage = "Usage: nsh <start|stop|set>" if len(args) < 1: print(usage) return if args[0] == "start": self.mpstate.functions.input_handler = self.send self.started = True self.mpstate.rl.set_prompt("") elif args[0] == "stop": self.stop() elif args[0] == "set": self.serial_settings.command(args[1:]) else: print(usage)
[ "def", "cmd_nsh", "(", "self", ",", "args", ")", ":", "usage", "=", "\"Usage: nsh <start|stop|set>\"", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "usage", ")", "return", "if", "args", "[", "0", "]", "==", "\"start\"", ":", "self", ".", "mpstate", ".", "functions", ".", "input_handler", "=", "self", ".", "send", "self", ".", "started", "=", "True", "self", ".", "mpstate", ".", "rl", ".", "set_prompt", "(", "\"\"", ")", "elif", "args", "[", "0", "]", "==", "\"stop\"", ":", "self", ".", "stop", "(", ")", "elif", "args", "[", "0", "]", "==", "\"set\"", ":", "self", ".", "serial_settings", ".", "command", "(", "args", "[", "1", ":", "]", ")", "else", ":", "print", "(", "usage", ")" ]
nsh shell commands
[ "nsh", "shell", "commands" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py#L91-L106
235,297
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py
WPModule.process_waypoint_request
def process_waypoint_request(self, m, master): '''process a waypoint request from the master''' if (not self.loading_waypoints or time.time() > self.loading_waypoint_lasttime + 10.0): self.loading_waypoints = False self.console.error("not loading waypoints") return if m.seq >= self.wploader.count(): self.console.error("Request for bad waypoint %u (max %u)" % (m.seq, self.wploader.count())) return wp = self.wploader.wp(m.seq) wp.target_system = self.target_system wp.target_component = self.target_component self.master.mav.send(self.wploader.wp(m.seq)) self.loading_waypoint_lasttime = time.time() self.console.writeln("Sent waypoint %u : %s" % (m.seq, self.wploader.wp(m.seq))) if m.seq == self.wploader.count() - 1: self.loading_waypoints = False self.console.writeln("Sent all %u waypoints" % self.wploader.count())
python
def process_waypoint_request(self, m, master): '''process a waypoint request from the master''' if (not self.loading_waypoints or time.time() > self.loading_waypoint_lasttime + 10.0): self.loading_waypoints = False self.console.error("not loading waypoints") return if m.seq >= self.wploader.count(): self.console.error("Request for bad waypoint %u (max %u)" % (m.seq, self.wploader.count())) return wp = self.wploader.wp(m.seq) wp.target_system = self.target_system wp.target_component = self.target_component self.master.mav.send(self.wploader.wp(m.seq)) self.loading_waypoint_lasttime = time.time() self.console.writeln("Sent waypoint %u : %s" % (m.seq, self.wploader.wp(m.seq))) if m.seq == self.wploader.count() - 1: self.loading_waypoints = False self.console.writeln("Sent all %u waypoints" % self.wploader.count())
[ "def", "process_waypoint_request", "(", "self", ",", "m", ",", "master", ")", ":", "if", "(", "not", "self", ".", "loading_waypoints", "or", "time", ".", "time", "(", ")", ">", "self", ".", "loading_waypoint_lasttime", "+", "10.0", ")", ":", "self", ".", "loading_waypoints", "=", "False", "self", ".", "console", ".", "error", "(", "\"not loading waypoints\"", ")", "return", "if", "m", ".", "seq", ">=", "self", ".", "wploader", ".", "count", "(", ")", ":", "self", ".", "console", ".", "error", "(", "\"Request for bad waypoint %u (max %u)\"", "%", "(", "m", ".", "seq", ",", "self", ".", "wploader", ".", "count", "(", ")", ")", ")", "return", "wp", "=", "self", ".", "wploader", ".", "wp", "(", "m", ".", "seq", ")", "wp", ".", "target_system", "=", "self", ".", "target_system", "wp", ".", "target_component", "=", "self", ".", "target_component", "self", ".", "master", ".", "mav", ".", "send", "(", "self", ".", "wploader", ".", "wp", "(", "m", ".", "seq", ")", ")", "self", ".", "loading_waypoint_lasttime", "=", "time", ".", "time", "(", ")", "self", ".", "console", ".", "writeln", "(", "\"Sent waypoint %u : %s\"", "%", "(", "m", ".", "seq", ",", "self", ".", "wploader", ".", "wp", "(", "m", ".", "seq", ")", ")", ")", "if", "m", ".", "seq", "==", "self", ".", "wploader", ".", "count", "(", ")", "-", "1", ":", "self", ".", "loading_waypoints", "=", "False", "self", ".", "console", ".", "writeln", "(", "\"Sent all %u waypoints\"", "%", "self", ".", "wploader", ".", "count", "(", ")", ")" ]
process a waypoint request from the master
[ "process", "a", "waypoint", "request", "from", "the", "master" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py#L120-L138
235,298
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py
WPModule.send_all_waypoints
def send_all_waypoints(self): '''send all waypoints to vehicle''' self.master.waypoint_clear_all_send() if self.wploader.count() == 0: return self.loading_waypoints = True self.loading_waypoint_lasttime = time.time() self.master.waypoint_count_send(self.wploader.count())
python
def send_all_waypoints(self): '''send all waypoints to vehicle''' self.master.waypoint_clear_all_send() if self.wploader.count() == 0: return self.loading_waypoints = True self.loading_waypoint_lasttime = time.time() self.master.waypoint_count_send(self.wploader.count())
[ "def", "send_all_waypoints", "(", "self", ")", ":", "self", ".", "master", ".", "waypoint_clear_all_send", "(", ")", "if", "self", ".", "wploader", ".", "count", "(", ")", "==", "0", ":", "return", "self", ".", "loading_waypoints", "=", "True", "self", ".", "loading_waypoint_lasttime", "=", "time", ".", "time", "(", ")", "self", ".", "master", ".", "waypoint_count_send", "(", "self", ".", "wploader", ".", "count", "(", ")", ")" ]
send all waypoints to vehicle
[ "send", "all", "waypoints", "to", "vehicle" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py#L140-L147
235,299
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py
WPModule.load_waypoints
def load_waypoints(self, filename): '''load waypoints from a file''' self.wploader.target_system = self.target_system self.wploader.target_component = self.target_component try: self.wploader.load(filename) except Exception as msg: print("Unable to load %s - %s" % (filename, msg)) return print("Loaded %u waypoints from %s" % (self.wploader.count(), filename)) self.send_all_waypoints()
python
def load_waypoints(self, filename): '''load waypoints from a file''' self.wploader.target_system = self.target_system self.wploader.target_component = self.target_component try: self.wploader.load(filename) except Exception as msg: print("Unable to load %s - %s" % (filename, msg)) return print("Loaded %u waypoints from %s" % (self.wploader.count(), filename)) self.send_all_waypoints()
[ "def", "load_waypoints", "(", "self", ",", "filename", ")", ":", "self", ".", "wploader", ".", "target_system", "=", "self", ".", "target_system", "self", ".", "wploader", ".", "target_component", "=", "self", ".", "target_component", "try", ":", "self", ".", "wploader", ".", "load", "(", "filename", ")", "except", "Exception", "as", "msg", ":", "print", "(", "\"Unable to load %s - %s\"", "%", "(", "filename", ",", "msg", ")", ")", "return", "print", "(", "\"Loaded %u waypoints from %s\"", "%", "(", "self", ".", "wploader", ".", "count", "(", ")", ",", "filename", ")", ")", "self", ".", "send_all_waypoints", "(", ")" ]
load waypoints from a file
[ "load", "waypoints", "from", "a", "file" ]
303b18992785b2fe802212f2d758a60873007f1f
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_wp.py#L149-L159