id
int32 0
252k
| repo
stringlengths 7
55
| path
stringlengths 4
127
| func_name
stringlengths 1
88
| original_string
stringlengths 75
19.8k
| language
stringclasses 1
value | code
stringlengths 75
19.8k
| code_tokens
list | docstring
stringlengths 3
17.3k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 87
242
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,100
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
|
MAVLink.extended_sys_state_send
|
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False):
'''
Provides state for additional features
vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t)
landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t)
'''
return self.send(self.extended_sys_state_encode(vtol_state, landed_state), force_mavlink1=force_mavlink1)
|
python
|
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False):
'''
Provides state for additional features
vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t)
landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t)
'''
return self.send(self.extended_sys_state_encode(vtol_state, landed_state), force_mavlink1=force_mavlink1)
|
[
"def",
"extended_sys_state_send",
"(",
"self",
",",
"vtol_state",
",",
"landed_state",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"extended_sys_state_encode",
"(",
"vtol_state",
",",
"landed_state",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
Provides state for additional features
vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t)
landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. (uint8_t)
|
[
"Provides",
"state",
"for",
"additional",
"features"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12923-L12931
|
235,101
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
|
MAVLink.named_value_float_send
|
def named_value_float_send(self, time_boot_ms, name, value, force_mavlink1=False):
'''
Send a key-value pair as float. The use of this message is discouraged
for normal packets, but a quite efficient way for
testing new messages and getting experimental debug
output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Floating point value (float)
'''
return self.send(self.named_value_float_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
|
python
|
def named_value_float_send(self, time_boot_ms, name, value, force_mavlink1=False):
'''
Send a key-value pair as float. The use of this message is discouraged
for normal packets, but a quite efficient way for
testing new messages and getting experimental debug
output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Floating point value (float)
'''
return self.send(self.named_value_float_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
|
[
"def",
"named_value_float_send",
"(",
"self",
",",
"time_boot_ms",
",",
"name",
",",
"value",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"named_value_float_encode",
"(",
"time_boot_ms",
",",
"name",
",",
"value",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
Send a key-value pair as float. The use of this message is discouraged
for normal packets, but a quite efficient way for
testing new messages and getting experimental debug
output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Floating point value (float)
|
[
"Send",
"a",
"key",
"-",
"value",
"pair",
"as",
"float",
".",
"The",
"use",
"of",
"this",
"message",
"is",
"discouraged",
"for",
"normal",
"packets",
"but",
"a",
"quite",
"efficient",
"way",
"for",
"testing",
"new",
"messages",
"and",
"getting",
"experimental",
"debug",
"output",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13101-L13113
|
235,102
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
|
MAVLink.named_value_int_send
|
def named_value_int_send(self, time_boot_ms, name, value, force_mavlink1=False):
'''
Send a key-value pair as integer. The use of this message is
discouraged for normal packets, but a quite efficient
way for testing new messages and getting experimental
debug output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Signed integer value (int32_t)
'''
return self.send(self.named_value_int_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
|
python
|
def named_value_int_send(self, time_boot_ms, name, value, force_mavlink1=False):
'''
Send a key-value pair as integer. The use of this message is
discouraged for normal packets, but a quite efficient
way for testing new messages and getting experimental
debug output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Signed integer value (int32_t)
'''
return self.send(self.named_value_int_encode(time_boot_ms, name, value), force_mavlink1=force_mavlink1)
|
[
"def",
"named_value_int_send",
"(",
"self",
",",
"time_boot_ms",
",",
"name",
",",
"value",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"named_value_int_encode",
"(",
"time_boot_ms",
",",
"name",
",",
"value",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
Send a key-value pair as integer. The use of this message is
discouraged for normal packets, but a quite efficient
way for testing new messages and getting experimental
debug output.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
name : Name of the debug variable (char)
value : Signed integer value (int32_t)
|
[
"Send",
"a",
"key",
"-",
"value",
"pair",
"as",
"integer",
".",
"The",
"use",
"of",
"this",
"message",
"is",
"discouraged",
"for",
"normal",
"packets",
"but",
"a",
"quite",
"efficient",
"way",
"for",
"testing",
"new",
"messages",
"and",
"getting",
"experimental",
"debug",
"output",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13129-L13141
|
235,103
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
|
MAVLink.debug_send
|
def debug_send(self, time_boot_ms, ind, value, force_mavlink1=False):
'''
Send a debug value. The index is used to discriminate between values.
These values show up in the plot of QGroundControl as
DEBUG N.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
ind : index of debug variable (uint8_t)
value : DEBUG value (float)
'''
return self.send(self.debug_encode(time_boot_ms, ind, value), force_mavlink1=force_mavlink1)
|
python
|
def debug_send(self, time_boot_ms, ind, value, force_mavlink1=False):
'''
Send a debug value. The index is used to discriminate between values.
These values show up in the plot of QGroundControl as
DEBUG N.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
ind : index of debug variable (uint8_t)
value : DEBUG value (float)
'''
return self.send(self.debug_encode(time_boot_ms, ind, value), force_mavlink1=force_mavlink1)
|
[
"def",
"debug_send",
"(",
"self",
",",
"time_boot_ms",
",",
"ind",
",",
"value",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"debug_encode",
"(",
"time_boot_ms",
",",
"ind",
",",
"value",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
Send a debug value. The index is used to discriminate between values.
These values show up in the plot of QGroundControl as
DEBUG N.
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
ind : index of debug variable (uint8_t)
value : DEBUG value (float)
|
[
"Send",
"a",
"debug",
"value",
".",
"The",
"index",
"is",
"used",
"to",
"discriminate",
"between",
"values",
".",
"These",
"values",
"show",
"up",
"in",
"the",
"plot",
"of",
"QGroundControl",
"as",
"DEBUG",
"N",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L13186-L13197
|
235,104
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/publisherMotors.py
|
PublisherMotors.sendVX
|
def sendVX(self, vx):
'''
Sends VX velocity.
@param vx: VX velocity
@type vx: float
'''
self.lock.acquire()
self.data.vx = vx
self.lock.release()
|
python
|
def sendVX(self, vx):
'''
Sends VX velocity.
@param vx: VX velocity
@type vx: float
'''
self.lock.acquire()
self.data.vx = vx
self.lock.release()
|
[
"def",
"sendVX",
"(",
"self",
",",
"vx",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"self",
".",
"data",
".",
"vx",
"=",
"vx",
"self",
".",
"lock",
".",
"release",
"(",
")"
] |
Sends VX velocity.
@param vx: VX velocity
@type vx: float
|
[
"Sends",
"VX",
"velocity",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L138-L149
|
235,105
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/publisherMotors.py
|
PublisherMotors.sendVY
|
def sendVY(self, vy):
'''
Sends VY velocity.
@param vy: VY velocity
@type vy: float
'''
self.lock.acquire()
self.data.vy = vy
self.lock.release()
|
python
|
def sendVY(self, vy):
'''
Sends VY velocity.
@param vy: VY velocity
@type vy: float
'''
self.lock.acquire()
self.data.vy = vy
self.lock.release()
|
[
"def",
"sendVY",
"(",
"self",
",",
"vy",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"self",
".",
"data",
".",
"vy",
"=",
"vy",
"self",
".",
"lock",
".",
"release",
"(",
")"
] |
Sends VY velocity.
@param vy: VY velocity
@type vy: float
|
[
"Sends",
"VY",
"velocity",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L151-L162
|
235,106
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/publisherMotors.py
|
PublisherMotors.sendAZ
|
def sendAZ(self, az):
'''
Sends AZ velocity.
@param az: AZ velocity
@type az: float
'''
self.lock.acquire()
self.data.az = az
self.lock.release()
|
python
|
def sendAZ(self, az):
'''
Sends AZ velocity.
@param az: AZ velocity
@type az: float
'''
self.lock.acquire()
self.data.az = az
self.lock.release()
|
[
"def",
"sendAZ",
"(",
"self",
",",
"az",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"self",
".",
"data",
".",
"az",
"=",
"az",
"self",
".",
"lock",
".",
"release",
"(",
")"
] |
Sends AZ velocity.
@param az: AZ velocity
@type az: float
|
[
"Sends",
"AZ",
"velocity",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/publisherMotors.py#L164-L175
|
235,107
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/listenerBumper.py
|
bumperEvent2BumperData
|
def bumperEvent2BumperData(event):
'''
Translates from ROS BumperScan to JderobotTypes BumperData.
@param event: ROS BumperScan to translate
@type event: BumperScan
@return a BumperData translated from event
# bumper
LEFT = 0
CENTER = 1
RIGHT = 2
# state
RELEASED = 0
PRESSED = 1
'''
bump = BumperData()
bump.state = event.state
bump.bumper = event.bumper
#bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9)
return bump
|
python
|
def bumperEvent2BumperData(event):
'''
Translates from ROS BumperScan to JderobotTypes BumperData.
@param event: ROS BumperScan to translate
@type event: BumperScan
@return a BumperData translated from event
# bumper
LEFT = 0
CENTER = 1
RIGHT = 2
# state
RELEASED = 0
PRESSED = 1
'''
bump = BumperData()
bump.state = event.state
bump.bumper = event.bumper
#bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9)
return bump
|
[
"def",
"bumperEvent2BumperData",
"(",
"event",
")",
":",
"bump",
"=",
"BumperData",
"(",
")",
"bump",
".",
"state",
"=",
"event",
".",
"state",
"bump",
".",
"bumper",
"=",
"event",
".",
"bumper",
"#bump.timeStamp = event.header.stamp.secs + (event.header.stamp.nsecs *1e-9)",
"return",
"bump"
] |
Translates from ROS BumperScan to JderobotTypes BumperData.
@param event: ROS BumperScan to translate
@type event: BumperScan
@return a BumperData translated from event
# bumper
LEFT = 0
CENTER = 1
RIGHT = 2
# state
RELEASED = 0
PRESSED = 1
|
[
"Translates",
"from",
"ROS",
"BumperScan",
"to",
"JderobotTypes",
"BumperData",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L11-L36
|
235,108
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/listenerBumper.py
|
ListenerBumper.__callback
|
def __callback (self, event):
'''
Callback function to receive and save Bumper Scans.
@param event: ROS BumperScan received
@type event: BumperScan
'''
bump = bumperEvent2BumperData(event)
if bump.state == 1:
self.lock.acquire()
self.time = current_milli_time()
self.data = bump
self.lock.release()
|
python
|
def __callback (self, event):
'''
Callback function to receive and save Bumper Scans.
@param event: ROS BumperScan received
@type event: BumperScan
'''
bump = bumperEvent2BumperData(event)
if bump.state == 1:
self.lock.acquire()
self.time = current_milli_time()
self.data = bump
self.lock.release()
|
[
"def",
"__callback",
"(",
"self",
",",
"event",
")",
":",
"bump",
"=",
"bumperEvent2BumperData",
"(",
"event",
")",
"if",
"bump",
".",
"state",
"==",
"1",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"self",
".",
"time",
"=",
"current_milli_time",
"(",
")",
"self",
".",
"data",
"=",
"bump",
"self",
".",
"lock",
".",
"release",
"(",
")"
] |
Callback function to receive and save Bumper Scans.
@param event: ROS BumperScan received
@type event: BumperScan
|
[
"Callback",
"function",
"to",
"receive",
"and",
"save",
"Bumper",
"Scans",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L58-L73
|
235,109
|
JdeRobot/base
|
src/libs/comm_py/comm/ros/listenerBumper.py
|
ListenerBumper.getBumperData
|
def getBumperData(self):
'''
Returns last BumperData.
@return last JdeRobotTypes BumperData saved
'''
self.lock.acquire()
t = current_milli_time()
if (t - self.time) > 500:
self.data.state = 0
bump = self.data
self.lock.release()
return bump
|
python
|
def getBumperData(self):
'''
Returns last BumperData.
@return last JdeRobotTypes BumperData saved
'''
self.lock.acquire()
t = current_milli_time()
if (t - self.time) > 500:
self.data.state = 0
bump = self.data
self.lock.release()
return bump
|
[
"def",
"getBumperData",
"(",
"self",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"t",
"=",
"current_milli_time",
"(",
")",
"if",
"(",
"t",
"-",
"self",
".",
"time",
")",
">",
"500",
":",
"self",
".",
"data",
".",
"state",
"=",
"0",
"bump",
"=",
"self",
".",
"data",
"self",
".",
"lock",
".",
"release",
"(",
")",
"return",
"bump"
] |
Returns last BumperData.
@return last JdeRobotTypes BumperData saved
|
[
"Returns",
"last",
"BumperData",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerBumper.py#L89-L103
|
235,110
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py
|
BatteryModule.cmd_bat
|
def cmd_bat(self, args):
'''show battery levels'''
print("Flight battery: %u%%" % self.battery_level)
if self.settings.numcells != 0:
print("%.2f V/cell for %u cells - approx %u%%" % (self.per_cell,
self.settings.numcells,
self.vcell_to_battery_percent(self.per_cell)))
|
python
|
def cmd_bat(self, args):
'''show battery levels'''
print("Flight battery: %u%%" % self.battery_level)
if self.settings.numcells != 0:
print("%.2f V/cell for %u cells - approx %u%%" % (self.per_cell,
self.settings.numcells,
self.vcell_to_battery_percent(self.per_cell)))
|
[
"def",
"cmd_bat",
"(",
"self",
",",
"args",
")",
":",
"print",
"(",
"\"Flight battery: %u%%\"",
"%",
"self",
".",
"battery_level",
")",
"if",
"self",
".",
"settings",
".",
"numcells",
"!=",
"0",
":",
"print",
"(",
"\"%.2f V/cell for %u cells - approx %u%%\"",
"%",
"(",
"self",
".",
"per_cell",
",",
"self",
".",
"settings",
".",
"numcells",
",",
"self",
".",
"vcell_to_battery_percent",
"(",
"self",
".",
"per_cell",
")",
")",
")"
] |
show battery levels
|
[
"show",
"battery",
"levels"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py#L38-L44
|
235,111
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py
|
BatteryModule.battery_update
|
def battery_update(self, SYS_STATUS):
'''update battery level'''
# main flight battery
self.battery_level = SYS_STATUS.battery_remaining
self.voltage_level = SYS_STATUS.voltage_battery
self.current_battery = SYS_STATUS.current_battery
if self.settings.numcells != 0:
self.per_cell = (self.voltage_level*0.001) / self.settings.numcells
|
python
|
def battery_update(self, SYS_STATUS):
'''update battery level'''
# main flight battery
self.battery_level = SYS_STATUS.battery_remaining
self.voltage_level = SYS_STATUS.voltage_battery
self.current_battery = SYS_STATUS.current_battery
if self.settings.numcells != 0:
self.per_cell = (self.voltage_level*0.001) / self.settings.numcells
|
[
"def",
"battery_update",
"(",
"self",
",",
"SYS_STATUS",
")",
":",
"# main flight battery",
"self",
".",
"battery_level",
"=",
"SYS_STATUS",
".",
"battery_remaining",
"self",
".",
"voltage_level",
"=",
"SYS_STATUS",
".",
"voltage_battery",
"self",
".",
"current_battery",
"=",
"SYS_STATUS",
".",
"current_battery",
"if",
"self",
".",
"settings",
".",
"numcells",
"!=",
"0",
":",
"self",
".",
"per_cell",
"=",
"(",
"self",
".",
"voltage_level",
"*",
"0.001",
")",
"/",
"self",
".",
"settings",
".",
"numcells"
] |
update battery level
|
[
"update",
"battery",
"level"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py#L92-L99
|
235,112
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
|
CalibrationModule.cmd_accelcal
|
def cmd_accelcal(self, args):
'''do a full 3D accel calibration'''
mav = self.master
# ack the APM to begin 3D calibration of accelerometers
mav.mav.command_long_send(mav.target_system, mav.target_component,
mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
0, 0, 0, 0, 1, 0, 0)
self.accelcal_count = 0
self.accelcal_wait_enter = False
|
python
|
def cmd_accelcal(self, args):
'''do a full 3D accel calibration'''
mav = self.master
# ack the APM to begin 3D calibration of accelerometers
mav.mav.command_long_send(mav.target_system, mav.target_component,
mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
0, 0, 0, 0, 1, 0, 0)
self.accelcal_count = 0
self.accelcal_wait_enter = False
|
[
"def",
"cmd_accelcal",
"(",
"self",
",",
"args",
")",
":",
"mav",
"=",
"self",
".",
"master",
"# ack the APM to begin 3D calibration of accelerometers",
"mav",
".",
"mav",
".",
"command_long_send",
"(",
"mav",
".",
"target_system",
",",
"mav",
".",
"target_component",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_PREFLIGHT_CALIBRATION",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
",",
"0",
",",
"0",
")",
"self",
".",
"accelcal_count",
"=",
"0",
"self",
".",
"accelcal_wait_enter",
"=",
"False"
] |
do a full 3D accel calibration
|
[
"do",
"a",
"full",
"3D",
"accel",
"calibration"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L34-L42
|
235,113
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
|
CalibrationModule.cmd_gyrocal
|
def cmd_gyrocal(self, args):
'''do a full gyro calibration'''
mav = self.master
mav.mav.command_long_send(mav.target_system, mav.target_component,
mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
1, 0, 0, 0, 0, 0, 0)
|
python
|
def cmd_gyrocal(self, args):
'''do a full gyro calibration'''
mav = self.master
mav.mav.command_long_send(mav.target_system, mav.target_component,
mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
1, 0, 0, 0, 0, 0, 0)
|
[
"def",
"cmd_gyrocal",
"(",
"self",
",",
"args",
")",
":",
"mav",
"=",
"self",
".",
"master",
"mav",
".",
"mav",
".",
"command_long_send",
"(",
"mav",
".",
"target_system",
",",
"mav",
".",
"target_component",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_PREFLIGHT_CALIBRATION",
",",
"0",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")"
] |
do a full gyro calibration
|
[
"do",
"a",
"full",
"gyro",
"calibration"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L44-L49
|
235,114
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py
|
CalibrationModule.cmd_magcal
|
def cmd_magcal(self, args):
'''control magnetometer calibration'''
if len(args) < 1:
print("Usage: magcal <start|accept|cancel>")
return
if args[0] == 'start':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_START_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # p2: retry
1, # p3: autosave
0, # p4: delay
0, # param5
0, # param6
0) # param7
elif args[0] == 'accept':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_ACCEPT_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # param2
1, # param3
0, # param4
0, # param5
0, # param6
0) # param7
elif args[0] == 'cancel':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_CANCEL_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # param2
1, # param3
0, # param4
0, # param5
0, # param6
0)
|
python
|
def cmd_magcal(self, args):
'''control magnetometer calibration'''
if len(args) < 1:
print("Usage: magcal <start|accept|cancel>")
return
if args[0] == 'start':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_START_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # p2: retry
1, # p3: autosave
0, # p4: delay
0, # param5
0, # param6
0) # param7
elif args[0] == 'accept':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_ACCEPT_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # param2
1, # param3
0, # param4
0, # param5
0, # param6
0) # param7
elif args[0] == 'cancel':
self.master.mav.command_long_send(
self.settings.target_system, # target_system
0, # target_component
mavutil.mavlink.MAV_CMD_DO_CANCEL_MAG_CAL, # command
0, # confirmation
0, # p1: mag_mask
0, # param2
1, # param3
0, # param4
0, # param5
0, # param6
0)
|
[
"def",
"cmd_magcal",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"\"Usage: magcal <start|accept|cancel>\"",
")",
"return",
"if",
"args",
"[",
"0",
"]",
"==",
"'start'",
":",
"self",
".",
"master",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"settings",
".",
"target_system",
",",
"# target_system",
"0",
",",
"# target_component",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_DO_START_MAG_CAL",
",",
"# command",
"0",
",",
"# confirmation",
"0",
",",
"# p1: mag_mask",
"0",
",",
"# p2: retry",
"1",
",",
"# p3: autosave",
"0",
",",
"# p4: delay",
"0",
",",
"# param5",
"0",
",",
"# param6",
"0",
")",
"# param7",
"elif",
"args",
"[",
"0",
"]",
"==",
"'accept'",
":",
"self",
".",
"master",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"settings",
".",
"target_system",
",",
"# target_system",
"0",
",",
"# target_component",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_DO_ACCEPT_MAG_CAL",
",",
"# command",
"0",
",",
"# confirmation",
"0",
",",
"# p1: mag_mask",
"0",
",",
"# param2",
"1",
",",
"# param3",
"0",
",",
"# param4",
"0",
",",
"# param5",
"0",
",",
"# param6",
"0",
")",
"# param7",
"elif",
"args",
"[",
"0",
"]",
"==",
"'cancel'",
":",
"self",
".",
"master",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"settings",
".",
"target_system",
",",
"# target_system",
"0",
",",
"# target_component",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_DO_CANCEL_MAG_CAL",
",",
"# command",
"0",
",",
"# confirmation",
"0",
",",
"# p1: mag_mask",
"0",
",",
"# param2",
"1",
",",
"# param3",
"0",
",",
"# param4",
"0",
",",
"# param5",
"0",
",",
"# param6",
"0",
")"
] |
control magnetometer calibration
|
[
"control",
"magnetometer",
"calibration"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_calibration.py#L114-L158
|
235,115
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.set_fence_enabled
|
def set_fence_enabled(self, do_enable):
'''Enable or disable fence'''
self.master.mav.command_long_send(
self.target_system,
self.target_component,
mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, 0,
do_enable, 0, 0, 0, 0, 0, 0)
|
python
|
def set_fence_enabled(self, do_enable):
'''Enable or disable fence'''
self.master.mav.command_long_send(
self.target_system,
self.target_component,
mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, 0,
do_enable, 0, 0, 0, 0, 0, 0)
|
[
"def",
"set_fence_enabled",
"(",
"self",
",",
"do_enable",
")",
":",
"self",
".",
"master",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"target_system",
",",
"self",
".",
"target_component",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_DO_FENCE_ENABLE",
",",
"0",
",",
"do_enable",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")"
] |
Enable or disable fence
|
[
"Enable",
"or",
"disable",
"fence"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L96-L102
|
235,116
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.cmd_fence_move
|
def cmd_fence_move(self, args):
'''handle fencepoint move'''
if len(args) < 1:
print("Usage: fence move FENCEPOINTNUM")
return
if not self.have_list:
print("Please list fence points first")
return
idx = int(args[0])
if idx <= 0 or idx > self.fenceloader.count():
print("Invalid fence point number %u" % idx)
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
# note we don't subtract 1, as first fence point is the return point
self.fenceloader.move(idx, latlon[0], latlon[1])
if self.send_fence():
print("Moved fence point %u" % idx)
|
python
|
def cmd_fence_move(self, args):
'''handle fencepoint move'''
if len(args) < 1:
print("Usage: fence move FENCEPOINTNUM")
return
if not self.have_list:
print("Please list fence points first")
return
idx = int(args[0])
if idx <= 0 or idx > self.fenceloader.count():
print("Invalid fence point number %u" % idx)
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
# note we don't subtract 1, as first fence point is the return point
self.fenceloader.move(idx, latlon[0], latlon[1])
if self.send_fence():
print("Moved fence point %u" % idx)
|
[
"def",
"cmd_fence_move",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"\"Usage: fence move FENCEPOINTNUM\"",
")",
"return",
"if",
"not",
"self",
".",
"have_list",
":",
"print",
"(",
"\"Please list fence points first\"",
")",
"return",
"idx",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"if",
"idx",
"<=",
"0",
"or",
"idx",
">",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
":",
"print",
"(",
"\"Invalid fence point number %u\"",
"%",
"idx",
")",
"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",
"# note we don't subtract 1, as first fence point is the return point",
"self",
".",
"fenceloader",
".",
"move",
"(",
"idx",
",",
"latlon",
"[",
"0",
"]",
",",
"latlon",
"[",
"1",
"]",
")",
"if",
"self",
".",
"send_fence",
"(",
")",
":",
"print",
"(",
"\"Moved fence point %u\"",
"%",
"idx",
")"
] |
handle fencepoint move
|
[
"handle",
"fencepoint",
"move"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L104-L130
|
235,117
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.cmd_fence_remove
|
def cmd_fence_remove(self, args):
'''handle fencepoint remove'''
if len(args) < 1:
print("Usage: fence remove FENCEPOINTNUM")
return
if not self.have_list:
print("Please list fence points first")
return
idx = int(args[0])
if idx <= 0 or idx > self.fenceloader.count():
print("Invalid fence point number %u" % idx)
return
# note we don't subtract 1, as first fence point is the return point
self.fenceloader.remove(idx)
if self.send_fence():
print("Removed fence point %u" % idx)
else:
print("Failed to remove fence point %u" % idx)
|
python
|
def cmd_fence_remove(self, args):
'''handle fencepoint remove'''
if len(args) < 1:
print("Usage: fence remove FENCEPOINTNUM")
return
if not self.have_list:
print("Please list fence points first")
return
idx = int(args[0])
if idx <= 0 or idx > self.fenceloader.count():
print("Invalid fence point number %u" % idx)
return
# note we don't subtract 1, as first fence point is the return point
self.fenceloader.remove(idx)
if self.send_fence():
print("Removed fence point %u" % idx)
else:
print("Failed to remove fence point %u" % idx)
|
[
"def",
"cmd_fence_remove",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"\"Usage: fence remove FENCEPOINTNUM\"",
")",
"return",
"if",
"not",
"self",
".",
"have_list",
":",
"print",
"(",
"\"Please list fence points first\"",
")",
"return",
"idx",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"if",
"idx",
"<=",
"0",
"or",
"idx",
">",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
":",
"print",
"(",
"\"Invalid fence point number %u\"",
"%",
"idx",
")",
"return",
"# note we don't subtract 1, as first fence point is the return point",
"self",
".",
"fenceloader",
".",
"remove",
"(",
"idx",
")",
"if",
"self",
".",
"send_fence",
"(",
")",
":",
"print",
"(",
"\"Removed fence point %u\"",
"%",
"idx",
")",
"else",
":",
"print",
"(",
"\"Failed to remove fence point %u\"",
"%",
"idx",
")"
] |
handle fencepoint remove
|
[
"handle",
"fencepoint",
"remove"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L132-L151
|
235,118
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.send_fence
|
def send_fence(self):
'''send fence points from fenceloader'''
# must disable geo-fencing when loading
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
self.fenceloader.reindex()
action = self.get_mav_param('FENCE_ACTION', mavutil.mavlink.FENCE_ACTION_NONE)
self.param_set('FENCE_ACTION', mavutil.mavlink.FENCE_ACTION_NONE, 3)
self.param_set('FENCE_TOTAL', self.fenceloader.count(), 3)
for i in range(self.fenceloader.count()):
p = self.fenceloader.point(i)
self.master.mav.send(p)
p2 = self.fetch_fence_point(i)
if p2 is None:
self.param_set('FENCE_ACTION', action, 3)
return False
if (p.idx != p2.idx or
abs(p.lat - p2.lat) >= 0.00003 or
abs(p.lng - p2.lng) >= 0.00003):
print("Failed to send fence point %u" % i)
self.param_set('FENCE_ACTION', action, 3)
return False
self.param_set('FENCE_ACTION', action, 3)
return True
|
python
|
def send_fence(self):
'''send fence points from fenceloader'''
# must disable geo-fencing when loading
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
self.fenceloader.reindex()
action = self.get_mav_param('FENCE_ACTION', mavutil.mavlink.FENCE_ACTION_NONE)
self.param_set('FENCE_ACTION', mavutil.mavlink.FENCE_ACTION_NONE, 3)
self.param_set('FENCE_TOTAL', self.fenceloader.count(), 3)
for i in range(self.fenceloader.count()):
p = self.fenceloader.point(i)
self.master.mav.send(p)
p2 = self.fetch_fence_point(i)
if p2 is None:
self.param_set('FENCE_ACTION', action, 3)
return False
if (p.idx != p2.idx or
abs(p.lat - p2.lat) >= 0.00003 or
abs(p.lng - p2.lng) >= 0.00003):
print("Failed to send fence point %u" % i)
self.param_set('FENCE_ACTION', action, 3)
return False
self.param_set('FENCE_ACTION', action, 3)
return True
|
[
"def",
"send_fence",
"(",
"self",
")",
":",
"# must disable geo-fencing when loading",
"self",
".",
"fenceloader",
".",
"target_system",
"=",
"self",
".",
"target_system",
"self",
".",
"fenceloader",
".",
"target_component",
"=",
"self",
".",
"target_component",
"self",
".",
"fenceloader",
".",
"reindex",
"(",
")",
"action",
"=",
"self",
".",
"get_mav_param",
"(",
"'FENCE_ACTION'",
",",
"mavutil",
".",
"mavlink",
".",
"FENCE_ACTION_NONE",
")",
"self",
".",
"param_set",
"(",
"'FENCE_ACTION'",
",",
"mavutil",
".",
"mavlink",
".",
"FENCE_ACTION_NONE",
",",
"3",
")",
"self",
".",
"param_set",
"(",
"'FENCE_TOTAL'",
",",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
",",
"3",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
")",
":",
"p",
"=",
"self",
".",
"fenceloader",
".",
"point",
"(",
"i",
")",
"self",
".",
"master",
".",
"mav",
".",
"send",
"(",
"p",
")",
"p2",
"=",
"self",
".",
"fetch_fence_point",
"(",
"i",
")",
"if",
"p2",
"is",
"None",
":",
"self",
".",
"param_set",
"(",
"'FENCE_ACTION'",
",",
"action",
",",
"3",
")",
"return",
"False",
"if",
"(",
"p",
".",
"idx",
"!=",
"p2",
".",
"idx",
"or",
"abs",
"(",
"p",
".",
"lat",
"-",
"p2",
".",
"lat",
")",
">=",
"0.00003",
"or",
"abs",
"(",
"p",
".",
"lng",
"-",
"p2",
".",
"lng",
")",
">=",
"0.00003",
")",
":",
"print",
"(",
"\"Failed to send fence point %u\"",
"%",
"i",
")",
"self",
".",
"param_set",
"(",
"'FENCE_ACTION'",
",",
"action",
",",
"3",
")",
"return",
"False",
"self",
".",
"param_set",
"(",
"'FENCE_ACTION'",
",",
"action",
",",
"3",
")",
"return",
"True"
] |
send fence points from fenceloader
|
[
"send",
"fence",
"points",
"from",
"fenceloader"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L208-L231
|
235,119
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.fetch_fence_point
|
def fetch_fence_point(self ,i):
'''fetch one fence point'''
self.master.mav.fence_fetch_point_send(self.target_system,
self.target_component, i)
tstart = time.time()
p = None
while time.time() - tstart < 3:
p = self.master.recv_match(type='FENCE_POINT', blocking=False)
if p is not None:
break
time.sleep(0.1)
continue
if p is None:
self.console.error("Failed to fetch point %u" % i)
return None
return p
|
python
|
def fetch_fence_point(self ,i):
'''fetch one fence point'''
self.master.mav.fence_fetch_point_send(self.target_system,
self.target_component, i)
tstart = time.time()
p = None
while time.time() - tstart < 3:
p = self.master.recv_match(type='FENCE_POINT', blocking=False)
if p is not None:
break
time.sleep(0.1)
continue
if p is None:
self.console.error("Failed to fetch point %u" % i)
return None
return p
|
[
"def",
"fetch_fence_point",
"(",
"self",
",",
"i",
")",
":",
"self",
".",
"master",
".",
"mav",
".",
"fence_fetch_point_send",
"(",
"self",
".",
"target_system",
",",
"self",
".",
"target_component",
",",
"i",
")",
"tstart",
"=",
"time",
".",
"time",
"(",
")",
"p",
"=",
"None",
"while",
"time",
".",
"time",
"(",
")",
"-",
"tstart",
"<",
"3",
":",
"p",
"=",
"self",
".",
"master",
".",
"recv_match",
"(",
"type",
"=",
"'FENCE_POINT'",
",",
"blocking",
"=",
"False",
")",
"if",
"p",
"is",
"not",
"None",
":",
"break",
"time",
".",
"sleep",
"(",
"0.1",
")",
"continue",
"if",
"p",
"is",
"None",
":",
"self",
".",
"console",
".",
"error",
"(",
"\"Failed to fetch point %u\"",
"%",
"i",
")",
"return",
"None",
"return",
"p"
] |
fetch one fence point
|
[
"fetch",
"one",
"fence",
"point"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L233-L248
|
235,120
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py
|
FenceModule.fence_draw_callback
|
def fence_draw_callback(self, points):
'''callback from drawing a fence'''
self.fenceloader.clear()
if len(points) < 3:
return
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
bounds = mp_util.polygon_bounds(points)
(lat, lon, width, height) = bounds
center = (lat+width/2, lon+height/2)
self.fenceloader.add_latlon(center[0], center[1])
for p in points:
self.fenceloader.add_latlon(p[0], p[1])
# close it
self.fenceloader.add_latlon(points[0][0], points[0][1])
self.send_fence()
self.have_list = True
|
python
|
def fence_draw_callback(self, points):
'''callback from drawing a fence'''
self.fenceloader.clear()
if len(points) < 3:
return
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
bounds = mp_util.polygon_bounds(points)
(lat, lon, width, height) = bounds
center = (lat+width/2, lon+height/2)
self.fenceloader.add_latlon(center[0], center[1])
for p in points:
self.fenceloader.add_latlon(p[0], p[1])
# close it
self.fenceloader.add_latlon(points[0][0], points[0][1])
self.send_fence()
self.have_list = True
|
[
"def",
"fence_draw_callback",
"(",
"self",
",",
"points",
")",
":",
"self",
".",
"fenceloader",
".",
"clear",
"(",
")",
"if",
"len",
"(",
"points",
")",
"<",
"3",
":",
"return",
"self",
".",
"fenceloader",
".",
"target_system",
"=",
"self",
".",
"target_system",
"self",
".",
"fenceloader",
".",
"target_component",
"=",
"self",
".",
"target_component",
"bounds",
"=",
"mp_util",
".",
"polygon_bounds",
"(",
"points",
")",
"(",
"lat",
",",
"lon",
",",
"width",
",",
"height",
")",
"=",
"bounds",
"center",
"=",
"(",
"lat",
"+",
"width",
"/",
"2",
",",
"lon",
"+",
"height",
"/",
"2",
")",
"self",
".",
"fenceloader",
".",
"add_latlon",
"(",
"center",
"[",
"0",
"]",
",",
"center",
"[",
"1",
"]",
")",
"for",
"p",
"in",
"points",
":",
"self",
".",
"fenceloader",
".",
"add_latlon",
"(",
"p",
"[",
"0",
"]",
",",
"p",
"[",
"1",
"]",
")",
"# close it",
"self",
".",
"fenceloader",
".",
"add_latlon",
"(",
"points",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"points",
"[",
"0",
"]",
"[",
"1",
"]",
")",
"self",
".",
"send_fence",
"(",
")",
"self",
".",
"have_list",
"=",
"True"
] |
callback from drawing a fence
|
[
"callback",
"from",
"drawing",
"a",
"fence"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_fence.py#L250-L266
|
235,121
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py
|
ConsoleModule.add_menu
|
def add_menu(self, menu):
'''add a new menu'''
self.menu.add(menu)
self.mpstate.console.set_menu(self.menu, self.menu_callback)
|
python
|
def add_menu(self, menu):
'''add a new menu'''
self.menu.add(menu)
self.mpstate.console.set_menu(self.menu, self.menu_callback)
|
[
"def",
"add_menu",
"(",
"self",
",",
"menu",
")",
":",
"self",
".",
"menu",
".",
"add",
"(",
"menu",
")",
"self",
".",
"mpstate",
".",
"console",
".",
"set_menu",
"(",
"self",
".",
"menu",
",",
"self",
".",
"menu_callback",
")"
] |
add a new menu
|
[
"add",
"a",
"new",
"menu"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py#L67-L70
|
235,122
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py
|
ConsoleModule.estimated_time_remaining
|
def estimated_time_remaining(self, lat, lon, wpnum, speed):
'''estimate time remaining in mission in seconds'''
idx = wpnum
if wpnum >= self.module('wp').wploader.count():
return 0
distance = 0
done = set()
while idx < self.module('wp').wploader.count():
if idx in done:
break
done.add(idx)
w = self.module('wp').wploader.wp(idx)
if w.command == mavutil.mavlink.MAV_CMD_DO_JUMP:
idx = int(w.param1)
continue
idx += 1
if (w.x != 0 or w.y != 0) and w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME,
mavutil.mavlink.MAV_CMD_NAV_LAND,
mavutil.mavlink.MAV_CMD_NAV_TAKEOFF]:
distance += mp_util.gps_distance(lat, lon, w.x, w.y)
lat = w.x
lon = w.y
if w.command == mavutil.mavlink.MAV_CMD_NAV_LAND:
break
return distance / speed
|
python
|
def estimated_time_remaining(self, lat, lon, wpnum, speed):
'''estimate time remaining in mission in seconds'''
idx = wpnum
if wpnum >= self.module('wp').wploader.count():
return 0
distance = 0
done = set()
while idx < self.module('wp').wploader.count():
if idx in done:
break
done.add(idx)
w = self.module('wp').wploader.wp(idx)
if w.command == mavutil.mavlink.MAV_CMD_DO_JUMP:
idx = int(w.param1)
continue
idx += 1
if (w.x != 0 or w.y != 0) and w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME,
mavutil.mavlink.MAV_CMD_NAV_LAND,
mavutil.mavlink.MAV_CMD_NAV_TAKEOFF]:
distance += mp_util.gps_distance(lat, lon, w.x, w.y)
lat = w.x
lon = w.y
if w.command == mavutil.mavlink.MAV_CMD_NAV_LAND:
break
return distance / speed
|
[
"def",
"estimated_time_remaining",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"wpnum",
",",
"speed",
")",
":",
"idx",
"=",
"wpnum",
"if",
"wpnum",
">=",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"count",
"(",
")",
":",
"return",
"0",
"distance",
"=",
"0",
"done",
"=",
"set",
"(",
")",
"while",
"idx",
"<",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"count",
"(",
")",
":",
"if",
"idx",
"in",
"done",
":",
"break",
"done",
".",
"add",
"(",
"idx",
")",
"w",
"=",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"wp",
"(",
"idx",
")",
"if",
"w",
".",
"command",
"==",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_DO_JUMP",
":",
"idx",
"=",
"int",
"(",
"w",
".",
"param1",
")",
"continue",
"idx",
"+=",
"1",
"if",
"(",
"w",
".",
"x",
"!=",
"0",
"or",
"w",
".",
"y",
"!=",
"0",
")",
"and",
"w",
".",
"command",
"in",
"[",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_WAYPOINT",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_LOITER_UNLIM",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_LOITER_TURNS",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_LOITER_TIME",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_LAND",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_TAKEOFF",
"]",
":",
"distance",
"+=",
"mp_util",
".",
"gps_distance",
"(",
"lat",
",",
"lon",
",",
"w",
".",
"x",
",",
"w",
".",
"y",
")",
"lat",
"=",
"w",
".",
"x",
"lon",
"=",
"w",
".",
"y",
"if",
"w",
".",
"command",
"==",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_NAV_LAND",
":",
"break",
"return",
"distance",
"/",
"speed"
] |
estimate time remaining in mission in seconds
|
[
"estimate",
"time",
"remaining",
"in",
"mission",
"in",
"seconds"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_console.py#L90-L117
|
235,123
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Vector3.angle
|
def angle(self, v):
'''return the angle between this vector and another vector'''
return acos((self * v) / (self.length() * v.length()))
|
python
|
def angle(self, v):
'''return the angle between this vector and another vector'''
return acos((self * v) / (self.length() * v.length()))
|
[
"def",
"angle",
"(",
"self",
",",
"v",
")",
":",
"return",
"acos",
"(",
"(",
"self",
"*",
"v",
")",
"/",
"(",
"self",
".",
"length",
"(",
")",
"*",
"v",
".",
"length",
"(",
")",
")",
")"
] |
return the angle between this vector and another vector
|
[
"return",
"the",
"angle",
"between",
"this",
"vector",
"and",
"another",
"vector"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L114-L116
|
235,124
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.from_euler
|
def from_euler(self, roll, pitch, yaw):
'''fill the matrix from Euler angles in radians'''
cp = cos(pitch)
sp = sin(pitch)
sr = sin(roll)
cr = cos(roll)
sy = sin(yaw)
cy = cos(yaw)
self.a.x = cp * cy
self.a.y = (sr * sp * cy) - (cr * sy)
self.a.z = (cr * sp * cy) + (sr * sy)
self.b.x = cp * sy
self.b.y = (sr * sp * sy) + (cr * cy)
self.b.z = (cr * sp * sy) - (sr * cy)
self.c.x = -sp
self.c.y = sr * cp
self.c.z = cr * cp
|
python
|
def from_euler(self, roll, pitch, yaw):
'''fill the matrix from Euler angles in radians'''
cp = cos(pitch)
sp = sin(pitch)
sr = sin(roll)
cr = cos(roll)
sy = sin(yaw)
cy = cos(yaw)
self.a.x = cp * cy
self.a.y = (sr * sp * cy) - (cr * sy)
self.a.z = (cr * sp * cy) + (sr * sy)
self.b.x = cp * sy
self.b.y = (sr * sp * sy) + (cr * cy)
self.b.z = (cr * sp * sy) - (sr * cy)
self.c.x = -sp
self.c.y = sr * cp
self.c.z = cr * cp
|
[
"def",
"from_euler",
"(",
"self",
",",
"roll",
",",
"pitch",
",",
"yaw",
")",
":",
"cp",
"=",
"cos",
"(",
"pitch",
")",
"sp",
"=",
"sin",
"(",
"pitch",
")",
"sr",
"=",
"sin",
"(",
"roll",
")",
"cr",
"=",
"cos",
"(",
"roll",
")",
"sy",
"=",
"sin",
"(",
"yaw",
")",
"cy",
"=",
"cos",
"(",
"yaw",
")",
"self",
".",
"a",
".",
"x",
"=",
"cp",
"*",
"cy",
"self",
".",
"a",
".",
"y",
"=",
"(",
"sr",
"*",
"sp",
"*",
"cy",
")",
"-",
"(",
"cr",
"*",
"sy",
")",
"self",
".",
"a",
".",
"z",
"=",
"(",
"cr",
"*",
"sp",
"*",
"cy",
")",
"+",
"(",
"sr",
"*",
"sy",
")",
"self",
".",
"b",
".",
"x",
"=",
"cp",
"*",
"sy",
"self",
".",
"b",
".",
"y",
"=",
"(",
"sr",
"*",
"sp",
"*",
"sy",
")",
"+",
"(",
"cr",
"*",
"cy",
")",
"self",
".",
"b",
".",
"z",
"=",
"(",
"cr",
"*",
"sp",
"*",
"sy",
")",
"-",
"(",
"sr",
"*",
"cy",
")",
"self",
".",
"c",
".",
"x",
"=",
"-",
"sp",
"self",
".",
"c",
".",
"y",
"=",
"sr",
"*",
"cp",
"self",
".",
"c",
".",
"z",
"=",
"cr",
"*",
"cp"
] |
fill the matrix from Euler angles in radians
|
[
"fill",
"the",
"matrix",
"from",
"Euler",
"angles",
"in",
"radians"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L154-L171
|
235,125
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.from_euler312
|
def from_euler312(self, roll, pitch, yaw):
'''fill the matrix from Euler angles in radians in 312 convention'''
c3 = cos(pitch)
s3 = sin(pitch)
s2 = sin(roll)
c2 = cos(roll)
s1 = sin(yaw)
c1 = cos(yaw)
self.a.x = c1 * c3 - s1 * s2 * s3
self.b.y = c1 * c2
self.c.z = c3 * c2
self.a.y = -c2*s1
self.a.z = s3*c1 + c3*s2*s1
self.b.x = c3*s1 + s3*s2*c1
self.b.z = s1*s3 - s2*c1*c3
self.c.x = -s3*c2
self.c.y = s2
|
python
|
def from_euler312(self, roll, pitch, yaw):
'''fill the matrix from Euler angles in radians in 312 convention'''
c3 = cos(pitch)
s3 = sin(pitch)
s2 = sin(roll)
c2 = cos(roll)
s1 = sin(yaw)
c1 = cos(yaw)
self.a.x = c1 * c3 - s1 * s2 * s3
self.b.y = c1 * c2
self.c.z = c3 * c2
self.a.y = -c2*s1
self.a.z = s3*c1 + c3*s2*s1
self.b.x = c3*s1 + s3*s2*c1
self.b.z = s1*s3 - s2*c1*c3
self.c.x = -s3*c2
self.c.y = s2
|
[
"def",
"from_euler312",
"(",
"self",
",",
"roll",
",",
"pitch",
",",
"yaw",
")",
":",
"c3",
"=",
"cos",
"(",
"pitch",
")",
"s3",
"=",
"sin",
"(",
"pitch",
")",
"s2",
"=",
"sin",
"(",
"roll",
")",
"c2",
"=",
"cos",
"(",
"roll",
")",
"s1",
"=",
"sin",
"(",
"yaw",
")",
"c1",
"=",
"cos",
"(",
"yaw",
")",
"self",
".",
"a",
".",
"x",
"=",
"c1",
"*",
"c3",
"-",
"s1",
"*",
"s2",
"*",
"s3",
"self",
".",
"b",
".",
"y",
"=",
"c1",
"*",
"c2",
"self",
".",
"c",
".",
"z",
"=",
"c3",
"*",
"c2",
"self",
".",
"a",
".",
"y",
"=",
"-",
"c2",
"*",
"s1",
"self",
".",
"a",
".",
"z",
"=",
"s3",
"*",
"c1",
"+",
"c3",
"*",
"s2",
"*",
"s1",
"self",
".",
"b",
".",
"x",
"=",
"c3",
"*",
"s1",
"+",
"s3",
"*",
"s2",
"*",
"c1",
"self",
".",
"b",
".",
"z",
"=",
"s1",
"*",
"s3",
"-",
"s2",
"*",
"c1",
"*",
"c3",
"self",
".",
"c",
".",
"x",
"=",
"-",
"s3",
"*",
"c2",
"self",
".",
"c",
".",
"y",
"=",
"s2"
] |
fill the matrix from Euler angles in radians in 312 convention
|
[
"fill",
"the",
"matrix",
"from",
"Euler",
"angles",
"in",
"radians",
"in",
"312",
"convention"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L201-L218
|
235,126
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.rotate
|
def rotate(self, g):
'''rotate the matrix by a given amount on 3 axes'''
temp_matrix = Matrix3()
a = self.a
b = self.b
c = self.c
temp_matrix.a.x = a.y * g.z - a.z * g.y
temp_matrix.a.y = a.z * g.x - a.x * g.z
temp_matrix.a.z = a.x * g.y - a.y * g.x
temp_matrix.b.x = b.y * g.z - b.z * g.y
temp_matrix.b.y = b.z * g.x - b.x * g.z
temp_matrix.b.z = b.x * g.y - b.y * g.x
temp_matrix.c.x = c.y * g.z - c.z * g.y
temp_matrix.c.y = c.z * g.x - c.x * g.z
temp_matrix.c.z = c.x * g.y - c.y * g.x
self.a += temp_matrix.a
self.b += temp_matrix.b
self.c += temp_matrix.c
|
python
|
def rotate(self, g):
'''rotate the matrix by a given amount on 3 axes'''
temp_matrix = Matrix3()
a = self.a
b = self.b
c = self.c
temp_matrix.a.x = a.y * g.z - a.z * g.y
temp_matrix.a.y = a.z * g.x - a.x * g.z
temp_matrix.a.z = a.x * g.y - a.y * g.x
temp_matrix.b.x = b.y * g.z - b.z * g.y
temp_matrix.b.y = b.z * g.x - b.x * g.z
temp_matrix.b.z = b.x * g.y - b.y * g.x
temp_matrix.c.x = c.y * g.z - c.z * g.y
temp_matrix.c.y = c.z * g.x - c.x * g.z
temp_matrix.c.z = c.x * g.y - c.y * g.x
self.a += temp_matrix.a
self.b += temp_matrix.b
self.c += temp_matrix.c
|
[
"def",
"rotate",
"(",
"self",
",",
"g",
")",
":",
"temp_matrix",
"=",
"Matrix3",
"(",
")",
"a",
"=",
"self",
".",
"a",
"b",
"=",
"self",
".",
"b",
"c",
"=",
"self",
".",
"c",
"temp_matrix",
".",
"a",
".",
"x",
"=",
"a",
".",
"y",
"*",
"g",
".",
"z",
"-",
"a",
".",
"z",
"*",
"g",
".",
"y",
"temp_matrix",
".",
"a",
".",
"y",
"=",
"a",
".",
"z",
"*",
"g",
".",
"x",
"-",
"a",
".",
"x",
"*",
"g",
".",
"z",
"temp_matrix",
".",
"a",
".",
"z",
"=",
"a",
".",
"x",
"*",
"g",
".",
"y",
"-",
"a",
".",
"y",
"*",
"g",
".",
"x",
"temp_matrix",
".",
"b",
".",
"x",
"=",
"b",
".",
"y",
"*",
"g",
".",
"z",
"-",
"b",
".",
"z",
"*",
"g",
".",
"y",
"temp_matrix",
".",
"b",
".",
"y",
"=",
"b",
".",
"z",
"*",
"g",
".",
"x",
"-",
"b",
".",
"x",
"*",
"g",
".",
"z",
"temp_matrix",
".",
"b",
".",
"z",
"=",
"b",
".",
"x",
"*",
"g",
".",
"y",
"-",
"b",
".",
"y",
"*",
"g",
".",
"x",
"temp_matrix",
".",
"c",
".",
"x",
"=",
"c",
".",
"y",
"*",
"g",
".",
"z",
"-",
"c",
".",
"z",
"*",
"g",
".",
"y",
"temp_matrix",
".",
"c",
".",
"y",
"=",
"c",
".",
"z",
"*",
"g",
".",
"x",
"-",
"c",
".",
"x",
"*",
"g",
".",
"z",
"temp_matrix",
".",
"c",
".",
"z",
"=",
"c",
".",
"x",
"*",
"g",
".",
"y",
"-",
"c",
".",
"y",
"*",
"g",
".",
"x",
"self",
".",
"a",
"+=",
"temp_matrix",
".",
"a",
"self",
".",
"b",
"+=",
"temp_matrix",
".",
"b",
"self",
".",
"c",
"+=",
"temp_matrix",
".",
"c"
] |
rotate the matrix by a given amount on 3 axes
|
[
"rotate",
"the",
"matrix",
"by",
"a",
"given",
"amount",
"on",
"3",
"axes"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L262-L279
|
235,127
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.normalize
|
def normalize(self):
'''re-normalise a rotation matrix'''
error = self.a * self.b
t0 = self.a - (self.b * (0.5 * error))
t1 = self.b - (self.a * (0.5 * error))
t2 = t0 % t1
self.a = t0 * (1.0 / t0.length())
self.b = t1 * (1.0 / t1.length())
self.c = t2 * (1.0 / t2.length())
|
python
|
def normalize(self):
'''re-normalise a rotation matrix'''
error = self.a * self.b
t0 = self.a - (self.b * (0.5 * error))
t1 = self.b - (self.a * (0.5 * error))
t2 = t0 % t1
self.a = t0 * (1.0 / t0.length())
self.b = t1 * (1.0 / t1.length())
self.c = t2 * (1.0 / t2.length())
|
[
"def",
"normalize",
"(",
"self",
")",
":",
"error",
"=",
"self",
".",
"a",
"*",
"self",
".",
"b",
"t0",
"=",
"self",
".",
"a",
"-",
"(",
"self",
".",
"b",
"*",
"(",
"0.5",
"*",
"error",
")",
")",
"t1",
"=",
"self",
".",
"b",
"-",
"(",
"self",
".",
"a",
"*",
"(",
"0.5",
"*",
"error",
")",
")",
"t2",
"=",
"t0",
"%",
"t1",
"self",
".",
"a",
"=",
"t0",
"*",
"(",
"1.0",
"/",
"t0",
".",
"length",
"(",
")",
")",
"self",
".",
"b",
"=",
"t1",
"*",
"(",
"1.0",
"/",
"t1",
".",
"length",
"(",
")",
")",
"self",
".",
"c",
"=",
"t2",
"*",
"(",
"1.0",
"/",
"t2",
".",
"length",
"(",
")",
")"
] |
re-normalise a rotation matrix
|
[
"re",
"-",
"normalise",
"a",
"rotation",
"matrix"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L281-L289
|
235,128
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.trace
|
def trace(self):
'''the trace of the matrix'''
return self.a.x + self.b.y + self.c.z
|
python
|
def trace(self):
'''the trace of the matrix'''
return self.a.x + self.b.y + self.c.z
|
[
"def",
"trace",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"x",
"+",
"self",
".",
"b",
".",
"y",
"+",
"self",
".",
"c",
".",
"z"
] |
the trace of the matrix
|
[
"the",
"trace",
"of",
"the",
"matrix"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L291-L293
|
235,129
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.from_axis_angle
|
def from_axis_angle(self, axis, angle):
'''create a rotation matrix from axis and angle'''
ux = axis.x
uy = axis.y
uz = axis.z
ct = cos(angle)
st = sin(angle)
self.a.x = ct + (1-ct) * ux**2
self.a.y = ux*uy*(1-ct) - uz*st
self.a.z = ux*uz*(1-ct) + uy*st
self.b.x = uy*ux*(1-ct) + uz*st
self.b.y = ct + (1-ct) * uy**2
self.b.z = uy*uz*(1-ct) - ux*st
self.c.x = uz*ux*(1-ct) - uy*st
self.c.y = uz*uy*(1-ct) + ux*st
self.c.z = ct + (1-ct) * uz**2
|
python
|
def from_axis_angle(self, axis, angle):
'''create a rotation matrix from axis and angle'''
ux = axis.x
uy = axis.y
uz = axis.z
ct = cos(angle)
st = sin(angle)
self.a.x = ct + (1-ct) * ux**2
self.a.y = ux*uy*(1-ct) - uz*st
self.a.z = ux*uz*(1-ct) + uy*st
self.b.x = uy*ux*(1-ct) + uz*st
self.b.y = ct + (1-ct) * uy**2
self.b.z = uy*uz*(1-ct) - ux*st
self.c.x = uz*ux*(1-ct) - uy*st
self.c.y = uz*uy*(1-ct) + ux*st
self.c.z = ct + (1-ct) * uz**2
|
[
"def",
"from_axis_angle",
"(",
"self",
",",
"axis",
",",
"angle",
")",
":",
"ux",
"=",
"axis",
".",
"x",
"uy",
"=",
"axis",
".",
"y",
"uz",
"=",
"axis",
".",
"z",
"ct",
"=",
"cos",
"(",
"angle",
")",
"st",
"=",
"sin",
"(",
"angle",
")",
"self",
".",
"a",
".",
"x",
"=",
"ct",
"+",
"(",
"1",
"-",
"ct",
")",
"*",
"ux",
"**",
"2",
"self",
".",
"a",
".",
"y",
"=",
"ux",
"*",
"uy",
"*",
"(",
"1",
"-",
"ct",
")",
"-",
"uz",
"*",
"st",
"self",
".",
"a",
".",
"z",
"=",
"ux",
"*",
"uz",
"*",
"(",
"1",
"-",
"ct",
")",
"+",
"uy",
"*",
"st",
"self",
".",
"b",
".",
"x",
"=",
"uy",
"*",
"ux",
"*",
"(",
"1",
"-",
"ct",
")",
"+",
"uz",
"*",
"st",
"self",
".",
"b",
".",
"y",
"=",
"ct",
"+",
"(",
"1",
"-",
"ct",
")",
"*",
"uy",
"**",
"2",
"self",
".",
"b",
".",
"z",
"=",
"uy",
"*",
"uz",
"*",
"(",
"1",
"-",
"ct",
")",
"-",
"ux",
"*",
"st",
"self",
".",
"c",
".",
"x",
"=",
"uz",
"*",
"ux",
"*",
"(",
"1",
"-",
"ct",
")",
"-",
"uy",
"*",
"st",
"self",
".",
"c",
".",
"y",
"=",
"uz",
"*",
"uy",
"*",
"(",
"1",
"-",
"ct",
")",
"+",
"ux",
"*",
"st",
"self",
".",
"c",
".",
"z",
"=",
"ct",
"+",
"(",
"1",
"-",
"ct",
")",
"*",
"uz",
"**",
"2"
] |
create a rotation matrix from axis and angle
|
[
"create",
"a",
"rotation",
"matrix",
"from",
"axis",
"and",
"angle"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L295-L310
|
235,130
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Matrix3.from_two_vectors
|
def from_two_vectors(self, vec1, vec2):
'''get a rotation matrix from two vectors.
This returns a rotation matrix which when applied to vec1
will produce a vector pointing in the same direction as vec2'''
angle = vec1.angle(vec2)
cross = vec1 % vec2
if cross.length() == 0:
# the two vectors are colinear
return self.from_euler(0,0,angle)
cross.normalize()
return self.from_axis_angle(cross, angle)
|
python
|
def from_two_vectors(self, vec1, vec2):
'''get a rotation matrix from two vectors.
This returns a rotation matrix which when applied to vec1
will produce a vector pointing in the same direction as vec2'''
angle = vec1.angle(vec2)
cross = vec1 % vec2
if cross.length() == 0:
# the two vectors are colinear
return self.from_euler(0,0,angle)
cross.normalize()
return self.from_axis_angle(cross, angle)
|
[
"def",
"from_two_vectors",
"(",
"self",
",",
"vec1",
",",
"vec2",
")",
":",
"angle",
"=",
"vec1",
".",
"angle",
"(",
"vec2",
")",
"cross",
"=",
"vec1",
"%",
"vec2",
"if",
"cross",
".",
"length",
"(",
")",
"==",
"0",
":",
"# the two vectors are colinear",
"return",
"self",
".",
"from_euler",
"(",
"0",
",",
"0",
",",
"angle",
")",
"cross",
".",
"normalize",
"(",
")",
"return",
"self",
".",
"from_axis_angle",
"(",
"cross",
",",
"angle",
")"
] |
get a rotation matrix from two vectors.
This returns a rotation matrix which when applied to vec1
will produce a vector pointing in the same direction as vec2
|
[
"get",
"a",
"rotation",
"matrix",
"from",
"two",
"vectors",
".",
"This",
"returns",
"a",
"rotation",
"matrix",
"which",
"when",
"applied",
"to",
"vec1",
"will",
"produce",
"a",
"vector",
"pointing",
"in",
"the",
"same",
"direction",
"as",
"vec2"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L313-L323
|
235,131
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py
|
Line.plane_intersection
|
def plane_intersection(self, plane, forward_only=False):
'''return point where line intersects with a plane'''
l_dot_n = self.vector * plane.normal
if l_dot_n == 0.0:
# line is parallel to the plane
return None
d = ((plane.point - self.point) * plane.normal) / l_dot_n
if forward_only and d < 0:
return None
return (self.vector * d) + self.point
|
python
|
def plane_intersection(self, plane, forward_only=False):
'''return point where line intersects with a plane'''
l_dot_n = self.vector * plane.normal
if l_dot_n == 0.0:
# line is parallel to the plane
return None
d = ((plane.point - self.point) * plane.normal) / l_dot_n
if forward_only and d < 0:
return None
return (self.vector * d) + self.point
|
[
"def",
"plane_intersection",
"(",
"self",
",",
"plane",
",",
"forward_only",
"=",
"False",
")",
":",
"l_dot_n",
"=",
"self",
".",
"vector",
"*",
"plane",
".",
"normal",
"if",
"l_dot_n",
"==",
"0.0",
":",
"# line is parallel to the plane",
"return",
"None",
"d",
"=",
"(",
"(",
"plane",
".",
"point",
"-",
"self",
".",
"point",
")",
"*",
"plane",
".",
"normal",
")",
"/",
"l_dot_n",
"if",
"forward_only",
"and",
"d",
"<",
"0",
":",
"return",
"None",
"return",
"(",
"self",
".",
"vector",
"*",
"d",
")",
"+",
"self",
".",
"point"
] |
return point where line intersects with a plane
|
[
"return",
"point",
"where",
"line",
"intersects",
"with",
"a",
"plane"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L348-L357
|
235,132
|
JdeRobot/base
|
src/libs/comm_py/comm/ice/rgbdIceClient.py
|
RgbdCamera.getRgbd
|
def getRgbd(self):
'''
Returns last Rgbd.
@return last JdeRobotTypes Rgbd saved
'''
img = Rgb()
if self.hasproxy():
self.lock.acquire()
img = self.image
self.lock.release()
return img
|
python
|
def getRgbd(self):
'''
Returns last Rgbd.
@return last JdeRobotTypes Rgbd saved
'''
img = Rgb()
if self.hasproxy():
self.lock.acquire()
img = self.image
self.lock.release()
return img
|
[
"def",
"getRgbd",
"(",
"self",
")",
":",
"img",
"=",
"Rgb",
"(",
")",
"if",
"self",
".",
"hasproxy",
"(",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"img",
"=",
"self",
".",
"image",
"self",
".",
"lock",
".",
"release",
"(",
")",
"return",
"img"
] |
Returns last Rgbd.
@return last JdeRobotTypes Rgbd saved
|
[
"Returns",
"last",
"Rgbd",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/rgbdIceClient.py#L97-L109
|
235,133
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py
|
Graph.add_mavlink_packet
|
def add_mavlink_packet(self, msg):
'''add data to the graph'''
mtype = msg.get_type()
if mtype not in self.msg_types:
return
for i in range(len(self.fields)):
if mtype not in self.field_types[i]:
continue
f = self.fields[i]
self.values[i] = mavutil.evaluate_expression(f, self.state.master.messages)
if self.livegraph is not None:
self.livegraph.add_values(self.values)
|
python
|
def add_mavlink_packet(self, msg):
'''add data to the graph'''
mtype = msg.get_type()
if mtype not in self.msg_types:
return
for i in range(len(self.fields)):
if mtype not in self.field_types[i]:
continue
f = self.fields[i]
self.values[i] = mavutil.evaluate_expression(f, self.state.master.messages)
if self.livegraph is not None:
self.livegraph.add_values(self.values)
|
[
"def",
"add_mavlink_packet",
"(",
"self",
",",
"msg",
")",
":",
"mtype",
"=",
"msg",
".",
"get_type",
"(",
")",
"if",
"mtype",
"not",
"in",
"self",
".",
"msg_types",
":",
"return",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"fields",
")",
")",
":",
"if",
"mtype",
"not",
"in",
"self",
".",
"field_types",
"[",
"i",
"]",
":",
"continue",
"f",
"=",
"self",
".",
"fields",
"[",
"i",
"]",
"self",
".",
"values",
"[",
"i",
"]",
"=",
"mavutil",
".",
"evaluate_expression",
"(",
"f",
",",
"self",
".",
"state",
".",
"master",
".",
"messages",
")",
"if",
"self",
".",
"livegraph",
"is",
"not",
"None",
":",
"self",
".",
"livegraph",
".",
"add_values",
"(",
"self",
".",
"values",
")"
] |
add data to the graph
|
[
"add",
"data",
"to",
"the",
"graph"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py#L104-L115
|
235,134
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_javascript.py
|
generate
|
def generate(basename, xml):
'''generate complete javascript implementation'''
if basename.endswith('.js'):
filename = basename
else:
filename = basename + '.js'
msgs = []
enums = []
filelist = []
for x in xml:
msgs.extend(x.message)
enums.extend(x.enum)
filelist.append(os.path.basename(x.filename))
for m in msgs:
if xml[0].little_endian:
m.fmtstr = '<'
else:
m.fmtstr = '>'
for f in m.ordered_fields:
m.fmtstr += mavfmt(f)
m.order_map = [ 0 ] * len(m.fieldnames)
for i in range(0, len(m.fieldnames)):
m.order_map[i] = m.ordered_fieldnames.index(m.fieldnames[i])
print("Generating %s" % filename)
outf = open(filename, "w")
generate_preamble(outf, msgs, filelist, xml[0])
generate_enums(outf, enums)
generate_message_ids(outf, msgs)
generate_classes(outf, msgs)
generate_mavlink_class(outf, msgs, xml[0])
generate_footer(outf)
outf.close()
print("Generated %s OK" % filename)
|
python
|
def generate(basename, xml):
'''generate complete javascript implementation'''
if basename.endswith('.js'):
filename = basename
else:
filename = basename + '.js'
msgs = []
enums = []
filelist = []
for x in xml:
msgs.extend(x.message)
enums.extend(x.enum)
filelist.append(os.path.basename(x.filename))
for m in msgs:
if xml[0].little_endian:
m.fmtstr = '<'
else:
m.fmtstr = '>'
for f in m.ordered_fields:
m.fmtstr += mavfmt(f)
m.order_map = [ 0 ] * len(m.fieldnames)
for i in range(0, len(m.fieldnames)):
m.order_map[i] = m.ordered_fieldnames.index(m.fieldnames[i])
print("Generating %s" % filename)
outf = open(filename, "w")
generate_preamble(outf, msgs, filelist, xml[0])
generate_enums(outf, enums)
generate_message_ids(outf, msgs)
generate_classes(outf, msgs)
generate_mavlink_class(outf, msgs, xml[0])
generate_footer(outf)
outf.close()
print("Generated %s OK" % filename)
|
[
"def",
"generate",
"(",
"basename",
",",
"xml",
")",
":",
"if",
"basename",
".",
"endswith",
"(",
"'.js'",
")",
":",
"filename",
"=",
"basename",
"else",
":",
"filename",
"=",
"basename",
"+",
"'.js'",
"msgs",
"=",
"[",
"]",
"enums",
"=",
"[",
"]",
"filelist",
"=",
"[",
"]",
"for",
"x",
"in",
"xml",
":",
"msgs",
".",
"extend",
"(",
"x",
".",
"message",
")",
"enums",
".",
"extend",
"(",
"x",
".",
"enum",
")",
"filelist",
".",
"append",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"x",
".",
"filename",
")",
")",
"for",
"m",
"in",
"msgs",
":",
"if",
"xml",
"[",
"0",
"]",
".",
"little_endian",
":",
"m",
".",
"fmtstr",
"=",
"'<'",
"else",
":",
"m",
".",
"fmtstr",
"=",
"'>'",
"for",
"f",
"in",
"m",
".",
"ordered_fields",
":",
"m",
".",
"fmtstr",
"+=",
"mavfmt",
"(",
"f",
")",
"m",
".",
"order_map",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"m",
".",
"fieldnames",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"m",
".",
"fieldnames",
")",
")",
":",
"m",
".",
"order_map",
"[",
"i",
"]",
"=",
"m",
".",
"ordered_fieldnames",
".",
"index",
"(",
"m",
".",
"fieldnames",
"[",
"i",
"]",
")",
"print",
"(",
"\"Generating %s\"",
"%",
"filename",
")",
"outf",
"=",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"generate_preamble",
"(",
"outf",
",",
"msgs",
",",
"filelist",
",",
"xml",
"[",
"0",
"]",
")",
"generate_enums",
"(",
"outf",
",",
"enums",
")",
"generate_message_ids",
"(",
"outf",
",",
"msgs",
")",
"generate_classes",
"(",
"outf",
",",
"msgs",
")",
"generate_mavlink_class",
"(",
"outf",
",",
"msgs",
",",
"xml",
"[",
"0",
"]",
")",
"generate_footer",
"(",
"outf",
")",
"outf",
".",
"close",
"(",
")",
"print",
"(",
"\"Generated %s OK\"",
"%",
"filename",
")"
] |
generate complete javascript implementation
|
[
"generate",
"complete",
"javascript",
"implementation"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_javascript.py#L538-L574
|
235,135
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavflightmodes.py
|
flight_modes
|
def flight_modes(logfile):
'''show flight modes for a log file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
mode = ""
previous_mode = ""
mode_start_timestamp = -1
time_in_mode = {}
previous_percent = -1
seconds_per_percent = -1
filesize = os.path.getsize(filename)
while True:
m = mlog.recv_match(type=['SYS_STATUS','HEARTBEAT','MODE'],
condition='MAV.flightmode!="%s"' % mlog.flightmode)
if m is None:
break
print('%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % (
time.asctime(time.localtime(m._timestamp)),
mlog.flightmode,
m._timestamp, mlog.percent))
mode = mlog.flightmode
if (mode not in time_in_mode):
time_in_mode[mode] = 0
if (mode_start_timestamp == -1):
mode_start_timestamp = m._timestamp
elif (previous_mode != "" and previous_mode != mode):
time_in_mode[previous_mode] = time_in_mode[previous_mode] + (m._timestamp - mode_start_timestamp)
#figure out how many seconds per percentage point so I can
#caculate how many seconds for the final mode
if (seconds_per_percent == -1 and previous_percent != -1
and previous_percent != mlog.percent):
seconds_per_percent = (m._timestamp - mode_start_timestamp) / (mlog.percent - previous_percent)
mode_start_timestamp = m._timestamp
previous_mode = mode
previous_percent = mlog.percent
#put a whitespace line before the per-mode report
print()
print("Time per mode:")
#need to get the time in the final mode
if (seconds_per_percent != -1):
seconds_remaining = (100.0 - previous_percent) * seconds_per_percent
time_in_mode[previous_mode] = time_in_mode[previous_mode] + seconds_remaining
total_flight_time = 0
for key, value in time_in_mode.iteritems():
total_flight_time = total_flight_time + value
for key, value in time_in_mode.iteritems():
print('%-12s %s %.2f%%' % (key, str(datetime.timedelta(seconds=int(value))), (value / total_flight_time) * 100.0))
else:
#can't print time in mode if only one mode during flight
print(previous_mode, " 100% of flight time")
|
python
|
def flight_modes(logfile):
'''show flight modes for a log file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
mode = ""
previous_mode = ""
mode_start_timestamp = -1
time_in_mode = {}
previous_percent = -1
seconds_per_percent = -1
filesize = os.path.getsize(filename)
while True:
m = mlog.recv_match(type=['SYS_STATUS','HEARTBEAT','MODE'],
condition='MAV.flightmode!="%s"' % mlog.flightmode)
if m is None:
break
print('%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % (
time.asctime(time.localtime(m._timestamp)),
mlog.flightmode,
m._timestamp, mlog.percent))
mode = mlog.flightmode
if (mode not in time_in_mode):
time_in_mode[mode] = 0
if (mode_start_timestamp == -1):
mode_start_timestamp = m._timestamp
elif (previous_mode != "" and previous_mode != mode):
time_in_mode[previous_mode] = time_in_mode[previous_mode] + (m._timestamp - mode_start_timestamp)
#figure out how many seconds per percentage point so I can
#caculate how many seconds for the final mode
if (seconds_per_percent == -1 and previous_percent != -1
and previous_percent != mlog.percent):
seconds_per_percent = (m._timestamp - mode_start_timestamp) / (mlog.percent - previous_percent)
mode_start_timestamp = m._timestamp
previous_mode = mode
previous_percent = mlog.percent
#put a whitespace line before the per-mode report
print()
print("Time per mode:")
#need to get the time in the final mode
if (seconds_per_percent != -1):
seconds_remaining = (100.0 - previous_percent) * seconds_per_percent
time_in_mode[previous_mode] = time_in_mode[previous_mode] + seconds_remaining
total_flight_time = 0
for key, value in time_in_mode.iteritems():
total_flight_time = total_flight_time + value
for key, value in time_in_mode.iteritems():
print('%-12s %s %.2f%%' % (key, str(datetime.timedelta(seconds=int(value))), (value / total_flight_time) * 100.0))
else:
#can't print time in mode if only one mode during flight
print(previous_mode, " 100% of flight time")
|
[
"def",
"flight_modes",
"(",
"logfile",
")",
":",
"print",
"(",
"\"Processing log %s\"",
"%",
"filename",
")",
"mlog",
"=",
"mavutil",
".",
"mavlink_connection",
"(",
"filename",
")",
"mode",
"=",
"\"\"",
"previous_mode",
"=",
"\"\"",
"mode_start_timestamp",
"=",
"-",
"1",
"time_in_mode",
"=",
"{",
"}",
"previous_percent",
"=",
"-",
"1",
"seconds_per_percent",
"=",
"-",
"1",
"filesize",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"filename",
")",
"while",
"True",
":",
"m",
"=",
"mlog",
".",
"recv_match",
"(",
"type",
"=",
"[",
"'SYS_STATUS'",
",",
"'HEARTBEAT'",
",",
"'MODE'",
"]",
",",
"condition",
"=",
"'MAV.flightmode!=\"%s\"'",
"%",
"mlog",
".",
"flightmode",
")",
"if",
"m",
"is",
"None",
":",
"break",
"print",
"(",
"'%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)'",
"%",
"(",
"time",
".",
"asctime",
"(",
"time",
".",
"localtime",
"(",
"m",
".",
"_timestamp",
")",
")",
",",
"mlog",
".",
"flightmode",
",",
"m",
".",
"_timestamp",
",",
"mlog",
".",
"percent",
")",
")",
"mode",
"=",
"mlog",
".",
"flightmode",
"if",
"(",
"mode",
"not",
"in",
"time_in_mode",
")",
":",
"time_in_mode",
"[",
"mode",
"]",
"=",
"0",
"if",
"(",
"mode_start_timestamp",
"==",
"-",
"1",
")",
":",
"mode_start_timestamp",
"=",
"m",
".",
"_timestamp",
"elif",
"(",
"previous_mode",
"!=",
"\"\"",
"and",
"previous_mode",
"!=",
"mode",
")",
":",
"time_in_mode",
"[",
"previous_mode",
"]",
"=",
"time_in_mode",
"[",
"previous_mode",
"]",
"+",
"(",
"m",
".",
"_timestamp",
"-",
"mode_start_timestamp",
")",
"#figure out how many seconds per percentage point so I can",
"#caculate how many seconds for the final mode",
"if",
"(",
"seconds_per_percent",
"==",
"-",
"1",
"and",
"previous_percent",
"!=",
"-",
"1",
"and",
"previous_percent",
"!=",
"mlog",
".",
"percent",
")",
":",
"seconds_per_percent",
"=",
"(",
"m",
".",
"_timestamp",
"-",
"mode_start_timestamp",
")",
"/",
"(",
"mlog",
".",
"percent",
"-",
"previous_percent",
")",
"mode_start_timestamp",
"=",
"m",
".",
"_timestamp",
"previous_mode",
"=",
"mode",
"previous_percent",
"=",
"mlog",
".",
"percent",
"#put a whitespace line before the per-mode report",
"print",
"(",
")",
"print",
"(",
"\"Time per mode:\"",
")",
"#need to get the time in the final mode",
"if",
"(",
"seconds_per_percent",
"!=",
"-",
"1",
")",
":",
"seconds_remaining",
"=",
"(",
"100.0",
"-",
"previous_percent",
")",
"*",
"seconds_per_percent",
"time_in_mode",
"[",
"previous_mode",
"]",
"=",
"time_in_mode",
"[",
"previous_mode",
"]",
"+",
"seconds_remaining",
"total_flight_time",
"=",
"0",
"for",
"key",
",",
"value",
"in",
"time_in_mode",
".",
"iteritems",
"(",
")",
":",
"total_flight_time",
"=",
"total_flight_time",
"+",
"value",
"for",
"key",
",",
"value",
"in",
"time_in_mode",
".",
"iteritems",
"(",
")",
":",
"print",
"(",
"'%-12s %s %.2f%%'",
"%",
"(",
"key",
",",
"str",
"(",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"int",
"(",
"value",
")",
")",
")",
",",
"(",
"value",
"/",
"total_flight_time",
")",
"*",
"100.0",
")",
")",
"else",
":",
"#can't print time in mode if only one mode during flight",
"print",
"(",
"previous_mode",
",",
"\" 100% of flight time\"",
")"
] |
show flight modes for a log file
|
[
"show",
"flight",
"modes",
"for",
"a",
"log",
"file"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavflightmodes.py#L18-L80
|
235,136
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
|
have_graph
|
def have_graph(name):
'''return true if we have a graph of the given name'''
for g in mestate.graphs:
if g.name == name:
return True
return False
|
python
|
def have_graph(name):
'''return true if we have a graph of the given name'''
for g in mestate.graphs:
if g.name == name:
return True
return False
|
[
"def",
"have_graph",
"(",
"name",
")",
":",
"for",
"g",
"in",
"mestate",
".",
"graphs",
":",
"if",
"g",
".",
"name",
"==",
"name",
":",
"return",
"True",
"return",
"False"
] |
return true if we have a graph of the given name
|
[
"return",
"true",
"if",
"we",
"have",
"a",
"graph",
"of",
"the",
"given",
"name"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L67-L72
|
235,137
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
|
expression_ok
|
def expression_ok(expression):
'''return True if an expression is OK with current messages'''
expression_ok = True
fields = expression.split()
for f in fields:
try:
if f.endswith(':2'):
f = f[:-2]
if mavutil.evaluate_expression(f, mestate.status.msgs) is None:
expression_ok = False
except Exception:
expression_ok = False
break
return expression_ok
|
python
|
def expression_ok(expression):
'''return True if an expression is OK with current messages'''
expression_ok = True
fields = expression.split()
for f in fields:
try:
if f.endswith(':2'):
f = f[:-2]
if mavutil.evaluate_expression(f, mestate.status.msgs) is None:
expression_ok = False
except Exception:
expression_ok = False
break
return expression_ok
|
[
"def",
"expression_ok",
"(",
"expression",
")",
":",
"expression_ok",
"=",
"True",
"fields",
"=",
"expression",
".",
"split",
"(",
")",
"for",
"f",
"in",
"fields",
":",
"try",
":",
"if",
"f",
".",
"endswith",
"(",
"':2'",
")",
":",
"f",
"=",
"f",
"[",
":",
"-",
"2",
"]",
"if",
"mavutil",
".",
"evaluate_expression",
"(",
"f",
",",
"mestate",
".",
"status",
".",
"msgs",
")",
"is",
"None",
":",
"expression_ok",
"=",
"False",
"except",
"Exception",
":",
"expression_ok",
"=",
"False",
"break",
"return",
"expression_ok"
] |
return True if an expression is OK with current messages
|
[
"return",
"True",
"if",
"an",
"expression",
"is",
"OK",
"with",
"current",
"messages"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L129-L142
|
235,138
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
|
load_graph_xml
|
def load_graph_xml(xml, filename, load_all=False):
'''load a graph from one xml string'''
ret = []
try:
root = objectify.fromstring(xml)
except Exception:
return []
if root.tag != 'graphs':
return []
if not hasattr(root, 'graph'):
return []
for g in root.graph:
name = g.attrib['name']
expressions = [e.text for e in g.expression]
if load_all:
ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
continue
if have_graph(name):
continue
for e in expressions:
if expression_ok(e):
ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
break
return ret
|
python
|
def load_graph_xml(xml, filename, load_all=False):
'''load a graph from one xml string'''
ret = []
try:
root = objectify.fromstring(xml)
except Exception:
return []
if root.tag != 'graphs':
return []
if not hasattr(root, 'graph'):
return []
for g in root.graph:
name = g.attrib['name']
expressions = [e.text for e in g.expression]
if load_all:
ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
continue
if have_graph(name):
continue
for e in expressions:
if expression_ok(e):
ret.append(GraphDefinition(name, e, g.description.text, expressions, filename))
break
return ret
|
[
"def",
"load_graph_xml",
"(",
"xml",
",",
"filename",
",",
"load_all",
"=",
"False",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"root",
"=",
"objectify",
".",
"fromstring",
"(",
"xml",
")",
"except",
"Exception",
":",
"return",
"[",
"]",
"if",
"root",
".",
"tag",
"!=",
"'graphs'",
":",
"return",
"[",
"]",
"if",
"not",
"hasattr",
"(",
"root",
",",
"'graph'",
")",
":",
"return",
"[",
"]",
"for",
"g",
"in",
"root",
".",
"graph",
":",
"name",
"=",
"g",
".",
"attrib",
"[",
"'name'",
"]",
"expressions",
"=",
"[",
"e",
".",
"text",
"for",
"e",
"in",
"g",
".",
"expression",
"]",
"if",
"load_all",
":",
"ret",
".",
"append",
"(",
"GraphDefinition",
"(",
"name",
",",
"e",
",",
"g",
".",
"description",
".",
"text",
",",
"expressions",
",",
"filename",
")",
")",
"continue",
"if",
"have_graph",
"(",
"name",
")",
":",
"continue",
"for",
"e",
"in",
"expressions",
":",
"if",
"expression_ok",
"(",
"e",
")",
":",
"ret",
".",
"append",
"(",
"GraphDefinition",
"(",
"name",
",",
"e",
",",
"g",
".",
"description",
".",
"text",
",",
"expressions",
",",
"filename",
")",
")",
"break",
"return",
"ret"
] |
load a graph from one xml string
|
[
"load",
"a",
"graph",
"from",
"one",
"xml",
"string"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L144-L167
|
235,139
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
|
cmd_condition
|
def cmd_condition(args):
'''control MAVExporer conditions'''
if len(args) == 0:
print("condition is: %s" % mestate.settings.condition)
return
mestate.settings.condition = ' '.join(args)
if len(mestate.settings.condition) == 0 or mestate.settings.condition == 'clear':
mestate.settings.condition = None
|
python
|
def cmd_condition(args):
'''control MAVExporer conditions'''
if len(args) == 0:
print("condition is: %s" % mestate.settings.condition)
return
mestate.settings.condition = ' '.join(args)
if len(mestate.settings.condition) == 0 or mestate.settings.condition == 'clear':
mestate.settings.condition = None
|
[
"def",
"cmd_condition",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"print",
"(",
"\"condition is: %s\"",
"%",
"mestate",
".",
"settings",
".",
"condition",
")",
"return",
"mestate",
".",
"settings",
".",
"condition",
"=",
"' '",
".",
"join",
"(",
"args",
")",
"if",
"len",
"(",
"mestate",
".",
"settings",
".",
"condition",
")",
"==",
"0",
"or",
"mestate",
".",
"settings",
".",
"condition",
"==",
"'clear'",
":",
"mestate",
".",
"settings",
".",
"condition",
"=",
"None"
] |
control MAVExporer conditions
|
[
"control",
"MAVExporer",
"conditions"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L260-L267
|
235,140
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py
|
MAVLink.ualberta_sys_status_send
|
def ualberta_sys_status_send(self, mode, nav_mode, pilot, force_mavlink1=False):
'''
System status specific to ualberta uav
mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t)
nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t)
pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t)
'''
return self.send(self.ualberta_sys_status_encode(mode, nav_mode, pilot), force_mavlink1=force_mavlink1)
|
python
|
def ualberta_sys_status_send(self, mode, nav_mode, pilot, force_mavlink1=False):
'''
System status specific to ualberta uav
mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t)
nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t)
pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t)
'''
return self.send(self.ualberta_sys_status_encode(mode, nav_mode, pilot), force_mavlink1=force_mavlink1)
|
[
"def",
"ualberta_sys_status_send",
"(",
"self",
",",
"mode",
",",
"nav_mode",
",",
"pilot",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"ualberta_sys_status_encode",
"(",
"mode",
",",
"nav_mode",
",",
"pilot",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
System status specific to ualberta uav
mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t)
nav_mode : Navigation mode, see UALBERTA_NAV_MODE ENUM (uint8_t)
pilot : Pilot mode, see UALBERTA_PILOT_MODE (uint8_t)
|
[
"System",
"status",
"specific",
"to",
"ualberta",
"uav"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py#L7434-L7443
|
235,141
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py
|
MAVLink.button_change_send
|
def button_change_send(self, time_boot_ms, last_change_ms, state, force_mavlink1=False):
'''
Report button state change
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
last_change_ms : Time of last change of button state (uint32_t)
state : Bitmap state of buttons (uint8_t)
'''
return self.send(self.button_change_encode(time_boot_ms, last_change_ms, state), force_mavlink1=force_mavlink1)
|
python
|
def button_change_send(self, time_boot_ms, last_change_ms, state, force_mavlink1=False):
'''
Report button state change
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
last_change_ms : Time of last change of button state (uint32_t)
state : Bitmap state of buttons (uint8_t)
'''
return self.send(self.button_change_encode(time_boot_ms, last_change_ms, state), force_mavlink1=force_mavlink1)
|
[
"def",
"button_change_send",
"(",
"self",
",",
"time_boot_ms",
",",
"last_change_ms",
",",
"state",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"button_change_encode",
"(",
"time_boot_ms",
",",
"last_change_ms",
",",
"state",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
Report button state change
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
last_change_ms : Time of last change of button state (uint32_t)
state : Bitmap state of buttons (uint8_t)
|
[
"Report",
"button",
"state",
"change"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ualberta.py#L12186-L12195
|
235,142
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/lib/ANUGA/redfearn.py
|
convert_from_latlon_to_utm
|
def convert_from_latlon_to_utm(points=None,
latitudes=None,
longitudes=None,
false_easting=None,
false_northing=None):
"""Convert latitude and longitude data to UTM as a list of coordinates.
Input
points: list of points given in decimal degrees (latitude, longitude) or
latitudes: list of latitudes and
longitudes: list of longitudes
false_easting (optional)
false_northing (optional)
Output
points: List of converted points
zone: Common UTM zone for converted points
Notes
Assume the false_easting and false_northing are the same for each list.
If points end up in different UTM zones, an ANUGAerror is thrown.
"""
old_geo = Geo_reference()
utm_points = []
if points == None:
assert len(latitudes) == len(longitudes)
points = map(None, latitudes, longitudes)
for point in points:
zone, easting, northing = redfearn(float(point[0]),
float(point[1]),
false_easting=false_easting,
false_northing=false_northing)
new_geo = Geo_reference(zone)
old_geo.reconcile_zones(new_geo)
utm_points.append([easting, northing])
return utm_points, old_geo.get_zone()
|
python
|
def convert_from_latlon_to_utm(points=None,
latitudes=None,
longitudes=None,
false_easting=None,
false_northing=None):
"""Convert latitude and longitude data to UTM as a list of coordinates.
Input
points: list of points given in decimal degrees (latitude, longitude) or
latitudes: list of latitudes and
longitudes: list of longitudes
false_easting (optional)
false_northing (optional)
Output
points: List of converted points
zone: Common UTM zone for converted points
Notes
Assume the false_easting and false_northing are the same for each list.
If points end up in different UTM zones, an ANUGAerror is thrown.
"""
old_geo = Geo_reference()
utm_points = []
if points == None:
assert len(latitudes) == len(longitudes)
points = map(None, latitudes, longitudes)
for point in points:
zone, easting, northing = redfearn(float(point[0]),
float(point[1]),
false_easting=false_easting,
false_northing=false_northing)
new_geo = Geo_reference(zone)
old_geo.reconcile_zones(new_geo)
utm_points.append([easting, northing])
return utm_points, old_geo.get_zone()
|
[
"def",
"convert_from_latlon_to_utm",
"(",
"points",
"=",
"None",
",",
"latitudes",
"=",
"None",
",",
"longitudes",
"=",
"None",
",",
"false_easting",
"=",
"None",
",",
"false_northing",
"=",
"None",
")",
":",
"old_geo",
"=",
"Geo_reference",
"(",
")",
"utm_points",
"=",
"[",
"]",
"if",
"points",
"==",
"None",
":",
"assert",
"len",
"(",
"latitudes",
")",
"==",
"len",
"(",
"longitudes",
")",
"points",
"=",
"map",
"(",
"None",
",",
"latitudes",
",",
"longitudes",
")",
"for",
"point",
"in",
"points",
":",
"zone",
",",
"easting",
",",
"northing",
"=",
"redfearn",
"(",
"float",
"(",
"point",
"[",
"0",
"]",
")",
",",
"float",
"(",
"point",
"[",
"1",
"]",
")",
",",
"false_easting",
"=",
"false_easting",
",",
"false_northing",
"=",
"false_northing",
")",
"new_geo",
"=",
"Geo_reference",
"(",
"zone",
")",
"old_geo",
".",
"reconcile_zones",
"(",
"new_geo",
")",
"utm_points",
".",
"append",
"(",
"[",
"easting",
",",
"northing",
"]",
")",
"return",
"utm_points",
",",
"old_geo",
".",
"get_zone",
"(",
")"
] |
Convert latitude and longitude data to UTM as a list of coordinates.
Input
points: list of points given in decimal degrees (latitude, longitude) or
latitudes: list of latitudes and
longitudes: list of longitudes
false_easting (optional)
false_northing (optional)
Output
points: List of converted points
zone: Common UTM zone for converted points
Notes
Assume the false_easting and false_northing are the same for each list.
If points end up in different UTM zones, an ANUGAerror is thrown.
|
[
"Convert",
"latitude",
"and",
"longitude",
"data",
"to",
"UTM",
"as",
"a",
"list",
"of",
"coordinates",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/ANUGA/redfearn.py#L199-L243
|
235,143
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py
|
QuaternionBase.dcm
|
def dcm(self):
"""
Get the DCM
:returns: 3x3 array
"""
if self._dcm is None:
if self._q is not None:
# try to get dcm from q
self._dcm = self._q_to_dcm(self.q)
elif self._euler is not None:
# try to get get dcm from euler
self._dcm = self._euler_to_dcm(self._euler)
return self._dcm
|
python
|
def dcm(self):
"""
Get the DCM
:returns: 3x3 array
"""
if self._dcm is None:
if self._q is not None:
# try to get dcm from q
self._dcm = self._q_to_dcm(self.q)
elif self._euler is not None:
# try to get get dcm from euler
self._dcm = self._euler_to_dcm(self._euler)
return self._dcm
|
[
"def",
"dcm",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dcm",
"is",
"None",
":",
"if",
"self",
".",
"_q",
"is",
"not",
"None",
":",
"# try to get dcm from q",
"self",
".",
"_dcm",
"=",
"self",
".",
"_q_to_dcm",
"(",
"self",
".",
"q",
")",
"elif",
"self",
".",
"_euler",
"is",
"not",
"None",
":",
"# try to get get dcm from euler",
"self",
".",
"_dcm",
"=",
"self",
".",
"_euler_to_dcm",
"(",
"self",
".",
"_euler",
")",
"return",
"self",
".",
"_dcm"
] |
Get the DCM
:returns: 3x3 array
|
[
"Get",
"the",
"DCM"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L128-L141
|
235,144
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavgpslock.py
|
lock_time
|
def lock_time(logfile):
'''work out gps lock times for a log file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
locked = False
start_time = 0.0
total_time = 0.0
t = None
m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition)
if m is None:
return 0
unlock_time = time.mktime(time.localtime(m._timestamp))
while True:
m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition)
if m is None:
if locked:
total_time += time.mktime(t) - start_time
if total_time > 0:
print("Lock time : %u:%02u" % (int(total_time)/60, int(total_time)%60))
return total_time
t = time.localtime(m._timestamp)
if m.fix_type >= 2 and not locked:
print("Locked at %s after %u seconds" % (time.asctime(t),
time.mktime(t) - unlock_time))
locked = True
start_time = time.mktime(t)
elif m.fix_type == 1 and locked:
print("Lost GPS lock at %s" % time.asctime(t))
locked = False
total_time += time.mktime(t) - start_time
unlock_time = time.mktime(t)
elif m.fix_type == 0 and locked:
print("Lost protocol lock at %s" % time.asctime(t))
locked = False
total_time += time.mktime(t) - start_time
unlock_time = time.mktime(t)
return total_time
|
python
|
def lock_time(logfile):
'''work out gps lock times for a log file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
locked = False
start_time = 0.0
total_time = 0.0
t = None
m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition)
if m is None:
return 0
unlock_time = time.mktime(time.localtime(m._timestamp))
while True:
m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition)
if m is None:
if locked:
total_time += time.mktime(t) - start_time
if total_time > 0:
print("Lock time : %u:%02u" % (int(total_time)/60, int(total_time)%60))
return total_time
t = time.localtime(m._timestamp)
if m.fix_type >= 2 and not locked:
print("Locked at %s after %u seconds" % (time.asctime(t),
time.mktime(t) - unlock_time))
locked = True
start_time = time.mktime(t)
elif m.fix_type == 1 and locked:
print("Lost GPS lock at %s" % time.asctime(t))
locked = False
total_time += time.mktime(t) - start_time
unlock_time = time.mktime(t)
elif m.fix_type == 0 and locked:
print("Lost protocol lock at %s" % time.asctime(t))
locked = False
total_time += time.mktime(t) - start_time
unlock_time = time.mktime(t)
return total_time
|
[
"def",
"lock_time",
"(",
"logfile",
")",
":",
"print",
"(",
"\"Processing log %s\"",
"%",
"filename",
")",
"mlog",
"=",
"mavutil",
".",
"mavlink_connection",
"(",
"filename",
")",
"locked",
"=",
"False",
"start_time",
"=",
"0.0",
"total_time",
"=",
"0.0",
"t",
"=",
"None",
"m",
"=",
"mlog",
".",
"recv_match",
"(",
"type",
"=",
"[",
"'GPS_RAW_INT'",
",",
"'GPS_RAW'",
"]",
",",
"condition",
"=",
"args",
".",
"condition",
")",
"if",
"m",
"is",
"None",
":",
"return",
"0",
"unlock_time",
"=",
"time",
".",
"mktime",
"(",
"time",
".",
"localtime",
"(",
"m",
".",
"_timestamp",
")",
")",
"while",
"True",
":",
"m",
"=",
"mlog",
".",
"recv_match",
"(",
"type",
"=",
"[",
"'GPS_RAW_INT'",
",",
"'GPS_RAW'",
"]",
",",
"condition",
"=",
"args",
".",
"condition",
")",
"if",
"m",
"is",
"None",
":",
"if",
"locked",
":",
"total_time",
"+=",
"time",
".",
"mktime",
"(",
"t",
")",
"-",
"start_time",
"if",
"total_time",
">",
"0",
":",
"print",
"(",
"\"Lock time : %u:%02u\"",
"%",
"(",
"int",
"(",
"total_time",
")",
"/",
"60",
",",
"int",
"(",
"total_time",
")",
"%",
"60",
")",
")",
"return",
"total_time",
"t",
"=",
"time",
".",
"localtime",
"(",
"m",
".",
"_timestamp",
")",
"if",
"m",
".",
"fix_type",
">=",
"2",
"and",
"not",
"locked",
":",
"print",
"(",
"\"Locked at %s after %u seconds\"",
"%",
"(",
"time",
".",
"asctime",
"(",
"t",
")",
",",
"time",
".",
"mktime",
"(",
"t",
")",
"-",
"unlock_time",
")",
")",
"locked",
"=",
"True",
"start_time",
"=",
"time",
".",
"mktime",
"(",
"t",
")",
"elif",
"m",
".",
"fix_type",
"==",
"1",
"and",
"locked",
":",
"print",
"(",
"\"Lost GPS lock at %s\"",
"%",
"time",
".",
"asctime",
"(",
"t",
")",
")",
"locked",
"=",
"False",
"total_time",
"+=",
"time",
".",
"mktime",
"(",
"t",
")",
"-",
"start_time",
"unlock_time",
"=",
"time",
".",
"mktime",
"(",
"t",
")",
"elif",
"m",
".",
"fix_type",
"==",
"0",
"and",
"locked",
":",
"print",
"(",
"\"Lost protocol lock at %s\"",
"%",
"time",
".",
"asctime",
"(",
"t",
")",
")",
"locked",
"=",
"False",
"total_time",
"+=",
"time",
".",
"mktime",
"(",
"t",
")",
"-",
"start_time",
"unlock_time",
"=",
"time",
".",
"mktime",
"(",
"t",
")",
"return",
"total_time"
] |
work out gps lock times for a log file
|
[
"work",
"out",
"gps",
"lock",
"times",
"for",
"a",
"log",
"file"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavgpslock.py#L19-L58
|
235,145
|
JdeRobot/base
|
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
|
MPSlipMapFrame.on_menu
|
def on_menu(self, event):
'''handle menu selection'''
state = self.state
# see if it is a popup menu
if state.popup_object is not None:
obj = state.popup_object
ret = obj.popup_menu.find_selected(event)
if ret is not None:
ret.call_handler()
state.event_queue.put(SlipMenuEvent(state.popup_latlon, event,
[SlipObjectSelection(obj.key, 0, obj.layer, obj.selection_info())],
ret))
state.popup_object = None
state.popup_latlon = None
if state.default_popup is not None:
ret = state.default_popup.popup.find_selected(event)
if ret is not None:
ret.call_handler()
state.event_queue.put(SlipMenuEvent(state.popup_latlon, event, [], ret))
# otherwise a normal menu
ret = self.menu.find_selected(event)
if ret is None:
return
ret.call_handler()
if ret.returnkey == 'toggleGrid':
state.grid = ret.IsChecked()
elif ret.returnkey == 'toggleFollow':
state.follow = ret.IsChecked()
elif ret.returnkey == 'toggleDownload':
state.download = ret.IsChecked()
elif ret.returnkey == 'setService':
state.mt.set_service(ret.get_choice())
elif ret.returnkey == 'gotoPosition':
state.panel.enter_position()
elif ret.returnkey == 'increaseBrightness':
state.brightness *= 1.25
elif ret.returnkey == 'decreaseBrightness':
state.brightness /= 1.25
state.need_redraw = True
|
python
|
def on_menu(self, event):
'''handle menu selection'''
state = self.state
# see if it is a popup menu
if state.popup_object is not None:
obj = state.popup_object
ret = obj.popup_menu.find_selected(event)
if ret is not None:
ret.call_handler()
state.event_queue.put(SlipMenuEvent(state.popup_latlon, event,
[SlipObjectSelection(obj.key, 0, obj.layer, obj.selection_info())],
ret))
state.popup_object = None
state.popup_latlon = None
if state.default_popup is not None:
ret = state.default_popup.popup.find_selected(event)
if ret is not None:
ret.call_handler()
state.event_queue.put(SlipMenuEvent(state.popup_latlon, event, [], ret))
# otherwise a normal menu
ret = self.menu.find_selected(event)
if ret is None:
return
ret.call_handler()
if ret.returnkey == 'toggleGrid':
state.grid = ret.IsChecked()
elif ret.returnkey == 'toggleFollow':
state.follow = ret.IsChecked()
elif ret.returnkey == 'toggleDownload':
state.download = ret.IsChecked()
elif ret.returnkey == 'setService':
state.mt.set_service(ret.get_choice())
elif ret.returnkey == 'gotoPosition':
state.panel.enter_position()
elif ret.returnkey == 'increaseBrightness':
state.brightness *= 1.25
elif ret.returnkey == 'decreaseBrightness':
state.brightness /= 1.25
state.need_redraw = True
|
[
"def",
"on_menu",
"(",
"self",
",",
"event",
")",
":",
"state",
"=",
"self",
".",
"state",
"# see if it is a popup menu",
"if",
"state",
".",
"popup_object",
"is",
"not",
"None",
":",
"obj",
"=",
"state",
".",
"popup_object",
"ret",
"=",
"obj",
".",
"popup_menu",
".",
"find_selected",
"(",
"event",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"ret",
".",
"call_handler",
"(",
")",
"state",
".",
"event_queue",
".",
"put",
"(",
"SlipMenuEvent",
"(",
"state",
".",
"popup_latlon",
",",
"event",
",",
"[",
"SlipObjectSelection",
"(",
"obj",
".",
"key",
",",
"0",
",",
"obj",
".",
"layer",
",",
"obj",
".",
"selection_info",
"(",
")",
")",
"]",
",",
"ret",
")",
")",
"state",
".",
"popup_object",
"=",
"None",
"state",
".",
"popup_latlon",
"=",
"None",
"if",
"state",
".",
"default_popup",
"is",
"not",
"None",
":",
"ret",
"=",
"state",
".",
"default_popup",
".",
"popup",
".",
"find_selected",
"(",
"event",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"ret",
".",
"call_handler",
"(",
")",
"state",
".",
"event_queue",
".",
"put",
"(",
"SlipMenuEvent",
"(",
"state",
".",
"popup_latlon",
",",
"event",
",",
"[",
"]",
",",
"ret",
")",
")",
"# otherwise a normal menu",
"ret",
"=",
"self",
".",
"menu",
".",
"find_selected",
"(",
"event",
")",
"if",
"ret",
"is",
"None",
":",
"return",
"ret",
".",
"call_handler",
"(",
")",
"if",
"ret",
".",
"returnkey",
"==",
"'toggleGrid'",
":",
"state",
".",
"grid",
"=",
"ret",
".",
"IsChecked",
"(",
")",
"elif",
"ret",
".",
"returnkey",
"==",
"'toggleFollow'",
":",
"state",
".",
"follow",
"=",
"ret",
".",
"IsChecked",
"(",
")",
"elif",
"ret",
".",
"returnkey",
"==",
"'toggleDownload'",
":",
"state",
".",
"download",
"=",
"ret",
".",
"IsChecked",
"(",
")",
"elif",
"ret",
".",
"returnkey",
"==",
"'setService'",
":",
"state",
".",
"mt",
".",
"set_service",
"(",
"ret",
".",
"get_choice",
"(",
")",
")",
"elif",
"ret",
".",
"returnkey",
"==",
"'gotoPosition'",
":",
"state",
".",
"panel",
".",
"enter_position",
"(",
")",
"elif",
"ret",
".",
"returnkey",
"==",
"'increaseBrightness'",
":",
"state",
".",
"brightness",
"*=",
"1.25",
"elif",
"ret",
".",
"returnkey",
"==",
"'decreaseBrightness'",
":",
"state",
".",
"brightness",
"/=",
"1.25",
"state",
".",
"need_redraw",
"=",
"True"
] |
handle menu selection
|
[
"handle",
"menu",
"selection"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L49-L88
|
235,146
|
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",
">",
"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",
")"
] |
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
|
235,147
|
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",
"]",
"=",
"{",
"}",
"state",
".",
"layers",
"[",
"obj",
".",
"layer",
"]",
"[",
"obj",
".",
"key",
"]",
"=",
"obj",
"state",
".",
"need_redraw",
"=",
"True"
] |
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
|
235,148
|
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",
".",
"need_redraw",
"=",
"True"
] |
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
|
235,149
|
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",
".",
"mt",
".",
"tiles_pending",
"(",
")",
")"
] |
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
|
235,150
|
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",
".",
"width",
",",
"state",
".",
"ground_width",
")"
] |
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
|
235,151
|
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",
".",
"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",
")"
] |
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
|
235,152
|
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",
")",
"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",
")"
] |
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
|
235,153
|
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",
".",
"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",
"(",
")"
] |
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
|
235,154
|
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",
".",
"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"
] |
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
|
235,155
|
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",
".",
"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"
] |
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
|
235,156
|
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",
"(",
")",
"state",
".",
"frame",
".",
"PopupMenu",
"(",
"wx_menu",
",",
"pos",
")"
] |
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
|
235,157
|
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",
"keys",
":",
"if",
"(",
"isinstance",
"(",
"state",
".",
"layers",
"[",
"l",
"]",
"[",
"key",
"]",
",",
"SlipThumbnail",
")",
"and",
"not",
"isinstance",
"(",
"state",
".",
"layers",
"[",
"l",
"]",
"[",
"key",
"]",
",",
"SlipIcon",
")",
")",
":",
"state",
".",
"layers",
"[",
"l",
"]",
".",
"pop",
"(",
"key",
")"
] |
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
|
235,158
|
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",
",",
"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",
"(",
")"
] |
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
|
235,159
|
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",
"None",
"return",
"v"
] |
evaluation an expression
|
[
"evaluation",
"an",
"expression"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavexpression.py#L26-L34
|
235,160
|
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.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\"",
")"
] |
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
|
235,161
|
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
|
235,162
|
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",
"ret"
] |
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
|
235,163
|
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",
")",
":",
"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",
")"
] |
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
|
235,164
|
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",
"*",
"0.000001",
")",
"# this ensures FMT messages get appropriate timestamp:",
"self",
".",
"timestamp",
"=",
"self",
".",
"timebase",
"+",
"first_us_stamp",
"*",
"0.000001"
] |
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
|
235,165
|
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",
"*",
"0.001",
")",
"self",
".",
"timestamp",
"=",
"self",
".",
"timebase",
"+",
"first_ms_stamp",
"*",
"0.001"
] |
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
|
235,166
|
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
|
235,167
|
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",
"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",
"=",
"{",
"}"
] |
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
|
235,168
|
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",
".",
"rewind_event",
"(",
")"
] |
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
|
235,169
|
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_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"
] |
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
|
235,170
|
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",
":",
"self",
".",
"clock",
".",
"set_message_timestamp",
"(",
"m",
")"
] |
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
|
235,171
|
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",
")",
"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",
")"
] |
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
|
235,172
|
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",
"=",
"[",
"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"
] |
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
|
235,173
|
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
|
235,174
|
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",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,175
|
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",
"=",
"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
|
235,176
|
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",
",",
"longitude",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,177
|
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",
",",
"order",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,178
|
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",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,179
|
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_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,180
|
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_component",
",",
"seq",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,181
|
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_component",
",",
"count",
")",
",",
"force_mavlink1",
"=",
"force_mavlink1",
")"
] |
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
|
235,182
|
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
|
235,183
|
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",
",",
"xml",
")",
"copy_fixed_headers",
"(",
"basename",
",",
"xml_list",
"[",
"0",
"]",
")"
] |
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
|
235,184
|
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",
".",
"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",
"(",
")"
] |
Updates Pose3d.
|
[
"Updates",
"Pose3d",
"."
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/pose3dIceClient.py#L68-L86
|
235,185
|
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
|
235,186
|
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",
"*",
"qy",
"+",
"qz",
"*",
"qz",
"rotateX",
"=",
"0.0",
"if",
"(",
"rotateXa0",
"!=",
"0.0",
"and",
"rotateXa1",
"!=",
"0.0",
")",
":",
"rotateX",
"=",
"atan2",
"(",
"rotateXa0",
",",
"rotateXa1",
")",
"return",
"rotateX"
] |
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
|
235,187
|
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'",
",",
"'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"
] |
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
|
235,188
|
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",
":",
"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",
"(",
")"
] |
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
|
235,189
|
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",
"-",
"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.
|
[
"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
|
235,190
|
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)",
"# ... ... ... ...",
"# ( 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",
")"
] |
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
|
235,191
|
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\"",
"%",
"(",
"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"
] |
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
|
235,192
|
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",
">=",
"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"
] |
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
|
235,193
|
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",
".",
"flightmode",
"=",
"None",
"self",
".",
"params",
"=",
"{",
"}"
] |
rewind to start
|
[
"rewind",
"to",
"start"
] |
303b18992785b2fe802212f2d758a60873007f1f
|
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mavmemlog.py#L68-L76
|
235,194
|
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",
"(",
"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"
] |
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
|
235,195
|
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",
".",
"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",
")",
")"
] |
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
|
235,196
|
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",
"(",
"\"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"
] |
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
|
235,197
|
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",
"(",
"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",
"]",
")",
")"
] |
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
|
235,198
|
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_list",
")",
"copy_fixed_headers",
"(",
"basename",
",",
"xml_list",
"[",
"0",
"]",
")"
] |
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
|
235,199
|
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",
",",
"value13",
",",
"value14",
",",
"value15",
",",
"value16",
",",
"value17",
",",
"value18",
",",
"value19",
",",
"value20",
")",
":",
"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",
")"
] |
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.