pyparrot.commandsandsensors package

Submodules

pyparrot.commandsandsensors.DroneCommandParser module

class pyparrot.commandsandsensors.DroneCommandParser.DroneCommandParser[source]

Bases: object

get_command_tuple(project, myclass, cmd)[source]

Parses the command XML for the specified class name and command name

Parameters:
  • myclass – class name (renamed to myclass to avoid reserved name) in the xml file
  • cmd – command to execute (from XML file)
Returns:

get_command_tuple_with_enum(project, myclass, cmd, enum_name)[source]

Parses the command XML for the specified class name and command name and checks for enum_name

Parameters:
  • myclass – class name (renamed to myclass to avoid reserved name) in the xml file
  • cmd – command to execute (from XML file)
Returns:

pyparrot.commandsandsensors.DroneSensorParser module

Sensor parser class: handles the XML parsing and gets the values but the actual data is stored with the drone itself since it knows what to do with it.

class pyparrot.commandsandsensors.DroneSensorParser.DroneSensorParser(drone_type)[source]

Bases: object

extract_sensor_values(data)[source]

Extract the sensor values from the data in the BLE packet :param data: BLE packet of sensor data :return: a list of tuples of (sensor name, sensor value, sensor enum, header_tuple)

pyparrot.commandsandsensors.DroneSensorParser.get_data_format_and_size(data, data_type)[source]

Internal function to convert data_type to the corresponding struct.pack format string as per https://docs.python.org/2/library/struct.html#format-characters

Function contributed by awm102 on GitHub. Amy moved this to DroneSensorParser to be more general, edited a bit to fit within the drone sensor parser as well.

Parameters:
  • data – the data that will be packed. Not actually used here unless the data_type is string, then it is used to calculate the data size.
  • data_type – a string representing the data type
Returns:

a tuple of a string representing the struct.pack format for the data type and an int representing the number of bytes

Module contents