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 listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1 value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapFrame.follow | def follow(self, object):
'''follow an object on the map'''
state = self.state
(px,py) = state.panel.pixmapper(object.latlon)
ratio = 0.25
if (px > ratio*state.width and
px < (1.0-ratio)*state.width and
py > ratio*state.height and
py < (1.0-ratio)*state.height):
# we're in the mid part of the map already, don't move
return
if not state.follow:
# the user has disabled following
return
(lat, lon) = object.latlon
state.panel.re_center(state.width/2, state.height/2, lat, lon) | python | def follow(self, object):
'''follow an object on the map'''
state = self.state
(px,py) = state.panel.pixmapper(object.latlon)
ratio = 0.25
if (px > ratio*state.width and
px < (1.0-ratio)*state.width and
py > ratio*state.height and
py < (1.0-ratio)*state.height):
# we're in the mid part of the map already, don't move
return
if not state.follow:
# the user has disabled following
return
(lat, lon) = object.latlon
state.panel.re_center(state.width/2, state.height/2, lat, lon) | [
"def",
"follow",
"(",
"self",
",",
"object",
")",
":",
"state",
"=",
"self",
".",
"state",
"(",
"px",
",",
"py",
")",
"=",
"state",
".",
"panel",
".",
"pixmapper",
"(",
"object",
".",
"latlon",
")",
"ratio",
"=",
"0.25",
"if",
"(",
"px",
">",
"... | follow an object on the map | [
"follow",
"an",
"object",
"on",
"the",
"map"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L101-L118 | train | 230,000 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapFrame.add_object | def add_object(self, obj):
'''add an object to a later'''
state = self.state
if not obj.layer in state.layers:
# its a new layer
state.layers[obj.layer] = {}
state.layers[obj.layer][obj.key] = obj
state.need_redraw = True | python | def add_object(self, obj):
'''add an object to a later'''
state = self.state
if not obj.layer in state.layers:
# its a new layer
state.layers[obj.layer] = {}
state.layers[obj.layer][obj.key] = obj
state.need_redraw = True | [
"def",
"add_object",
"(",
"self",
",",
"obj",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"not",
"obj",
".",
"layer",
"in",
"state",
".",
"layers",
":",
"# its a new layer",
"state",
".",
"layers",
"[",
"obj",
".",
"layer",
"]",
"=",
"{",
"... | add an object to a later | [
"add",
"an",
"object",
"to",
"a",
"later"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L120-L127 | train | 230,001 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapFrame.remove_object | def remove_object(self, key):
'''remove an object by key from all layers'''
state = self.state
for layer in state.layers:
state.layers[layer].pop(key, None)
state.need_redraw = True | python | def remove_object(self, key):
'''remove an object by key from all layers'''
state = self.state
for layer in state.layers:
state.layers[layer].pop(key, None)
state.need_redraw = True | [
"def",
"remove_object",
"(",
"self",
",",
"key",
")",
":",
"state",
"=",
"self",
".",
"state",
"for",
"layer",
"in",
"state",
".",
"layers",
":",
"state",
".",
"layers",
"[",
"layer",
"]",
".",
"pop",
"(",
"key",
",",
"None",
")",
"state",
".",
"... | remove an object by key from all layers | [
"remove",
"an",
"object",
"by",
"key",
"from",
"all",
"layers"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L129-L134 | train | 230,002 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.current_view | def current_view(self):
'''return a tuple representing the current view'''
state = self.state
return (state.lat, state.lon, state.width, state.height,
state.ground_width, state.mt.tiles_pending()) | python | def current_view(self):
'''return a tuple representing the current view'''
state = self.state
return (state.lat, state.lon, state.width, state.height,
state.ground_width, state.mt.tiles_pending()) | [
"def",
"current_view",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"state",
"return",
"(",
"state",
".",
"lat",
",",
"state",
".",
"lon",
",",
"state",
".",
"width",
",",
"state",
".",
"height",
",",
"state",
".",
"ground_width",
",",
"state",
... | return a tuple representing the current view | [
"return",
"a",
"tuple",
"representing",
"the",
"current",
"view"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L276-L280 | train | 230,003 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.coordinates | def coordinates(self, x, y):
'''return coordinates of a pixel in the map'''
state = self.state
return state.mt.coord_from_area(x, y, state.lat, state.lon, state.width, state.ground_width) | python | def coordinates(self, x, y):
'''return coordinates of a pixel in the map'''
state = self.state
return state.mt.coord_from_area(x, y, state.lat, state.lon, state.width, state.ground_width) | [
"def",
"coordinates",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"state",
"=",
"self",
".",
"state",
"return",
"state",
".",
"mt",
".",
"coord_from_area",
"(",
"x",
",",
"y",
",",
"state",
".",
"lat",
",",
"state",
".",
"lon",
",",
"state",
".",
... | return coordinates of a pixel in the map | [
"return",
"coordinates",
"of",
"a",
"pixel",
"in",
"the",
"map"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L282-L285 | train | 230,004 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.re_center | def re_center(self, x, y, lat, lon):
'''re-center view for pixel x,y'''
state = self.state
if lat is None or lon is None:
return
(lat2,lon2) = self.coordinates(x, y)
distance = mp_util.gps_distance(lat2, lon2, lat, lon)
bearing = mp_util.gps_bearing(lat2, lon2, lat, lon)
(state.lat, state.lon) = mp_util.gps_newpos(state.lat, state.lon, bearing, distance) | python | def re_center(self, x, y, lat, lon):
'''re-center view for pixel x,y'''
state = self.state
if lat is None or lon is None:
return
(lat2,lon2) = self.coordinates(x, y)
distance = mp_util.gps_distance(lat2, lon2, lat, lon)
bearing = mp_util.gps_bearing(lat2, lon2, lat, lon)
(state.lat, state.lon) = mp_util.gps_newpos(state.lat, state.lon, bearing, distance) | [
"def",
"re_center",
"(",
"self",
",",
"x",
",",
"y",
",",
"lat",
",",
"lon",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"lat",
"is",
"None",
"or",
"lon",
"is",
"None",
":",
"return",
"(",
"lat2",
",",
"lon2",
")",
"=",
"self",
".",
"... | re-center view for pixel x,y | [
"re",
"-",
"center",
"view",
"for",
"pixel",
"x",
"y"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L287-L295 | train | 230,005 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.change_zoom | def change_zoom(self, zoom):
'''zoom in or out by zoom factor, keeping centered'''
state = self.state
if self.mouse_pos:
(x,y) = (self.mouse_pos.x, self.mouse_pos.y)
else:
(x,y) = (state.width/2, state.height/2)
(lat,lon) = self.coordinates(x, y)
state.ground_width *= zoom
# limit ground_width to sane values
state.ground_width = max(state.ground_width, 20)
state.ground_width = min(state.ground_width, 20000000)
self.re_center(x,y, lat, lon) | python | def change_zoom(self, zoom):
'''zoom in or out by zoom factor, keeping centered'''
state = self.state
if self.mouse_pos:
(x,y) = (self.mouse_pos.x, self.mouse_pos.y)
else:
(x,y) = (state.width/2, state.height/2)
(lat,lon) = self.coordinates(x, y)
state.ground_width *= zoom
# limit ground_width to sane values
state.ground_width = max(state.ground_width, 20)
state.ground_width = min(state.ground_width, 20000000)
self.re_center(x,y, lat, lon) | [
"def",
"change_zoom",
"(",
"self",
",",
"zoom",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"self",
".",
"mouse_pos",
":",
"(",
"x",
",",
"y",
")",
"=",
"(",
"self",
".",
"mouse_pos",
".",
"x",
",",
"self",
".",
"mouse_pos",
".",
"y",
"... | zoom in or out by zoom factor, keeping centered | [
"zoom",
"in",
"or",
"out",
"by",
"zoom",
"factor",
"keeping",
"centered"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L297-L309 | train | 230,006 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.enter_position | def enter_position(self):
'''enter new position'''
state = self.state
dlg = wx.TextEntryDialog(self, 'Enter new position', 'Position')
dlg.SetValue("%f %f" % (state.lat, state.lon))
if dlg.ShowModal() == wx.ID_OK:
latlon = dlg.GetValue().split()
dlg.Destroy()
state.lat = float(latlon[0])
state.lon = float(latlon[1])
self.re_center(state.width/2,state.height/2, state.lat, state.lon)
self.redraw_map() | python | def enter_position(self):
'''enter new position'''
state = self.state
dlg = wx.TextEntryDialog(self, 'Enter new position', 'Position')
dlg.SetValue("%f %f" % (state.lat, state.lon))
if dlg.ShowModal() == wx.ID_OK:
latlon = dlg.GetValue().split()
dlg.Destroy()
state.lat = float(latlon[0])
state.lon = float(latlon[1])
self.re_center(state.width/2,state.height/2, state.lat, state.lon)
self.redraw_map() | [
"def",
"enter_position",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"state",
"dlg",
"=",
"wx",
".",
"TextEntryDialog",
"(",
"self",
",",
"'Enter new position'",
",",
"'Position'",
")",
"dlg",
".",
"SetValue",
"(",
"\"%f %f\"",
"%",
"(",
"state",
"... | enter new position | [
"enter",
"new",
"position"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L311-L322 | train | 230,007 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.update_position | def update_position(self):
'''update position text'''
state = self.state
pos = self.mouse_pos
newtext = ''
alt = 0
if pos is not None:
(lat,lon) = self.coordinates(pos.x, pos.y)
newtext += 'Cursor: %f %f (%s)' % (lat, lon, mp_util.latlon_to_grid((lat, lon)))
if state.elevation:
alt = self.ElevationMap.GetElevation(lat, lon)
if alt is not None:
newtext += ' %.1fm' % alt
state.mt.set_download(state.download)
pending = 0
if state.download:
pending = state.mt.tiles_pending()
if pending:
newtext += ' Map Downloading %u ' % pending
if alt == -1:
newtext += ' SRTM Downloading '
newtext += '\n'
if self.click_pos is not None:
newtext += 'Click: %f %f (%s %s) (%s)' % (self.click_pos[0], self.click_pos[1],
mp_util.degrees_to_dms(self.click_pos[0]),
mp_util.degrees_to_dms(self.click_pos[1]),
mp_util.latlon_to_grid(self.click_pos))
if self.last_click_pos is not None:
distance = mp_util.gps_distance(self.last_click_pos[0], self.last_click_pos[1],
self.click_pos[0], self.click_pos[1])
bearing = mp_util.gps_bearing(self.last_click_pos[0], self.last_click_pos[1],
self.click_pos[0], self.click_pos[1])
newtext += ' Distance: %.1fm Bearing %.1f' % (distance, bearing)
if newtext != state.oldtext:
self.position.Clear()
self.position.WriteText(newtext)
state.oldtext = newtext | python | def update_position(self):
'''update position text'''
state = self.state
pos = self.mouse_pos
newtext = ''
alt = 0
if pos is not None:
(lat,lon) = self.coordinates(pos.x, pos.y)
newtext += 'Cursor: %f %f (%s)' % (lat, lon, mp_util.latlon_to_grid((lat, lon)))
if state.elevation:
alt = self.ElevationMap.GetElevation(lat, lon)
if alt is not None:
newtext += ' %.1fm' % alt
state.mt.set_download(state.download)
pending = 0
if state.download:
pending = state.mt.tiles_pending()
if pending:
newtext += ' Map Downloading %u ' % pending
if alt == -1:
newtext += ' SRTM Downloading '
newtext += '\n'
if self.click_pos is not None:
newtext += 'Click: %f %f (%s %s) (%s)' % (self.click_pos[0], self.click_pos[1],
mp_util.degrees_to_dms(self.click_pos[0]),
mp_util.degrees_to_dms(self.click_pos[1]),
mp_util.latlon_to_grid(self.click_pos))
if self.last_click_pos is not None:
distance = mp_util.gps_distance(self.last_click_pos[0], self.last_click_pos[1],
self.click_pos[0], self.click_pos[1])
bearing = mp_util.gps_bearing(self.last_click_pos[0], self.last_click_pos[1],
self.click_pos[0], self.click_pos[1])
newtext += ' Distance: %.1fm Bearing %.1f' % (distance, bearing)
if newtext != state.oldtext:
self.position.Clear()
self.position.WriteText(newtext)
state.oldtext = newtext | [
"def",
"update_position",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"state",
"pos",
"=",
"self",
".",
"mouse_pos",
"newtext",
"=",
"''",
"alt",
"=",
"0",
"if",
"pos",
"is",
"not",
"None",
":",
"(",
"lat",
",",
"lon",
")",
"=",
"self",
"."... | update position text | [
"update",
"position",
"text"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L324-L360 | train | 230,008 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.selected_objects | def selected_objects(self, pos):
'''return a list of matching objects for a position'''
state = self.state
selected = []
(px, py) = pos
for layer in state.layers:
for key in state.layers[layer]:
obj = state.layers[layer][key]
distance = obj.clicked(px, py)
if distance is not None:
selected.append(SlipObjectSelection(key, distance, layer, extra_info=obj.selection_info()))
selected.sort(key=lambda c: c.distance)
return selected | python | def selected_objects(self, pos):
'''return a list of matching objects for a position'''
state = self.state
selected = []
(px, py) = pos
for layer in state.layers:
for key in state.layers[layer]:
obj = state.layers[layer][key]
distance = obj.clicked(px, py)
if distance is not None:
selected.append(SlipObjectSelection(key, distance, layer, extra_info=obj.selection_info()))
selected.sort(key=lambda c: c.distance)
return selected | [
"def",
"selected_objects",
"(",
"self",
",",
"pos",
")",
":",
"state",
"=",
"self",
".",
"state",
"selected",
"=",
"[",
"]",
"(",
"px",
",",
"py",
")",
"=",
"pos",
"for",
"layer",
"in",
"state",
".",
"layers",
":",
"for",
"key",
"in",
"state",
".... | return a list of matching objects for a position | [
"return",
"a",
"list",
"of",
"matching",
"objects",
"for",
"a",
"position"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L458-L470 | train | 230,009 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.show_default_popup | def show_default_popup(self, pos):
'''show default popup menu'''
state = self.state
if state.default_popup.popup is not None:
wx_menu = state.default_popup.popup.wx_menu()
state.frame.PopupMenu(wx_menu, pos) | python | def show_default_popup(self, pos):
'''show default popup menu'''
state = self.state
if state.default_popup.popup is not None:
wx_menu = state.default_popup.popup.wx_menu()
state.frame.PopupMenu(wx_menu, pos) | [
"def",
"show_default_popup",
"(",
"self",
",",
"pos",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"state",
".",
"default_popup",
".",
"popup",
"is",
"not",
"None",
":",
"wx_menu",
"=",
"state",
".",
"default_popup",
".",
"popup",
".",
"wx_menu",
... | show default popup menu | [
"show",
"default",
"popup",
"menu"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L485-L490 | train | 230,010 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.clear_thumbnails | def clear_thumbnails(self):
'''clear all thumbnails from the map'''
state = self.state
for l in state.layers:
keys = state.layers[l].keys()[:]
for key in keys:
if (isinstance(state.layers[l][key], SlipThumbnail)
and not isinstance(state.layers[l][key], SlipIcon)):
state.layers[l].pop(key) | python | def clear_thumbnails(self):
'''clear all thumbnails from the map'''
state = self.state
for l in state.layers:
keys = state.layers[l].keys()[:]
for key in keys:
if (isinstance(state.layers[l][key], SlipThumbnail)
and not isinstance(state.layers[l][key], SlipIcon)):
state.layers[l].pop(key) | [
"def",
"clear_thumbnails",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"state",
"for",
"l",
"in",
"state",
".",
"layers",
":",
"keys",
"=",
"state",
".",
"layers",
"[",
"l",
"]",
".",
"keys",
"(",
")",
"[",
":",
"]",
"for",
"key",
"in",
"... | clear all thumbnails from the map | [
"clear",
"all",
"thumbnails",
"from",
"the",
"map"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L545-L553 | train | 230,011 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py | MPSlipMapPanel.on_key_down | def on_key_down(self, event):
'''handle keyboard input'''
state = self.state
# send all key events to the parent
if self.mouse_pos:
latlon = self.coordinates(self.mouse_pos.x, self.mouse_pos.y)
selected = self.selected_objects(self.mouse_pos)
state.event_queue.put(SlipKeyEvent(latlon, event, selected))
c = event.GetUniChar()
if c == ord('+') or (c == ord('=') and event.ShiftDown()):
self.change_zoom(1.0/1.2)
event.Skip()
elif c == ord('-'):
self.change_zoom(1.2)
event.Skip()
elif c == ord('G'):
self.enter_position()
event.Skip()
elif c == ord('C'):
self.clear_thumbnails()
event.Skip() | python | def on_key_down(self, event):
'''handle keyboard input'''
state = self.state
# send all key events to the parent
if self.mouse_pos:
latlon = self.coordinates(self.mouse_pos.x, self.mouse_pos.y)
selected = self.selected_objects(self.mouse_pos)
state.event_queue.put(SlipKeyEvent(latlon, event, selected))
c = event.GetUniChar()
if c == ord('+') or (c == ord('=') and event.ShiftDown()):
self.change_zoom(1.0/1.2)
event.Skip()
elif c == ord('-'):
self.change_zoom(1.2)
event.Skip()
elif c == ord('G'):
self.enter_position()
event.Skip()
elif c == ord('C'):
self.clear_thumbnails()
event.Skip() | [
"def",
"on_key_down",
"(",
"self",
",",
"event",
")",
":",
"state",
"=",
"self",
".",
"state",
"# send all key events to the parent",
"if",
"self",
".",
"mouse_pos",
":",
"latlon",
"=",
"self",
".",
"coordinates",
"(",
"self",
".",
"mouse_pos",
".",
"x",
"... | handle keyboard input | [
"handle",
"keyboard",
"input"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L555-L577 | train | 230,012 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavexpression.py | evaluate_expression | def evaluate_expression(expression, vars):
'''evaluation an expression'''
try:
v = eval(expression, globals(), vars)
except NameError:
return None
except ZeroDivisionError:
return None
return v | python | def evaluate_expression(expression, vars):
'''evaluation an expression'''
try:
v = eval(expression, globals(), vars)
except NameError:
return None
except ZeroDivisionError:
return None
return v | [
"def",
"evaluate_expression",
"(",
"expression",
",",
"vars",
")",
":",
"try",
":",
"v",
"=",
"eval",
"(",
"expression",
",",
"globals",
"(",
")",
",",
"vars",
")",
"except",
"NameError",
":",
"return",
"None",
"except",
"ZeroDivisionError",
":",
"return",... | evaluation an expression | [
"evaluation",
"an",
"expression"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavexpression.py#L26-L34 | train | 230,013 |
JdeRobot/base | src/tools/colorTuner_py/QDarkStyleSheet/qdarkstyle/compile_qrc.py | compile_all | def compile_all():
"""
Compile style.qrc using rcc, pyside-rcc and pyrcc4
"""
# print("Compiling for Qt: style.qrc -> style.rcc")
# os.system("rcc style.qrc -o style.rcc")
print("Compiling for PyQt4: style.qrc -> pyqt_style_rc.py")
os.system("pyrcc4 -py3 style.qrc -o pyqt_style_rc.py")
print("Compiling for PyQt5: style.qrc -> pyqt5_style_rc.py")
os.system("pyrcc5 style.qrc -o pyqt5_style_rc.py")
print("Compiling for PySide: style.qrc -> pyside_style_rc.py")
os.system("pyside-rcc -py3 style.qrc -o pyside_style_rc.py") | python | def compile_all():
"""
Compile style.qrc using rcc, pyside-rcc and pyrcc4
"""
# print("Compiling for Qt: style.qrc -> style.rcc")
# os.system("rcc style.qrc -o style.rcc")
print("Compiling for PyQt4: style.qrc -> pyqt_style_rc.py")
os.system("pyrcc4 -py3 style.qrc -o pyqt_style_rc.py")
print("Compiling for PyQt5: style.qrc -> pyqt5_style_rc.py")
os.system("pyrcc5 style.qrc -o pyqt5_style_rc.py")
print("Compiling for PySide: style.qrc -> pyside_style_rc.py")
os.system("pyside-rcc -py3 style.qrc -o pyside_style_rc.py") | [
"def",
"compile_all",
"(",
")",
":",
"# print(\"Compiling for Qt: style.qrc -> style.rcc\")",
"# os.system(\"rcc style.qrc -o style.rcc\")",
"print",
"(",
"\"Compiling for PyQt4: style.qrc -> pyqt_style_rc.py\"",
")",
"os",
".",
"system",
"(",
"\"pyrcc4 -py3 style.qrc -o pyqt_style_rc.... | Compile style.qrc using rcc, pyside-rcc and pyrcc4 | [
"Compile",
"style",
".",
"qrc",
"using",
"rcc",
"pyside",
"-",
"rcc",
"and",
"pyrcc4"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/tools/colorTuner_py/QDarkStyleSheet/qdarkstyle/compile_qrc.py#L39-L50 | train | 230,014 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | null_term | def null_term(str):
'''null terminate a string'''
idx = str.find("\0")
if idx != -1:
str = str[:idx]
return str | python | def null_term(str):
'''null terminate a string'''
idx = str.find("\0")
if idx != -1:
str = str[:idx]
return str | [
"def",
"null_term",
"(",
"str",
")",
":",
"idx",
"=",
"str",
".",
"find",
"(",
"\"\\0\"",
")",
"if",
"idx",
"!=",
"-",
"1",
":",
"str",
"=",
"str",
"[",
":",
"idx",
"]",
"return",
"str"
] | null terminate a string | [
"null",
"terminate",
"a",
"string"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L71-L76 | train | 230,015 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader_is_text_log | def DFReader_is_text_log(filename):
'''return True if a file appears to be a valid text log'''
f = open(filename)
ret = (f.read(8000).find('FMT, ') != -1)
f.close()
return ret | python | def DFReader_is_text_log(filename):
'''return True if a file appears to be a valid text log'''
f = open(filename)
ret = (f.read(8000).find('FMT, ') != -1)
f.close()
return ret | [
"def",
"DFReader_is_text_log",
"(",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
")",
"ret",
"=",
"(",
"f",
".",
"read",
"(",
"8000",
")",
".",
"find",
"(",
"'FMT, '",
")",
"!=",
"-",
"1",
")",
"f",
".",
"close",
"(",
")",
"return",
... | return True if a file appears to be a valid text log | [
"return",
"True",
"if",
"a",
"file",
"appears",
"to",
"be",
"a",
"valid",
"text",
"log"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L594-L599 | train | 230,016 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFMessage.get_msgbuf | def get_msgbuf(self):
'''create a binary message buffer for a message'''
values = []
for i in range(len(self.fmt.columns)):
if i >= len(self.fmt.msg_mults):
continue
mul = self.fmt.msg_mults[i]
name = self.fmt.columns[i]
if name == 'Mode' and 'ModeNum' in self.fmt.columns:
name = 'ModeNum'
v = self.__getattr__(name)
if mul is not None:
v /= mul
values.append(v)
return struct.pack("BBB", 0xA3, 0x95, self.fmt.type) + struct.pack(self.fmt.msg_struct, *values) | python | def get_msgbuf(self):
'''create a binary message buffer for a message'''
values = []
for i in range(len(self.fmt.columns)):
if i >= len(self.fmt.msg_mults):
continue
mul = self.fmt.msg_mults[i]
name = self.fmt.columns[i]
if name == 'Mode' and 'ModeNum' in self.fmt.columns:
name = 'ModeNum'
v = self.__getattr__(name)
if mul is not None:
v /= mul
values.append(v)
return struct.pack("BBB", 0xA3, 0x95, self.fmt.type) + struct.pack(self.fmt.msg_struct, *values) | [
"def",
"get_msgbuf",
"(",
"self",
")",
":",
"values",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"fmt",
".",
"columns",
")",
")",
":",
"if",
"i",
">=",
"len",
"(",
"self",
".",
"fmt",
".",
"msg_mults",
")",
":",
"... | create a binary message buffer for a message | [
"create",
"a",
"binary",
"message",
"buffer",
"for",
"a",
"message"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L121-L135 | train | 230,017 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReaderClock_usec.find_time_base | def find_time_base(self, gps, first_us_stamp):
'''work out time basis for the log - even newer style'''
t = self._gpsTimeToTime(gps.GWk, gps.GMS)
self.set_timebase(t - gps.TimeUS*0.000001)
# this ensures FMT messages get appropriate timestamp:
self.timestamp = self.timebase + first_us_stamp*0.000001 | python | def find_time_base(self, gps, first_us_stamp):
'''work out time basis for the log - even newer style'''
t = self._gpsTimeToTime(gps.GWk, gps.GMS)
self.set_timebase(t - gps.TimeUS*0.000001)
# this ensures FMT messages get appropriate timestamp:
self.timestamp = self.timebase + first_us_stamp*0.000001 | [
"def",
"find_time_base",
"(",
"self",
",",
"gps",
",",
"first_us_stamp",
")",
":",
"t",
"=",
"self",
".",
"_gpsTimeToTime",
"(",
"gps",
".",
"GWk",
",",
"gps",
".",
"GMS",
")",
"self",
".",
"set_timebase",
"(",
"t",
"-",
"gps",
".",
"TimeUS",
"*",
... | work out time basis for the log - even newer style | [
"work",
"out",
"time",
"basis",
"for",
"the",
"log",
"-",
"even",
"newer",
"style"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L166-L171 | train | 230,018 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReaderClock_msec.find_time_base | def find_time_base(self, gps, first_ms_stamp):
'''work out time basis for the log - new style'''
t = self._gpsTimeToTime(gps.Week, gps.TimeMS)
self.set_timebase(t - gps.T*0.001)
self.timestamp = self.timebase + first_ms_stamp*0.001 | python | def find_time_base(self, gps, first_ms_stamp):
'''work out time basis for the log - new style'''
t = self._gpsTimeToTime(gps.Week, gps.TimeMS)
self.set_timebase(t - gps.T*0.001)
self.timestamp = self.timebase + first_ms_stamp*0.001 | [
"def",
"find_time_base",
"(",
"self",
",",
"gps",
",",
"first_ms_stamp",
")",
":",
"t",
"=",
"self",
".",
"_gpsTimeToTime",
"(",
"gps",
".",
"Week",
",",
"gps",
".",
"TimeMS",
")",
"self",
".",
"set_timebase",
"(",
"t",
"-",
"gps",
".",
"T",
"*",
"... | work out time basis for the log - new style | [
"work",
"out",
"time",
"basis",
"for",
"the",
"log",
"-",
"new",
"style"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L204-L208 | train | 230,019 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReaderClock_px4.find_time_base | def find_time_base(self, gps):
'''work out time basis for the log - PX4 native'''
t = gps.GPSTime * 1.0e-6
self.timebase = t - self.px4_timebase | python | def find_time_base(self, gps):
'''work out time basis for the log - PX4 native'''
t = gps.GPSTime * 1.0e-6
self.timebase = t - self.px4_timebase | [
"def",
"find_time_base",
"(",
"self",
",",
"gps",
")",
":",
"t",
"=",
"gps",
".",
"GPSTime",
"*",
"1.0e-6",
"self",
".",
"timebase",
"=",
"t",
"-",
"self",
".",
"px4_timebase"
] | work out time basis for the log - PX4 native | [
"work",
"out",
"time",
"basis",
"for",
"the",
"log",
"-",
"PX4",
"native"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L225-L228 | train | 230,020 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReaderClock_gps_interpolated.gps_message_arrived | def gps_message_arrived(self, m):
'''adjust time base from GPS message'''
# msec-style GPS message?
gps_week = getattr(m, 'Week', None)
gps_timems = getattr(m, 'TimeMS', None)
if gps_week is None:
# usec-style GPS message?
gps_week = getattr(m, 'GWk', None)
gps_timems = getattr(m, 'GMS', None)
if gps_week is None:
if getattr(m, 'GPSTime', None) is not None:
# PX4-style timestamp; we've only been called
# because we were speculatively created in case no
# better clock was found.
return;
t = self._gpsTimeToTime(gps_week, gps_timems)
deltat = t - self.timebase
if deltat <= 0:
return
for type in self.counts_since_gps:
rate = self.counts_since_gps[type] / deltat
if rate > self.msg_rate.get(type, 0):
self.msg_rate[type] = rate
self.msg_rate['IMU'] = 50.0
self.timebase = t
self.counts_since_gps = {} | python | def gps_message_arrived(self, m):
'''adjust time base from GPS message'''
# msec-style GPS message?
gps_week = getattr(m, 'Week', None)
gps_timems = getattr(m, 'TimeMS', None)
if gps_week is None:
# usec-style GPS message?
gps_week = getattr(m, 'GWk', None)
gps_timems = getattr(m, 'GMS', None)
if gps_week is None:
if getattr(m, 'GPSTime', None) is not None:
# PX4-style timestamp; we've only been called
# because we were speculatively created in case no
# better clock was found.
return;
t = self._gpsTimeToTime(gps_week, gps_timems)
deltat = t - self.timebase
if deltat <= 0:
return
for type in self.counts_since_gps:
rate = self.counts_since_gps[type] / deltat
if rate > self.msg_rate.get(type, 0):
self.msg_rate[type] = rate
self.msg_rate['IMU'] = 50.0
self.timebase = t
self.counts_since_gps = {} | [
"def",
"gps_message_arrived",
"(",
"self",
",",
"m",
")",
":",
"# msec-style GPS message?",
"gps_week",
"=",
"getattr",
"(",
"m",
",",
"'Week'",
",",
"None",
")",
"gps_timems",
"=",
"getattr",
"(",
"m",
",",
"'TimeMS'",
",",
"None",
")",
"if",
"gps_week",
... | adjust time base from GPS message | [
"adjust",
"time",
"base",
"from",
"GPS",
"message"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L270-L298 | train | 230,021 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader._rewind | def _rewind(self):
'''reset state on rewind'''
self.messages = { 'MAV' : self }
self.flightmode = "UNKNOWN"
self.percent = 0
if self.clock:
self.clock.rewind_event() | python | def _rewind(self):
'''reset state on rewind'''
self.messages = { 'MAV' : self }
self.flightmode = "UNKNOWN"
self.percent = 0
if self.clock:
self.clock.rewind_event() | [
"def",
"_rewind",
"(",
"self",
")",
":",
"self",
".",
"messages",
"=",
"{",
"'MAV'",
":",
"self",
"}",
"self",
".",
"flightmode",
"=",
"\"UNKNOWN\"",
"self",
".",
"percent",
"=",
"0",
"if",
"self",
".",
"clock",
":",
"self",
".",
"clock",
".",
"rew... | reset state on rewind | [
"reset",
"state",
"on",
"rewind"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L318-L324 | train | 230,022 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader.init_clock | def init_clock(self):
'''work out time basis for the log'''
self._rewind()
# speculatively create a gps clock in case we don't find anything
# better
gps_clock = DFReaderClock_gps_interpolated()
self.clock = gps_clock
px4_msg_time = None
px4_msg_gps = None
gps_interp_msg_gps1 = None
gps_interp_msg_gps2 = None
first_us_stamp = None
first_ms_stamp = None
have_good_clock = False
while True:
m = self.recv_msg()
if m is None:
break;
type = m.get_type()
if first_us_stamp is None:
first_us_stamp = getattr(m, "TimeUS", None);
if first_ms_stamp is None and (type != 'GPS' and type != 'GPS2'):
# Older GPS messages use TimeMS for msecs past start
# of gps week
first_ms_stamp = getattr(m, "TimeMS", None);
if type == 'GPS' or type == 'GPS2':
if getattr(m, "TimeUS", 0) != 0 and \
getattr(m, "GWk", 0) != 0: # everything-usec-timestamped
self.init_clock_usec()
if not self._zero_time_base:
self.clock.find_time_base(m, first_us_stamp)
have_good_clock = True
break
if getattr(m, "T", 0) != 0 and \
getattr(m, "Week", 0) != 0: # GPS is msec-timestamped
if first_ms_stamp is None:
first_ms_stamp = m.T
self.init_clock_msec()
if not self._zero_time_base:
self.clock.find_time_base(m, first_ms_stamp)
have_good_clock = True
break
if getattr(m, "GPSTime", 0) != 0: # px4-style-only
px4_msg_gps = m
if getattr(m, "Week", 0) != 0:
if gps_interp_msg_gps1 is not None and \
(gps_interp_msg_gps1.TimeMS != m.TimeMS or \
gps_interp_msg_gps1.Week != m.Week):
# we've received two distinct, non-zero GPS
# packets without finding a decent clock to
# use; fall back to interpolation. Q: should
# we wait a few more messages befoe doing
# this?
self.init_clock_gps_interpolated(gps_clock)
have_good_clock = True
break
gps_interp_msg_gps1 = m
elif type == 'TIME':
'''only px4-style logs use TIME'''
if getattr(m, "StartTime", None) != None:
px4_msg_time = m;
if px4_msg_time is not None and px4_msg_gps is not None:
self.init_clock_px4(px4_msg_time, px4_msg_gps)
have_good_clock = True
break
# print("clock is " + str(self.clock))
if not have_good_clock:
# we failed to find any GPS messages to set a time
# base for usec and msec clocks. Also, not a
# PX4-style log
if first_us_stamp is not None:
self.init_clock_usec()
elif first_ms_stamp is not None:
self.init_clock_msec()
self._rewind()
return | python | def init_clock(self):
'''work out time basis for the log'''
self._rewind()
# speculatively create a gps clock in case we don't find anything
# better
gps_clock = DFReaderClock_gps_interpolated()
self.clock = gps_clock
px4_msg_time = None
px4_msg_gps = None
gps_interp_msg_gps1 = None
gps_interp_msg_gps2 = None
first_us_stamp = None
first_ms_stamp = None
have_good_clock = False
while True:
m = self.recv_msg()
if m is None:
break;
type = m.get_type()
if first_us_stamp is None:
first_us_stamp = getattr(m, "TimeUS", None);
if first_ms_stamp is None and (type != 'GPS' and type != 'GPS2'):
# Older GPS messages use TimeMS for msecs past start
# of gps week
first_ms_stamp = getattr(m, "TimeMS", None);
if type == 'GPS' or type == 'GPS2':
if getattr(m, "TimeUS", 0) != 0 and \
getattr(m, "GWk", 0) != 0: # everything-usec-timestamped
self.init_clock_usec()
if not self._zero_time_base:
self.clock.find_time_base(m, first_us_stamp)
have_good_clock = True
break
if getattr(m, "T", 0) != 0 and \
getattr(m, "Week", 0) != 0: # GPS is msec-timestamped
if first_ms_stamp is None:
first_ms_stamp = m.T
self.init_clock_msec()
if not self._zero_time_base:
self.clock.find_time_base(m, first_ms_stamp)
have_good_clock = True
break
if getattr(m, "GPSTime", 0) != 0: # px4-style-only
px4_msg_gps = m
if getattr(m, "Week", 0) != 0:
if gps_interp_msg_gps1 is not None and \
(gps_interp_msg_gps1.TimeMS != m.TimeMS or \
gps_interp_msg_gps1.Week != m.Week):
# we've received two distinct, non-zero GPS
# packets without finding a decent clock to
# use; fall back to interpolation. Q: should
# we wait a few more messages befoe doing
# this?
self.init_clock_gps_interpolated(gps_clock)
have_good_clock = True
break
gps_interp_msg_gps1 = m
elif type == 'TIME':
'''only px4-style logs use TIME'''
if getattr(m, "StartTime", None) != None:
px4_msg_time = m;
if px4_msg_time is not None and px4_msg_gps is not None:
self.init_clock_px4(px4_msg_time, px4_msg_gps)
have_good_clock = True
break
# print("clock is " + str(self.clock))
if not have_good_clock:
# we failed to find any GPS messages to set a time
# base for usec and msec clocks. Also, not a
# PX4-style log
if first_us_stamp is not None:
self.init_clock_usec()
elif first_ms_stamp is not None:
self.init_clock_msec()
self._rewind()
return | [
"def",
"init_clock",
"(",
"self",
")",
":",
"self",
".",
"_rewind",
"(",
")",
"# speculatively create a gps clock in case we don't find anything",
"# better",
"gps_clock",
"=",
"DFReaderClock_gps_interpolated",
"(",
")",
"self",
".",
"clock",
"=",
"gps_clock",
"px4_msg_... | work out time basis for the log | [
"work",
"out",
"time",
"basis",
"for",
"the",
"log"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L343-L431 | train | 230,023 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader._set_time | def _set_time(self, m):
'''set time for a message'''
# really just left here for profiling
m._timestamp = self.timestamp
if len(m._fieldnames) > 0 and self.clock is not None:
self.clock.set_message_timestamp(m) | python | def _set_time(self, m):
'''set time for a message'''
# really just left here for profiling
m._timestamp = self.timestamp
if len(m._fieldnames) > 0 and self.clock is not None:
self.clock.set_message_timestamp(m) | [
"def",
"_set_time",
"(",
"self",
",",
"m",
")",
":",
"# really just left here for profiling",
"m",
".",
"_timestamp",
"=",
"self",
".",
"timestamp",
"if",
"len",
"(",
"m",
".",
"_fieldnames",
")",
">",
"0",
"and",
"self",
".",
"clock",
"is",
"not",
"None... | set time for a message | [
"set",
"time",
"for",
"a",
"message"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L433-L438 | train | 230,024 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader._add_msg | def _add_msg(self, m):
'''add a new message'''
type = m.get_type()
self.messages[type] = m
if self.clock:
self.clock.message_arrived(m)
if type == 'MSG':
if m.Message.find("Rover") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_GROUND_ROVER
elif m.Message.find("Plane") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_FIXED_WING
elif m.Message.find("Copter") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_QUADROTOR
elif m.Message.startswith("Antenna"):
self.mav_type = mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER
if type == 'MODE':
if isinstance(m.Mode, str):
self.flightmode = m.Mode.upper()
elif 'ModeNum' in m._fieldnames:
mapping = mavutil.mode_mapping_bynumber(self.mav_type)
if mapping is not None and m.ModeNum in mapping:
self.flightmode = mapping[m.ModeNum]
else:
self.flightmode = mavutil.mode_string_acm(m.Mode)
if type == 'STAT' and 'MainState' in m._fieldnames:
self.flightmode = mavutil.mode_string_px4(m.MainState)
if type == 'PARM' and getattr(m, 'Name', None) is not None:
self.params[m.Name] = m.Value
self._set_time(m) | python | def _add_msg(self, m):
'''add a new message'''
type = m.get_type()
self.messages[type] = m
if self.clock:
self.clock.message_arrived(m)
if type == 'MSG':
if m.Message.find("Rover") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_GROUND_ROVER
elif m.Message.find("Plane") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_FIXED_WING
elif m.Message.find("Copter") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_QUADROTOR
elif m.Message.startswith("Antenna"):
self.mav_type = mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER
if type == 'MODE':
if isinstance(m.Mode, str):
self.flightmode = m.Mode.upper()
elif 'ModeNum' in m._fieldnames:
mapping = mavutil.mode_mapping_bynumber(self.mav_type)
if mapping is not None and m.ModeNum in mapping:
self.flightmode = mapping[m.ModeNum]
else:
self.flightmode = mavutil.mode_string_acm(m.Mode)
if type == 'STAT' and 'MainState' in m._fieldnames:
self.flightmode = mavutil.mode_string_px4(m.MainState)
if type == 'PARM' and getattr(m, 'Name', None) is not None:
self.params[m.Name] = m.Value
self._set_time(m) | [
"def",
"_add_msg",
"(",
"self",
",",
"m",
")",
":",
"type",
"=",
"m",
".",
"get_type",
"(",
")",
"self",
".",
"messages",
"[",
"type",
"]",
"=",
"m",
"if",
"self",
".",
"clock",
":",
"self",
".",
"clock",
".",
"message_arrived",
"(",
"m",
")",
... | add a new message | [
"add",
"a",
"new",
"message"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L443-L473 | train | 230,025 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader.recv_match | def recv_match(self, condition=None, type=None, blocking=False):
'''recv the next 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]
while True:
m = self.recv_msg()
if m is None:
return None
if type is not None and not m.get_type() in type:
continue
if not mavutil.evaluate_condition(condition, self.messages):
continue
return m | python | def recv_match(self, condition=None, type=None, blocking=False):
'''recv the next 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]
while True:
m = self.recv_msg()
if m is None:
return None
if type is not None and not m.get_type() in type:
continue
if not mavutil.evaluate_condition(condition, self.messages):
continue
return m | [
"def",
"recv_match",
"(",
"self",
",",
"condition",
"=",
"None",
",",
"type",
"=",
"None",
",",
"blocking",
"=",
"False",
")",
":",
"if",
"type",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"type",
",",
"list",
")",
":",
"type",
"=",
"[",... | recv the next message that matches the given condition
type can be a string or a list of strings | [
"recv",
"the",
"next",
"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/DFReader.py#L475-L488 | train | 230,026 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py | DFReader.param | def param(self, name, default=None):
'''convenient function for returning an arbitrary MAVLink
parameter with a default'''
if not name in self.params:
return default
return self.params[name] | python | def param(self, name, default=None):
'''convenient function for returning an arbitrary MAVLink
parameter with a default'''
if not name in self.params:
return default
return self.params[name] | [
"def",
"param",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"not",
"name",
"in",
"self",
".",
"params",
":",
"return",
"default",
"return",
"self",
".",
"params",
"[",
"name",
"]"
] | convenient function for returning an arbitrary MAVLink
parameter with a default | [
"convenient",
"function",
"for",
"returning",
"an",
"arbitrary",
"MAVLink",
"parameter",
"with",
"a",
"default"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/DFReader.py#L494-L499 | train | 230,027 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.cpu_load_send | def cpu_load_send(self, sensLoad, ctrlLoad, batVolt, force_mavlink1=False):
'''
Sensor and DSC control loads.
sensLoad : Sensor DSC Load (uint8_t)
ctrlLoad : Control DSC Load (uint8_t)
batVolt : Battery Voltage in millivolts (uint16_t)
'''
return self.send(self.cpu_load_encode(sensLoad, ctrlLoad, batVolt), force_mavlink1=force_mavlink1) | python | def cpu_load_send(self, sensLoad, ctrlLoad, batVolt, force_mavlink1=False):
'''
Sensor and DSC control loads.
sensLoad : Sensor DSC Load (uint8_t)
ctrlLoad : Control DSC Load (uint8_t)
batVolt : Battery Voltage in millivolts (uint16_t)
'''
return self.send(self.cpu_load_encode(sensLoad, ctrlLoad, batVolt), force_mavlink1=force_mavlink1) | [
"def",
"cpu_load_send",
"(",
"self",
",",
"sensLoad",
",",
"ctrlLoad",
",",
"batVolt",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"cpu_load_encode",
"(",
"sensLoad",
",",
"ctrlLoad",
",",
"batVolt",
")",... | Sensor and DSC control loads.
sensLoad : Sensor DSC Load (uint8_t)
ctrlLoad : Control DSC Load (uint8_t)
batVolt : Battery Voltage in millivolts (uint16_t) | [
"Sensor",
"and",
"DSC",
"control",
"loads",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L7816-L7825 | train | 230,028 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.ctrl_srfc_pt_send | def ctrl_srfc_pt_send(self, target, bitfieldPt, force_mavlink1=False):
'''
This message sets the control surfaces for selective passthrough mode.
target : The system setting the commands (uint8_t)
bitfieldPt : Bitfield containing the passthrough configuration, see CONTROL_SURFACE_FLAG ENUM. (uint16_t)
'''
return self.send(self.ctrl_srfc_pt_encode(target, bitfieldPt), force_mavlink1=force_mavlink1) | python | def ctrl_srfc_pt_send(self, target, bitfieldPt, force_mavlink1=False):
'''
This message sets the control surfaces for selective passthrough mode.
target : The system setting the commands (uint8_t)
bitfieldPt : Bitfield containing the passthrough configuration, see CONTROL_SURFACE_FLAG ENUM. (uint16_t)
'''
return self.send(self.ctrl_srfc_pt_encode(target, bitfieldPt), force_mavlink1=force_mavlink1) | [
"def",
"ctrl_srfc_pt_send",
"(",
"self",
",",
"target",
",",
"bitfieldPt",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"ctrl_srfc_pt_encode",
"(",
"target",
",",
"bitfieldPt",
")",
",",
"force_mavlink1",
"=... | This message sets the control surfaces for selective passthrough mode.
target : The system setting the commands (uint8_t)
bitfieldPt : Bitfield containing the passthrough configuration, see CONTROL_SURFACE_FLAG ENUM. (uint16_t) | [
"This",
"message",
"sets",
"the",
"control",
"surfaces",
"for",
"selective",
"passthrough",
"mode",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L8025-L8033 | train | 230,029 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.slugs_mobile_location_send | def slugs_mobile_location_send(self, target, latitude, longitude, force_mavlink1=False):
'''
Transmits the last known position of the mobile GS to the UAV. Very
relevant when Track Mobile is enabled
target : The system reporting the action (uint8_t)
latitude : Mobile Latitude (float)
longitude : Mobile Longitude (float)
'''
return self.send(self.slugs_mobile_location_encode(target, latitude, longitude), force_mavlink1=force_mavlink1) | python | def slugs_mobile_location_send(self, target, latitude, longitude, force_mavlink1=False):
'''
Transmits the last known position of the mobile GS to the UAV. Very
relevant when Track Mobile is enabled
target : The system reporting the action (uint8_t)
latitude : Mobile Latitude (float)
longitude : Mobile Longitude (float)
'''
return self.send(self.slugs_mobile_location_encode(target, latitude, longitude), force_mavlink1=force_mavlink1) | [
"def",
"slugs_mobile_location_send",
"(",
"self",
",",
"target",
",",
"latitude",
",",
"longitude",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"slugs_mobile_location_encode",
"(",
"target",
",",
"latitude",
... | Transmits the last known position of the mobile GS to the UAV. Very
relevant when Track Mobile is enabled
target : The system reporting the action (uint8_t)
latitude : Mobile Latitude (float)
longitude : Mobile Longitude (float) | [
"Transmits",
"the",
"last",
"known",
"position",
"of",
"the",
"mobile",
"GS",
"to",
"the",
"UAV",
".",
"Very",
"relevant",
"when",
"Track",
"Mobile",
"is",
"enabled"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L8097-L8107 | train | 230,030 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.slugs_configuration_camera_send | def slugs_configuration_camera_send(self, target, idOrder, order, force_mavlink1=False):
'''
Control for camara.
target : The system setting the commands (uint8_t)
idOrder : ID 0: brightness 1: aperture 2: iris 3: ICR 4: backlight (uint8_t)
order : 1: up/on 2: down/off 3: auto/reset/no action (uint8_t)
'''
return self.send(self.slugs_configuration_camera_encode(target, idOrder, order), force_mavlink1=force_mavlink1) | python | def slugs_configuration_camera_send(self, target, idOrder, order, force_mavlink1=False):
'''
Control for camara.
target : The system setting the commands (uint8_t)
idOrder : ID 0: brightness 1: aperture 2: iris 3: ICR 4: backlight (uint8_t)
order : 1: up/on 2: down/off 3: auto/reset/no action (uint8_t)
'''
return self.send(self.slugs_configuration_camera_encode(target, idOrder, order), force_mavlink1=force_mavlink1) | [
"def",
"slugs_configuration_camera_send",
"(",
"self",
",",
"target",
",",
"idOrder",
",",
"order",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"slugs_configuration_camera_encode",
"(",
"target",
",",
"idOrder"... | Control for camara.
target : The system setting the commands (uint8_t)
idOrder : ID 0: brightness 1: aperture 2: iris 3: ICR 4: backlight (uint8_t)
order : 1: up/on 2: down/off 3: auto/reset/no action (uint8_t) | [
"Control",
"for",
"camara",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L8120-L8129 | train | 230,031 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.volt_sensor_send | def volt_sensor_send(self, r2Type, voltage, reading2, force_mavlink1=False):
'''
Transmits the readings from the voltage and current sensors
r2Type : It is the value of reading 2: 0 - Current, 1 - Foreward Sonar, 2 - Back Sonar, 3 - RPM (uint8_t)
voltage : Voltage in uS of PWM. 0 uS = 0V, 20 uS = 21.5V (uint16_t)
reading2 : Depends on the value of r2Type (0) Current consumption in uS of PWM, 20 uS = 90Amp (1) Distance in cm (2) Distance in cm (3) Absolute value (uint16_t)
'''
return self.send(self.volt_sensor_encode(r2Type, voltage, reading2), force_mavlink1=force_mavlink1) | python | def volt_sensor_send(self, r2Type, voltage, reading2, force_mavlink1=False):
'''
Transmits the readings from the voltage and current sensors
r2Type : It is the value of reading 2: 0 - Current, 1 - Foreward Sonar, 2 - Back Sonar, 3 - RPM (uint8_t)
voltage : Voltage in uS of PWM. 0 uS = 0V, 20 uS = 21.5V (uint16_t)
reading2 : Depends on the value of r2Type (0) Current consumption in uS of PWM, 20 uS = 90Amp (1) Distance in cm (2) Distance in cm (3) Absolute value (uint16_t)
'''
return self.send(self.volt_sensor_encode(r2Type, voltage, reading2), force_mavlink1=force_mavlink1) | [
"def",
"volt_sensor_send",
"(",
"self",
",",
"r2Type",
",",
"voltage",
",",
"reading2",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"volt_sensor_encode",
"(",
"r2Type",
",",
"voltage",
",",
"reading2",
")... | Transmits the readings from the voltage and current sensors
r2Type : It is the value of reading 2: 0 - Current, 1 - Foreward Sonar, 2 - Back Sonar, 3 - RPM (uint8_t)
voltage : Voltage in uS of PWM. 0 uS = 0V, 20 uS = 21.5V (uint16_t)
reading2 : Depends on the value of r2Type (0) Current consumption in uS of PWM, 20 uS = 90Amp (1) Distance in cm (2) Distance in cm (3) Absolute value (uint16_t) | [
"Transmits",
"the",
"readings",
"from",
"the",
"voltage",
"and",
"current",
"sensors"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L8172-L8181 | train | 230,032 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | MAVLink.ptz_status_send | def ptz_status_send(self, zoom, pan, tilt, force_mavlink1=False):
'''
Transmits the actual Pan, Tilt and Zoom values of the camera unit
zoom : The actual Zoom Value (uint8_t)
pan : The Pan value in 10ths of degree (int16_t)
tilt : The Tilt value in 10ths of degree (int16_t)
'''
return self.send(self.ptz_status_encode(zoom, pan, tilt), force_mavlink1=force_mavlink1) | python | def ptz_status_send(self, zoom, pan, tilt, force_mavlink1=False):
'''
Transmits the actual Pan, Tilt and Zoom values of the camera unit
zoom : The actual Zoom Value (uint8_t)
pan : The Pan value in 10ths of degree (int16_t)
tilt : The Tilt value in 10ths of degree (int16_t)
'''
return self.send(self.ptz_status_encode(zoom, pan, tilt), force_mavlink1=force_mavlink1) | [
"def",
"ptz_status_send",
"(",
"self",
",",
"zoom",
",",
"pan",
",",
"tilt",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"ptz_status_encode",
"(",
"zoom",
",",
"pan",
",",
"tilt",
")",
",",
"force_mav... | Transmits the actual Pan, Tilt and Zoom values of the camera unit
zoom : The actual Zoom Value (uint8_t)
pan : The Pan value in 10ths of degree (int16_t)
tilt : The Tilt value in 10ths of degree (int16_t) | [
"Transmits",
"the",
"actual",
"Pan",
"Tilt",
"and",
"Zoom",
"values",
"of",
"the",
"camera",
"unit"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L8194-L8203 | train | 230,033 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py | MAVLink.script_request_send | def script_request_send(self, target_system, target_component, seq, force_mavlink1=False):
'''
Request script item with the sequence number seq. The response of the
system to this message should be a SCRIPT_ITEM
message.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seq : Sequence (uint16_t)
'''
return self.send(self.script_request_encode(target_system, target_component, seq), force_mavlink1=force_mavlink1) | python | def script_request_send(self, target_system, target_component, seq, force_mavlink1=False):
'''
Request script item with the sequence number seq. The response of the
system to this message should be a SCRIPT_ITEM
message.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seq : Sequence (uint16_t)
'''
return self.send(self.script_request_encode(target_system, target_component, seq), force_mavlink1=force_mavlink1) | [
"def",
"script_request_send",
"(",
"self",
",",
"target_system",
",",
"target_component",
",",
"seq",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"script_request_encode",
"(",
"target_system",
",",
"target_comp... | Request script item with the sequence number seq. The response of the
system to this message should be a SCRIPT_ITEM
message.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
seq : Sequence (uint16_t) | [
"Request",
"script",
"item",
"with",
"the",
"sequence",
"number",
"seq",
".",
"The",
"response",
"of",
"the",
"system",
"to",
"this",
"message",
"should",
"be",
"a",
"SCRIPT_ITEM",
"message",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py#L7322-L7333 | train | 230,034 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py | MAVLink.script_count_send | def script_count_send(self, target_system, target_component, count, force_mavlink1=False):
'''
This message is emitted as response to SCRIPT_REQUEST_LIST by the MAV
to get the number of mission scripts.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
count : Number of script items in the sequence (uint16_t)
'''
return self.send(self.script_count_encode(target_system, target_component, count), force_mavlink1=force_mavlink1) | python | def script_count_send(self, target_system, target_component, count, force_mavlink1=False):
'''
This message is emitted as response to SCRIPT_REQUEST_LIST by the MAV
to get the number of mission scripts.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
count : Number of script items in the sequence (uint16_t)
'''
return self.send(self.script_count_encode(target_system, target_component, count), force_mavlink1=force_mavlink1) | [
"def",
"script_count_send",
"(",
"self",
",",
"target_system",
",",
"target_component",
",",
"count",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"script_count_encode",
"(",
"target_system",
",",
"target_compon... | This message is emitted as response to SCRIPT_REQUEST_LIST by the MAV
to get the number of mission scripts.
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
count : Number of script items in the sequence (uint16_t) | [
"This",
"message",
"is",
"emitted",
"as",
"response",
"to",
"SCRIPT_REQUEST_LIST",
"by",
"the",
"MAV",
"to",
"get",
"the",
"number",
"of",
"mission",
"scripts",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py#L7367-L7377 | train | 230,035 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py | MAVLink.script_current_send | def script_current_send(self, seq, force_mavlink1=False):
'''
This message informs about the currently active SCRIPT.
seq : Active Sequence (uint16_t)
'''
return self.send(self.script_current_encode(seq), force_mavlink1=force_mavlink1) | python | def script_current_send(self, seq, force_mavlink1=False):
'''
This message informs about the currently active SCRIPT.
seq : Active Sequence (uint16_t)
'''
return self.send(self.script_current_encode(seq), force_mavlink1=force_mavlink1) | [
"def",
"script_current_send",
"(",
"self",
",",
"seq",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"script_current_encode",
"(",
"seq",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] | This message informs about the currently active SCRIPT.
seq : Active Sequence (uint16_t) | [
"This",
"message",
"informs",
"about",
"the",
"currently",
"active",
"SCRIPT",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/paparazzi.py#L7388-L7395 | train | 230,036 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_c.py | generate | def generate(basename, xml_list):
'''generate complete MAVLink C implemenation'''
for idx in range(len(xml_list)):
xml = xml_list[idx]
xml.xml_idx = idx
generate_one(basename, xml)
copy_fixed_headers(basename, xml_list[0]) | python | def generate(basename, xml_list):
'''generate complete MAVLink C implemenation'''
for idx in range(len(xml_list)):
xml = xml_list[idx]
xml.xml_idx = idx
generate_one(basename, xml)
copy_fixed_headers(basename, xml_list[0]) | [
"def",
"generate",
"(",
"basename",
",",
"xml_list",
")",
":",
"for",
"idx",
"in",
"range",
"(",
"len",
"(",
"xml_list",
")",
")",
":",
"xml",
"=",
"xml_list",
"[",
"idx",
"]",
"xml",
".",
"xml_idx",
"=",
"idx",
"generate_one",
"(",
"basename",
",",
... | generate complete MAVLink C implemenation | [
"generate",
"complete",
"MAVLink",
"C",
"implemenation"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_c.py#L689-L696 | train | 230,037 |
JdeRobot/base | src/libs/comm_py/comm/ice/pose3dIceClient.py | Pose3D.update | def update(self):
'''
Updates Pose3d.
'''
pos = Pose3d()
if self.hasproxy():
pose = self.proxy.getPose3DData()
pos.yaw = self.quat2Yaw(pose.q0, pose.q1, pose.q2, pose.q3)
pos.pitch = self.quat2Pitch(pose.q0, pose.q1, pose.q2, pose.q3)
pos.roll = self.quat2Roll(pose.q0, pose.q1, pose.q2, pose.q3)
pos.x = pose.x
pos.y = pose.y
pos.z = pose.z
pos.h = pose.h
pos.q = [pose.q0, pose.q1, pose.q2, pose.q3]
self.lock.acquire()
self.pose = pos
self.lock.release() | python | def update(self):
'''
Updates Pose3d.
'''
pos = Pose3d()
if self.hasproxy():
pose = self.proxy.getPose3DData()
pos.yaw = self.quat2Yaw(pose.q0, pose.q1, pose.q2, pose.q3)
pos.pitch = self.quat2Pitch(pose.q0, pose.q1, pose.q2, pose.q3)
pos.roll = self.quat2Roll(pose.q0, pose.q1, pose.q2, pose.q3)
pos.x = pose.x
pos.y = pose.y
pos.z = pose.z
pos.h = pose.h
pos.q = [pose.q0, pose.q1, pose.q2, pose.q3]
self.lock.acquire()
self.pose = pos
self.lock.release() | [
"def",
"update",
"(",
"self",
")",
":",
"pos",
"=",
"Pose3d",
"(",
")",
"if",
"self",
".",
"hasproxy",
"(",
")",
":",
"pose",
"=",
"self",
".",
"proxy",
".",
"getPose3DData",
"(",
")",
"pos",
".",
"yaw",
"=",
"self",
".",
"quat2Yaw",
"(",
"pose",... | Updates Pose3d. | [
"Updates",
"Pose3d",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/pose3dIceClient.py#L68-L86 | train | 230,038 |
JdeRobot/base | src/libs/comm_py/comm/ice/pose3dIceClient.py | Pose3D.getPose3d | def getPose3d(self):
'''
Returns last Pose3d.
@return last JdeRobotTypes Pose3d saved
'''
self.lock.acquire()
pose = self.pose
self.lock.release()
return pose | python | def getPose3d(self):
'''
Returns last Pose3d.
@return last JdeRobotTypes Pose3d saved
'''
self.lock.acquire()
pose = self.pose
self.lock.release()
return pose | [
"def",
"getPose3d",
"(",
"self",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"pose",
"=",
"self",
".",
"pose",
"self",
".",
"lock",
".",
"release",
"(",
")",
"return",
"pose"
] | Returns last Pose3d.
@return last JdeRobotTypes Pose3d saved | [
"Returns",
"last",
"Pose3d",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/pose3dIceClient.py#L97-L107 | train | 230,039 |
JdeRobot/base | src/libs/comm_py/comm/ice/pose3dIceClient.py | Pose3D.quat2Roll | def quat2Roll (self, qw, qx, qy, qz):
'''
Translates from Quaternion to Roll.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Roll value translated from Quaternion
'''
rotateXa0=2.0*(qy*qz + qw*qx)
rotateXa1=qw*qw - qx*qx - qy*qy + qz*qz
rotateX=0.0
if(rotateXa0 != 0.0 and rotateXa1 != 0.0):
rotateX=atan2(rotateXa0, rotateXa1)
return rotateX | python | def quat2Roll (self, qw, qx, qy, qz):
'''
Translates from Quaternion to Roll.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Roll value translated from Quaternion
'''
rotateXa0=2.0*(qy*qz + qw*qx)
rotateXa1=qw*qw - qx*qx - qy*qy + qz*qz
rotateX=0.0
if(rotateXa0 != 0.0 and rotateXa1 != 0.0):
rotateX=atan2(rotateXa0, rotateXa1)
return rotateX | [
"def",
"quat2Roll",
"(",
"self",
",",
"qw",
",",
"qx",
",",
"qy",
",",
"qz",
")",
":",
"rotateXa0",
"=",
"2.0",
"*",
"(",
"qy",
"*",
"qz",
"+",
"qw",
"*",
"qx",
")",
"rotateXa1",
"=",
"qw",
"*",
"qw",
"-",
"qx",
"*",
"qx",
"-",
"qy",
"*",
... | Translates from Quaternion to Roll.
@param qw,qx,qy,qz: Quaternion values
@type qw,qx,qy,qz: float
@return Roll value translated from Quaternion | [
"Translates",
"from",
"Quaternion",
"to",
"Roll",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/pose3dIceClient.py#L150-L167 | train | 230,040 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_speech.py | SpeechModule.kill_speech_dispatcher | def kill_speech_dispatcher(self):
'''kill speech dispatcher processs'''
if not 'HOME' in os.environ:
return
pidpath = os.path.join(os.environ['HOME'], '.speech-dispatcher',
'pid', 'speech-dispatcher.pid')
if os.path.exists(pidpath):
try:
import signal
pid = int(open(pidpath).read())
if pid > 1 and os.kill(pid, 0) is None:
print("Killing speech dispatcher pid %u" % pid)
os.kill(pid, signal.SIGINT)
time.sleep(1)
except Exception as e:
pass | python | def kill_speech_dispatcher(self):
'''kill speech dispatcher processs'''
if not 'HOME' in os.environ:
return
pidpath = os.path.join(os.environ['HOME'], '.speech-dispatcher',
'pid', 'speech-dispatcher.pid')
if os.path.exists(pidpath):
try:
import signal
pid = int(open(pidpath).read())
if pid > 1 and os.kill(pid, 0) is None:
print("Killing speech dispatcher pid %u" % pid)
os.kill(pid, signal.SIGINT)
time.sleep(1)
except Exception as e:
pass | [
"def",
"kill_speech_dispatcher",
"(",
"self",
")",
":",
"if",
"not",
"'HOME'",
"in",
"os",
".",
"environ",
":",
"return",
"pidpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"'HOME'",
"]",
",",
"'.speech-dispatcher'",
",",
"... | kill speech dispatcher processs | [
"kill",
"speech",
"dispatcher",
"processs"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_speech.py#L27-L42 | train | 230,041 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py | SRTMDownloader.loadFileList | def loadFileList(self):
"""Load a previously created file list or create a new one if none is
available."""
try:
data = open(self.filelist_file, 'rb')
except IOError:
'''print "No SRTM cached file list. Creating new one!"'''
if self.offline == 0:
self.createFileList()
return
try:
self.filelist = pickle.load(data)
data.close()
if len(self.filelist) < self.min_filelist_len:
self.filelist = {}
if self.offline == 0:
self.createFileList()
except:
'''print "Unknown error loading cached SRTM file list. Creating new one!"'''
if self.offline == 0:
self.createFileList() | python | def loadFileList(self):
"""Load a previously created file list or create a new one if none is
available."""
try:
data = open(self.filelist_file, 'rb')
except IOError:
'''print "No SRTM cached file list. Creating new one!"'''
if self.offline == 0:
self.createFileList()
return
try:
self.filelist = pickle.load(data)
data.close()
if len(self.filelist) < self.min_filelist_len:
self.filelist = {}
if self.offline == 0:
self.createFileList()
except:
'''print "Unknown error loading cached SRTM file list. Creating new one!"'''
if self.offline == 0:
self.createFileList() | [
"def",
"loadFileList",
"(",
"self",
")",
":",
"try",
":",
"data",
"=",
"open",
"(",
"self",
".",
"filelist_file",
",",
"'rb'",
")",
"except",
"IOError",
":",
"'''print \"No SRTM cached file list. Creating new one!\"'''",
"if",
"self",
".",
"offline",
"==",
"0",
... | Load a previously created file list or create a new one if none is
available. | [
"Load",
"a",
"previously",
"created",
"file",
"list",
"or",
"create",
"a",
"new",
"one",
"if",
"none",
"is",
"available",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L89-L109 | train | 230,042 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py | SRTMTile._avg | def _avg(value1, value2, weight):
"""Returns the weighted average of two values and handles the case where
one value is None. If both values are None, None is returned.
"""
if value1 is None:
return value2
if value2 is None:
return value1
return value2 * weight + value1 * (1 - weight) | python | def _avg(value1, value2, weight):
"""Returns the weighted average of two values and handles the case where
one value is None. If both values are None, None is returned.
"""
if value1 is None:
return value2
if value2 is None:
return value1
return value2 * weight + value1 * (1 - weight) | [
"def",
"_avg",
"(",
"value1",
",",
"value2",
",",
"weight",
")",
":",
"if",
"value1",
"is",
"None",
":",
"return",
"value2",
"if",
"value2",
"is",
"None",
":",
"return",
"value1",
"return",
"value2",
"*",
"weight",
"+",
"value1",
"*",
"(",
"1",
"-",
... | Returns the weighted average of two values and handles the case where
one value is None. If both values are None, None is returned. | [
"Returns",
"the",
"weighted",
"average",
"of",
"two",
"values",
"and",
"handles",
"the",
"case",
"where",
"one",
"value",
"is",
"None",
".",
"If",
"both",
"values",
"are",
"None",
"None",
"is",
"returned",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L305-L313 | train | 230,043 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py | SRTMTile.calcOffset | def calcOffset(self, x, y):
"""Calculate offset into data array. Only uses to test correctness
of the formula."""
# Datalayout
# X = longitude
# Y = latitude
# Sample for size 1201x1201
# ( 0/1200) ( 1/1200) ... (1199/1200) (1200/1200)
# ( 0/1199) ( 1/1199) ... (1199/1199) (1200/1199)
# ... ... ... ...
# ( 0/ 1) ( 1/ 1) ... (1199/ 1) (1200/ 1)
# ( 0/ 0) ( 1/ 0) ... (1199/ 0) (1200/ 0)
# Some offsets:
# (0/1200) 0
# (1200/1200) 1200
# (0/1199) 1201
# (1200/1199) 2401
# (0/0) 1201*1200
# (1200/0) 1201*1201-1
return x + self.size * (self.size - y - 1) | python | def calcOffset(self, x, y):
"""Calculate offset into data array. Only uses to test correctness
of the formula."""
# Datalayout
# X = longitude
# Y = latitude
# Sample for size 1201x1201
# ( 0/1200) ( 1/1200) ... (1199/1200) (1200/1200)
# ( 0/1199) ( 1/1199) ... (1199/1199) (1200/1199)
# ... ... ... ...
# ( 0/ 1) ( 1/ 1) ... (1199/ 1) (1200/ 1)
# ( 0/ 0) ( 1/ 0) ... (1199/ 0) (1200/ 0)
# Some offsets:
# (0/1200) 0
# (1200/1200) 1200
# (0/1199) 1201
# (1200/1199) 2401
# (0/0) 1201*1200
# (1200/0) 1201*1201-1
return x + self.size * (self.size - y - 1) | [
"def",
"calcOffset",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"# Datalayout",
"# X = longitude",
"# Y = latitude",
"# Sample for size 1201x1201",
"# ( 0/1200) ( 1/1200) ... (1199/1200) (1200/1200)",
"# ( 0/1199) ( 1/1199) ... (1199/1199) (1200/1199)",
... | Calculate offset into data array. Only uses to test correctness
of the formula. | [
"Calculate",
"offset",
"into",
"data",
"array",
".",
"Only",
"uses",
"to",
"test",
"correctness",
"of",
"the",
"formula",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L315-L334 | train | 230,044 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py | SRTMTile.getPixelValue | def getPixelValue(self, x, y):
"""Get the value of a pixel from the data, handling voids in the
SRTM data."""
assert x < self.size, "x: %d<%d" % (x, self.size)
assert y < self.size, "y: %d<%d" % (y, self.size)
# Same as calcOffset, inlined for performance reasons
offset = x + self.size * (self.size - y - 1)
#print offset
value = self.data[offset]
if value == -32768:
return -1 # -32768 is a special value for areas with no data
return value | python | def getPixelValue(self, x, y):
"""Get the value of a pixel from the data, handling voids in the
SRTM data."""
assert x < self.size, "x: %d<%d" % (x, self.size)
assert y < self.size, "y: %d<%d" % (y, self.size)
# Same as calcOffset, inlined for performance reasons
offset = x + self.size * (self.size - y - 1)
#print offset
value = self.data[offset]
if value == -32768:
return -1 # -32768 is a special value for areas with no data
return value | [
"def",
"getPixelValue",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"assert",
"x",
"<",
"self",
".",
"size",
",",
"\"x: %d<%d\"",
"%",
"(",
"x",
",",
"self",
".",
"size",
")",
"assert",
"y",
"<",
"self",
".",
"size",
",",
"\"y: %d<%d\"",
"%",
"(",... | Get the value of a pixel from the data, handling voids in the
SRTM data. | [
"Get",
"the",
"value",
"of",
"a",
"pixel",
"from",
"the",
"data",
"handling",
"voids",
"in",
"the",
"SRTM",
"data",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L336-L347 | train | 230,045 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py | SRTMTile.getAltitudeFromLatLon | def getAltitudeFromLatLon(self, lat, lon):
"""Get the altitude of a lat lon pair, using the four neighbouring
pixels for interpolation.
"""
# print "-----\nFromLatLon", lon, lat
lat -= self.lat
lon -= self.lon
# print "lon, lat", lon, lat
if lat < 0.0 or lat >= 1.0 or lon < 0.0 or lon >= 1.0:
raise WrongTileError(self.lat, self.lon, self.lat+lat, self.lon+lon)
x = lon * (self.size - 1)
y = lat * (self.size - 1)
# print "x,y", x, y
x_int = int(x)
x_frac = x - int(x)
y_int = int(y)
y_frac = y - int(y)
# print "frac", x_int, x_frac, y_int, y_frac
value00 = self.getPixelValue(x_int, y_int)
value10 = self.getPixelValue(x_int+1, y_int)
value01 = self.getPixelValue(x_int, y_int+1)
value11 = self.getPixelValue(x_int+1, y_int+1)
value1 = self._avg(value00, value10, x_frac)
value2 = self._avg(value01, value11, x_frac)
value = self._avg(value1, value2, y_frac)
# print "%4d %4d | %4d\n%4d %4d | %4d\n-------------\n%4d" % (
# value00, value10, value1, value01, value11, value2, value)
return value | python | def getAltitudeFromLatLon(self, lat, lon):
"""Get the altitude of a lat lon pair, using the four neighbouring
pixels for interpolation.
"""
# print "-----\nFromLatLon", lon, lat
lat -= self.lat
lon -= self.lon
# print "lon, lat", lon, lat
if lat < 0.0 or lat >= 1.0 or lon < 0.0 or lon >= 1.0:
raise WrongTileError(self.lat, self.lon, self.lat+lat, self.lon+lon)
x = lon * (self.size - 1)
y = lat * (self.size - 1)
# print "x,y", x, y
x_int = int(x)
x_frac = x - int(x)
y_int = int(y)
y_frac = y - int(y)
# print "frac", x_int, x_frac, y_int, y_frac
value00 = self.getPixelValue(x_int, y_int)
value10 = self.getPixelValue(x_int+1, y_int)
value01 = self.getPixelValue(x_int, y_int+1)
value11 = self.getPixelValue(x_int+1, y_int+1)
value1 = self._avg(value00, value10, x_frac)
value2 = self._avg(value01, value11, x_frac)
value = self._avg(value1, value2, y_frac)
# print "%4d %4d | %4d\n%4d %4d | %4d\n-------------\n%4d" % (
# value00, value10, value1, value01, value11, value2, value)
return value | [
"def",
"getAltitudeFromLatLon",
"(",
"self",
",",
"lat",
",",
"lon",
")",
":",
"# print \"-----\\nFromLatLon\", lon, lat",
"lat",
"-=",
"self",
".",
"lat",
"lon",
"-=",
"self",
".",
"lon",
"# print \"lon, lat\", lon, lat",
"if",
"lat",
"<",
"0.0",
"or",
"lat",
... | Get the altitude of a lat lon pair, using the four neighbouring
pixels for interpolation. | [
"Get",
"the",
"altitude",
"of",
"a",
"lat",
"lon",
"pair",
"using",
"the",
"four",
"neighbouring",
"pixels",
"for",
"interpolation",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L350-L377 | train | 230,046 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mavmemlog.py | mavmemlog.rewind | def rewind(self):
'''rewind to start'''
self._index = 0
self.percent = 0
self.messages = {}
self._flightmode_index = 0
self._timestamp = None
self.flightmode = None
self.params = {} | python | def rewind(self):
'''rewind to start'''
self._index = 0
self.percent = 0
self.messages = {}
self._flightmode_index = 0
self._timestamp = None
self.flightmode = None
self.params = {} | [
"def",
"rewind",
"(",
"self",
")",
":",
"self",
".",
"_index",
"=",
"0",
"self",
".",
"percent",
"=",
"0",
"self",
".",
"messages",
"=",
"{",
"}",
"self",
".",
"_flightmode_index",
"=",
"0",
"self",
".",
"_timestamp",
"=",
"None",
"self",
".",
"fli... | rewind to start | [
"rewind",
"to",
"start"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mavmemlog.py#L68-L76 | train | 230,047 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py | MAVParmDict.mavset | def mavset(self, mav, name, value, retries=3):
'''set a parameter on a mavlink connection'''
got_ack = False
while retries > 0 and not got_ack:
retries -= 1
mav.param_set_send(name.upper(), float(value))
tstart = time.time()
while time.time() - tstart < 1:
ack = mav.recv_match(type='PARAM_VALUE', blocking=False)
if ack == None:
time.sleep(0.1)
continue
if str(name).upper() == str(ack.param_id).upper():
got_ack = True
self.__setitem__(name, float(value))
break
if not got_ack:
print("timeout setting %s to %f" % (name, float(value)))
return False
return True | python | def mavset(self, mav, name, value, retries=3):
'''set a parameter on a mavlink connection'''
got_ack = False
while retries > 0 and not got_ack:
retries -= 1
mav.param_set_send(name.upper(), float(value))
tstart = time.time()
while time.time() - tstart < 1:
ack = mav.recv_match(type='PARAM_VALUE', blocking=False)
if ack == None:
time.sleep(0.1)
continue
if str(name).upper() == str(ack.param_id).upper():
got_ack = True
self.__setitem__(name, float(value))
break
if not got_ack:
print("timeout setting %s to %f" % (name, float(value)))
return False
return True | [
"def",
"mavset",
"(",
"self",
",",
"mav",
",",
"name",
",",
"value",
",",
"retries",
"=",
"3",
")",
":",
"got_ack",
"=",
"False",
"while",
"retries",
">",
"0",
"and",
"not",
"got_ack",
":",
"retries",
"-=",
"1",
"mav",
".",
"param_set_send",
"(",
"... | set a parameter on a mavlink connection | [
"set",
"a",
"parameter",
"on",
"a",
"mavlink",
"connection"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py#L17-L36 | train | 230,048 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py | MAVParmDict.save | def save(self, filename, wildcard='*', verbose=False):
'''save parameters to a file'''
f = open(filename, mode='w')
k = list(self.keys())
k.sort()
count = 0
for p in k:
if p and fnmatch.fnmatch(str(p).upper(), wildcard.upper()):
f.write("%-16.16s %f\n" % (p, self.__getitem__(p)))
count += 1
f.close()
if verbose:
print("Saved %u parameters to %s" % (count, filename)) | python | def save(self, filename, wildcard='*', verbose=False):
'''save parameters to a file'''
f = open(filename, mode='w')
k = list(self.keys())
k.sort()
count = 0
for p in k:
if p and fnmatch.fnmatch(str(p).upper(), wildcard.upper()):
f.write("%-16.16s %f\n" % (p, self.__getitem__(p)))
count += 1
f.close()
if verbose:
print("Saved %u parameters to %s" % (count, filename)) | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"wildcard",
"=",
"'*'",
",",
"verbose",
"=",
"False",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"mode",
"=",
"'w'",
")",
"k",
"=",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
"k",
... | save parameters to a file | [
"save",
"parameters",
"to",
"a",
"file"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py#L39-L51 | train | 230,049 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py | MAVParmDict.load | def load(self, filename, wildcard='*', mav=None, check=True):
'''load parameters from a file'''
try:
f = open(filename, mode='r')
except:
print("Failed to open file '%s'" % filename)
return False
count = 0
changed = 0
for line in f:
line = line.strip()
if not line or line[0] == "#":
continue
line = line.replace(',',' ')
a = line.split()
if len(a) != 2:
print("Invalid line: %s" % line)
continue
# some parameters should not be loaded from files
if a[0] in self.exclude_load:
continue
if not fnmatch.fnmatch(a[0].upper(), wildcard.upper()):
continue
if mav is not None:
if check:
if a[0] not in self.keys():
print("Unknown parameter %s" % a[0])
continue
old_value = self.__getitem__(a[0])
if math.fabs(old_value - float(a[1])) <= self.mindelta:
count += 1
continue
if self.mavset(mav, a[0], a[1]):
print("changed %s from %f to %f" % (a[0], old_value, float(a[1])))
else:
print("set %s to %f" % (a[0], float(a[1])))
self.mavset(mav, a[0], a[1])
changed += 1
else:
self.__setitem__(a[0], float(a[1]))
count += 1
f.close()
if mav is not None:
print("Loaded %u parameters from %s (changed %u)" % (count, filename, changed))
else:
print("Loaded %u parameters from %s" % (count, filename))
return True | python | def load(self, filename, wildcard='*', mav=None, check=True):
'''load parameters from a file'''
try:
f = open(filename, mode='r')
except:
print("Failed to open file '%s'" % filename)
return False
count = 0
changed = 0
for line in f:
line = line.strip()
if not line or line[0] == "#":
continue
line = line.replace(',',' ')
a = line.split()
if len(a) != 2:
print("Invalid line: %s" % line)
continue
# some parameters should not be loaded from files
if a[0] in self.exclude_load:
continue
if not fnmatch.fnmatch(a[0].upper(), wildcard.upper()):
continue
if mav is not None:
if check:
if a[0] not in self.keys():
print("Unknown parameter %s" % a[0])
continue
old_value = self.__getitem__(a[0])
if math.fabs(old_value - float(a[1])) <= self.mindelta:
count += 1
continue
if self.mavset(mav, a[0], a[1]):
print("changed %s from %f to %f" % (a[0], old_value, float(a[1])))
else:
print("set %s to %f" % (a[0], float(a[1])))
self.mavset(mav, a[0], a[1])
changed += 1
else:
self.__setitem__(a[0], float(a[1]))
count += 1
f.close()
if mav is not None:
print("Loaded %u parameters from %s (changed %u)" % (count, filename, changed))
else:
print("Loaded %u parameters from %s" % (count, filename))
return True | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"wildcard",
"=",
"'*'",
",",
"mav",
"=",
"None",
",",
"check",
"=",
"True",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
")",
"except",
":",
"print",
"(",
"\... | load parameters from a file | [
"load",
"parameters",
"from",
"a",
"file"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py#L54-L100 | train | 230,050 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py | MAVParmDict.diff | def diff(self, filename, wildcard='*'):
'''show differences with another parameter file'''
other = MAVParmDict()
if not other.load(filename):
return
keys = sorted(list(set(self.keys()).union(set(other.keys()))))
for k in keys:
if not fnmatch.fnmatch(str(k).upper(), wildcard.upper()):
continue
if not k in other:
print("%-16.16s %12.4f" % (k, self[k]))
elif not k in self:
print("%-16.16s %12.4f" % (k, other[k]))
elif abs(self[k] - other[k]) > self.mindelta:
print("%-16.16s %12.4f %12.4f" % (k, other[k], self[k])) | python | def diff(self, filename, wildcard='*'):
'''show differences with another parameter file'''
other = MAVParmDict()
if not other.load(filename):
return
keys = sorted(list(set(self.keys()).union(set(other.keys()))))
for k in keys:
if not fnmatch.fnmatch(str(k).upper(), wildcard.upper()):
continue
if not k in other:
print("%-16.16s %12.4f" % (k, self[k]))
elif not k in self:
print("%-16.16s %12.4f" % (k, other[k]))
elif abs(self[k] - other[k]) > self.mindelta:
print("%-16.16s %12.4f %12.4f" % (k, other[k], self[k])) | [
"def",
"diff",
"(",
"self",
",",
"filename",
",",
"wildcard",
"=",
"'*'",
")",
":",
"other",
"=",
"MAVParmDict",
"(",
")",
"if",
"not",
"other",
".",
"load",
"(",
"filename",
")",
":",
"return",
"keys",
"=",
"sorted",
"(",
"list",
"(",
"set",
"(",
... | show differences with another parameter file | [
"show",
"differences",
"with",
"another",
"parameter",
"file"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavparm.py#L109-L123 | train | 230,051 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_java.py | generate | def generate(basename, xml_list):
'''generate complete MAVLink Java implemenation'''
for xml in xml_list:
generate_one(basename, xml)
generate_enums(basename, xml)
generate_MAVLinkMessage(basename, xml_list)
copy_fixed_headers(basename, xml_list[0]) | python | def generate(basename, xml_list):
'''generate complete MAVLink Java implemenation'''
for xml in xml_list:
generate_one(basename, xml)
generate_enums(basename, xml)
generate_MAVLinkMessage(basename, xml_list)
copy_fixed_headers(basename, xml_list[0]) | [
"def",
"generate",
"(",
"basename",
",",
"xml_list",
")",
":",
"for",
"xml",
"in",
"xml_list",
":",
"generate_one",
"(",
"basename",
",",
"xml",
")",
"generate_enums",
"(",
"basename",
",",
"xml",
")",
"generate_MAVLinkMessage",
"(",
"basename",
",",
"xml_li... | generate complete MAVLink Java implemenation | [
"generate",
"complete",
"MAVLink",
"Java",
"implemenation"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_java.py#L611-L617 | train | 230,052 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/autoquad.py | MAVLink.aq_telemetry_f_encode | def aq_telemetry_f_encode(self, Index, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20):
'''
Sends up to 20 raw float values.
Index : Index of message (uint16_t)
value1 : value1 (float)
value2 : value2 (float)
value3 : value3 (float)
value4 : value4 (float)
value5 : value5 (float)
value6 : value6 (float)
value7 : value7 (float)
value8 : value8 (float)
value9 : value9 (float)
value10 : value10 (float)
value11 : value11 (float)
value12 : value12 (float)
value13 : value13 (float)
value14 : value14 (float)
value15 : value15 (float)
value16 : value16 (float)
value17 : value17 (float)
value18 : value18 (float)
value19 : value19 (float)
value20 : value20 (float)
'''
return MAVLink_aq_telemetry_f_message(Index, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20) | python | def aq_telemetry_f_encode(self, Index, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20):
'''
Sends up to 20 raw float values.
Index : Index of message (uint16_t)
value1 : value1 (float)
value2 : value2 (float)
value3 : value3 (float)
value4 : value4 (float)
value5 : value5 (float)
value6 : value6 (float)
value7 : value7 (float)
value8 : value8 (float)
value9 : value9 (float)
value10 : value10 (float)
value11 : value11 (float)
value12 : value12 (float)
value13 : value13 (float)
value14 : value14 (float)
value15 : value15 (float)
value16 : value16 (float)
value17 : value17 (float)
value18 : value18 (float)
value19 : value19 (float)
value20 : value20 (float)
'''
return MAVLink_aq_telemetry_f_message(Index, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20) | [
"def",
"aq_telemetry_f_encode",
"(",
"self",
",",
"Index",
",",
"value1",
",",
"value2",
",",
"value3",
",",
"value4",
",",
"value5",
",",
"value6",
",",
"value7",
",",
"value8",
",",
"value9",
",",
"value10",
",",
"value11",
",",
"value12",
",",
"value1... | Sends up to 20 raw float values.
Index : Index of message (uint16_t)
value1 : value1 (float)
value2 : value2 (float)
value3 : value3 (float)
value4 : value4 (float)
value5 : value5 (float)
value6 : value6 (float)
value7 : value7 (float)
value8 : value8 (float)
value9 : value9 (float)
value10 : value10 (float)
value11 : value11 (float)
value12 : value12 (float)
value13 : value13 (float)
value14 : value14 (float)
value15 : value15 (float)
value16 : value16 (float)
value17 : value17 (float)
value18 : value18 (float)
value19 : value19 (float)
value20 : value20 (float) | [
"Sends",
"up",
"to",
"20",
"raw",
"float",
"values",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/autoquad.py#L7321-L7348 | train | 230,053 |
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 | train | 230,054 |
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",
"(",... | handle rally add | [
"handle",
"rally",
"add"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L72-L114 | train | 230,055 |
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",
"(",... | 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 | train | 230,056 |
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 fi... | handle rally move | [
"handle",
"rally",
"move"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L140-L173 | train | 230,057 |
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_... | rally point commands | [
"rally",
"point",
"commands"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L176-L251 | train | 230,058 |
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",
":",
"... | 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 | train | 230,059 |
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_com... | 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 | train | 230,060 |
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",
"(",
... | 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 | train | 230,061 |
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... | 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 | train | 230,062 |
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",
".",
... | 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 | train | 230,063 |
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",
"."... | 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 | train | 230,064 |
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 | train | 230,065 |
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 | train | 230,066 |
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",
",",
"targe... | 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 | train | 230,067 |
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 | train | 230,068 |
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",
... | 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 | train | 230,069 |
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",
... | 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 | train | 230,070 |
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",
... | 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 | train | 230,071 |
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",
... | 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 | train | 230,072 |
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",
",",
"targe... | 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 | train | 230,073 |
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",
... | 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 | train | 230,074 |
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",
",",
"... | 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 | train | 230,075 |
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",
",",
"ta... | 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 | train | 230,076 |
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"... | 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 | train | 230,077 |
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",
... | 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 | train | 230,078 |
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 | train | 230,079 |
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",
"*",... | 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 | train | 230,080 |
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",
"[",
... | 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 | train | 230,081 |
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",
"]",
".",
"ind... | 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 | train | 230,082 |
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",
")",
"i... | 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 | train | 230,083 |
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'",
"%",
"var... | 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 | train | 230,084 |
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'"... | 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 | train | 230,085 |
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",
"]",
"... | 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 | train | 230,086 |
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",
"-",
"q... | 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 | train | 230,087 |
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",
"=... | 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 | train | 230,088 |
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",
".",
"... | 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 | train | 230,089 |
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 | train | 230,090 |
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",
":",
... | 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 | train | 230,091 |
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",
"=",
"n... | 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 | train | 230,092 |
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",
... | 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 | train | 230,093 |
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",
"-",
... | 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 | train | 230,094 |
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",
".",
... | 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 | train | 230,095 |
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",
... | 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 | train | 230,096 |
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",
"|"... | 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 | train | 230,097 |
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"... | add a button | [
"add",
"a",
"button"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py#L100-L109 | train | 230,098 |
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",
... | 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 | train | 230,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.