Skip to content

mavsdk-python Param.select_component() returns UNKNOWN for non-autopilot components (e.g. component 51,123,124) #818

@VamsiTungala

Description

@VamsiTungala

Summary

Param.select_component() exists in mavsdk-python and is documented, but on my setup it returns ParamError: UNKNOWN when selecting non-autopilot components (for example component 51), even though those components are discovered by mavsdk_server.

This prevents using the MAVSDK Param plugin to upload params to components from a .params file (e.g. CAN/UAVCAN peripherals).

Environment

  • MAVSDK server version: v3.15.0 (from logs)
  • mavsdk-python: 3.15.3 (pip install)
  • OS: Linux (Ubuntu, Python 3.10)

What I’m trying to do

Use the MAVSDK Param plugin with:

  • select_component(component_id, ProtocolVersion.V1) or ProtocolVersion.EXT
  • set_param_int/float/custom(...)

to upload parameters to components listed in a PX4 .params file (component IDs like 51, 123, 124 - UAVCAN Devices).

Python Script

#!/usr/bin/env python3
import asyncio
from mavsdk import System
from mavsdk.param import ProtocolVersion
import logging
logging.basicConfig(level=logging.DEBUG)
async def wait_for_connection(drone: System):
    async for state in drone.core.connection_state():
        if state.is_connected:
            return
async def main():
    drone = System()
    await drone.connect(system_address="udpin://0.0.0.0:14550")
    await wait_for_connection(drone)
    print("Connected")
    try:
        await drone.param.select_component(51, ProtocolVersion.V1)
        print("Selected component 51 (V1)")
    except Exception as exc:
        print(f"select_component failed: {exc}")
        pass
    await drone.param.set_param_int("CELL_EMPTY_VOLTA", 3600)
    print("Set CELL_EMPTY_VOLTA = 3600 on component 51")

if __name__ == "__main__":
    asyncio.run(main()) 

Terminal Log

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:grpc._cython.cygrpc:[_cygrpc] Loaded running loop: id(loop)=139374995289184
DEBUG:grpc._cython.cygrpc:Using AsyncIOEngine.POLLER as I/O engine
DEBUG:grpc._cython.cygrpc:[_cygrpc] Loaded running loop: id(loop)=139374995289184
DEBUG:mavsdk.async_plugin_manager:Waiting for mavsdk_server to be ready...
INFO:mavsdk_server:MAVSDK version: v3.15.0 (mavsdk_impl.cpp:33)
INFO:mavsdk_server:Waiting to discover system on udpin://0.0.0.0:14550... (connection_initiator.h:20)
INFO:mavsdk_server:New system on: 10.41.1.1:45177 (system ID: 1) (udp_connection.cpp:263)
DEBUG:mavsdk_server:Component Autopilot (component ID: 1) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 192) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Discovered 2 components (system_impl.cpp:616)
INFO:mavsdk_server:System discovered (connection_initiator.h:62)
INFO:mavsdk_server:Server started (grpc_server.cpp:177)
INFO:mavsdk_server:Server set to listen on 0.0.0.0:50051 (grpc_server.cpp:178)
DEBUG:mavsdk_server:MAVLink: critical: Preflight: GPS Speed Accuracy too low (system_impl.cpp:358)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 155) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 236) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Compass 0 uncalibrated (system_impl.cpp:358)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 40) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Compass 1 uncalibrated (system_impl.cpp:358)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 198) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 97) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Companion Computer (component ID: 191) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Press safety button first (system_impl.cpp:358)
DEBUG:mavsdk_server:MAVLink: emergency: Battery 1: over voltage.         (system_impl.cpp:358)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 51) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 60) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 195) added. (system_impl.cpp:496)
DEBUG:mavsdk_server:Component Unsupported component (component ID: 63) added. (system_impl.cpp:496)
DEBUG:mavsdk.async_plugin_manager:Connected to mavsdk_server!
DEBUG:grpc._cython.cygrpc:[_cygrpc] Loaded running loop: id(loop)=139374995289184
Connected
DEBUG:grpc._cython.cygrpc:[_cygrpc] Loaded running loop: id(loop)=139374995289184
select_component failed: UNKNOWN: 'Unknown'; origin: select_component(); params: (51, <ProtocolVersion.V1: 0>)
DEBUG:grpc._cython.cygrpc:[_cygrpc] Loaded running loop: id(loop)=139374995289184
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
WARNING:mavsdk_server:sending again, retries to do: 5  (CELL_EMPTY_VOLTA). (mavlink_parameter_client.cpp:1163)
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
WARNING:mavsdk_server:sending again, retries to do: 4  (CELL_EMPTY_VOLTA). (mavlink_parameter_client.cpp:1163)
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Compass 0 uncalibrated (system_impl.cpp:358)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Compass 1 uncalibrated (system_impl.cpp:358)
DEBUG:mavsdk_server:MAVLink: critical: Preflight Fail: Press safety button first (system_impl.cpp:358)
DEBUG:mavsdk_server:MAVLink: emergency: Battery 1: over voltage.         (system_impl.cpp:358)
WARNING:mavsdk_server:sending again, retries to do: 3  (CELL_EMPTY_VOLTA). (mavlink_parameter_client.cpp:1163)
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
WARNING:mavsdk_server:sending again, retries to do: 2  (CELL_EMPTY_VOLTA). (mavlink_parameter_client.cpp:1163)
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
WARNING:mavsdk_server:sending again, retries to do: 1  (CELL_EMPTY_VOLTA). (mavlink_parameter_client.cpp:1163)
WARNING:mavsdk_server:Got ill-formed param_value message (param_id empty) (mavlink_parameter_client.cpp:661)
ERROR:mavsdk_server:Error: Retrying failed set param timeout: CELL_EMPTY_VOLTA (mavlink_parameter_client.cpp:1183)
Traceback (most recent call last):
  File "minimum_upload.py", line 31, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "minimum_upload.py", line 27, in main
    await drone.param.set_param_int("CELL_EMPTY_VOLTA", 3600)
  File "/home/user/.local/lib/python3.10/site-packages/mavsdk/param.py", line 585, in set_param_int
    raise ParamError(result, "set_param_int()", name, value)
mavsdk.param.ParamError: TIMEOUT: 'Timeout'; origin: set_param_int(); params: ('CELL_EMPTY_VOLTA', 3600)

Having similar error to get parameters of perticular component. get_all_params() is not downloading other component parameters (my case 51,123,124 - UAVCAN Components)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions