How to use the uavcan.protocol.param function in uavcan

To help you get started, we’ve selected a few uavcan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UAVCAN / gui_tool / uavcan_gui_tool / widgets / node_properties.py View on Github external
            self._node.defer(0.1, lambda: self._node.request(uavcan.protocol.param.GetSet.Request(index=index),
                                                             self._target_node_id,
                                                             partial(self._on_fetch_response, index),
                                                             priority=REQUEST_PRIORITY))
        except Exception as ex:
github cvra / robot-software / tools / studio / cvra_studio / commands / param_tree.py View on Github external
def set_param(self, target_id, name, value, value_type):
        req = uavcan.protocol.param.GetSet.Request(
            name=name,
            value=value_to_uavcan(value, value_type)
        )
        self.node.request(req, target_id, self._param_changed)
github cvra / robot-software / uwb-beacon-firmware / tools / antenna_delay_calibration.py View on Github external
def set_antenna_delay(node, value):
    request = uavcan.protocol.param.GetSet.Request()
    request.name = '/uwb/antenna_delay'
    request.value = uavcan.protocol.param.Value(real_value=value)
github cvra / robot-software / tools / studio / cvra_studio / commands / param_tree.py View on Github external
def save_params(self, target_id):
        OPCODE_SAVE = 0
        request = uavcan.protocol.param.ExecuteOpcode.Request(opcode=OPCODE_SAVE)
        self.node.request(request, target_id, self._save_params_callback)
        self.logger.info('Asked node {} to save its parameters on flash'.format(target_id))
github UAVCAN / pyuavcan / uavcan / introspect.py View on Github external
# value_to_constant_name()
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().MODE_OPERATIONAL),
        'mode'
    ))
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().HEALTH_OK),
        'health'
    ))
    print(value_to_constant_name(
        uavcan.equipment.range_sensor.Measurement(reading_type=uavcan.equipment.range_sensor.Measurement()
                                                  .READING_TYPE_TOO_FAR),
        'reading_type'
    ))
    print(value_to_constant_name(
        uavcan.protocol.param.ExecuteOpcode.Request(opcode=uavcan.protocol.param.ExecuteOpcode.Request().OPCODE_ERASE),
        'opcode'
    ))
    print(value_to_constant_name(
        uavcan.protocol.file.Error(value=uavcan.protocol.file.Error().ACCESS_DENIED),
        'value'
    ))
    print(value_to_constant_name(
        uavcan.equipment.power.BatteryInfo(status_flags=
                                           uavcan.equipment.power.BatteryInfo().STATUS_FLAG_NEED_SERVICE),
        'status_flags'
    ))
    print(value_to_constant_name(
        uavcan.equipment.power.BatteryInfo(status_flags=
                                           uavcan.equipment.power.BatteryInfo().STATUS_FLAG_NEED_SERVICE |
                                           uavcan.equipment.power.BatteryInfo().STATUS_FLAG_TEMP_HOT |
                                           uavcan.equipment.power.BatteryInfo().STATUS_FLAG_CHARGED),
github cvra / robot-software / tools / studio / cvra_studio / network / ParameterTree.py View on Github external
def value_to_uavcan(value, value_type):
    """
    Given a value and its type, returns a UAVCAN Value object
    """
    if   value_type == bool:  return uavcan.protocol.param.Value(boolean_value=bool(value))
    elif value_type == int:   return uavcan.protocol.param.Value(integer_value=int(value))
    elif value_type == float: return uavcan.protocol.param.Value(real_value=float(value))
    elif value_type == str:   return uavcan.protocol.param.Value(string_value=str(value))
    else:                     return uavcan.protocol.param.Value()
github UAVCAN / pyuavcan / uavcan / introspect.py View on Github external
print(to_yaml(info))

    lights = uavcan.equipment.indication.LightsCommand()
    lcmd = uavcan.equipment.indication.SingleLightCommand(light_id=123)
    lcmd.color.red = 1
    lcmd.color.green = 2
    lcmd.color.blue = 3
    lights.commands.append(lcmd)
    lcmd.light_id += 1
    lights.commands.append(lcmd)
    print(to_yaml(lights))

    print(to_yaml(uavcan.equipment.power.BatteryInfo()))
    print(to_yaml(uavcan.protocol.param.Empty()))

    getset = uavcan.protocol.param.GetSet.Response()
    print(to_yaml(getset))
    uavcan.switch_union_field(getset.value, 'empty')
    print(to_yaml(getset))

    # value_to_constant_name()
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().MODE_OPERATIONAL),
        'mode'
    ))
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().HEALTH_OK),
        'health'
    ))
    print(value_to_constant_name(
        uavcan.equipment.range_sensor.Measurement(reading_type=uavcan.equipment.range_sensor.Measurement()
                                                  .READING_TYPE_TOO_FAR),
github cvra / robot-software / tools / studio / cvra_studio / network / ParameterTree.py View on Github external
def value_to_uavcan(value, value_type):
    """
    Given a value and its type, returns a UAVCAN Value object
    """
    if   value_type == bool:  return uavcan.protocol.param.Value(boolean_value=bool(value))
    elif value_type == int:   return uavcan.protocol.param.Value(integer_value=int(value))
    elif value_type == float: return uavcan.protocol.param.Value(real_value=float(value))
    elif value_type == str:   return uavcan.protocol.param.Value(string_value=str(value))
    else:                     return uavcan.protocol.param.Value()
github UAVCAN / pyuavcan / uavcan / introspect.py View on Github external
info = uavcan.protocol.GetNodeInfo.Response(name='legion')
    info.hardware_version.certificate_of_authenticity = b'\x01\x02\x03\xff'
    print(to_yaml(info))

    lights = uavcan.equipment.indication.LightsCommand()
    lcmd = uavcan.equipment.indication.SingleLightCommand(light_id=123)
    lcmd.color.red = 1
    lcmd.color.green = 2
    lcmd.color.blue = 3
    lights.commands.append(lcmd)
    lcmd.light_id += 1
    lights.commands.append(lcmd)
    print(to_yaml(lights))

    print(to_yaml(uavcan.equipment.power.BatteryInfo()))
    print(to_yaml(uavcan.protocol.param.Empty()))

    getset = uavcan.protocol.param.GetSet.Response()
    print(to_yaml(getset))
    uavcan.switch_union_field(getset.value, 'empty')
    print(to_yaml(getset))

    # value_to_constant_name()
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().MODE_OPERATIONAL),
        'mode'
    ))
    print(value_to_constant_name(
        uavcan.protocol.NodeStatus(mode=uavcan.protocol.NodeStatus().HEALTH_OK),
        'health'
    ))
    print(value_to_constant_name(
github cvra / robot-software / tools / motor_config_loader.py View on Github external
def send_parameter(self, name, value, board_name):
        with self.node_lock:
            request = uavcan.protocol.param.GetSet.Request(name=name)
            # TODO other types
            if type(value) == bool:
                request.value.boolean_value = value
            elif type(value) == int:
                request.value.integer_value = value
            else:
                request.value.real_value = value

            self.node.request(request, self.boards_id_by_name[board_name],
                              self._send_parameter_callback)

        # Wait for an answer
        self.rpc_answered.acquire()