Homepage GitHub

Vendor specific type



According to specification at https://uavcan.org/Implementations/Pyuavcan/Tutorials/2._Basic_usage/
pyuavcen loads vendor specific DSDLs when loaded (import uavcan).
I have places my own definitions at this location:

# contains 20001.broadcast_type_test.uavcan

Then in my python script I try to load them like this:

import uavcan

node_info = uavcan.protocol.GetNodeInfo.Response()
node_info.name = 'TestNode'
node_info.software_version.major = 1
node = uavcan.make_node('vcan0', node_id=123, bitrate=125000, node_info=node_info)
node.mode = uavcan.protocol.NodeStatus().MODE_OPERATIONAL

def do_publish():
    msg = mydefs.broadcast_type_test(value=47)
    node.broadcast(msg, priority=uavcan.TRANSFER_PRIORITY_LOWEST)

handle = node.periodic(1, do_publish)

while True:
    node.spin(1)            # Spin for 1 second or until an exception is thrown


However, I det errors when running the script with

python3 myscript.py
  File "myscript.py", line 19, in do_publish
    msg = mydefs.broadcast_type_test(value=47)
NameError: name 'mydefs' is not defined

Sorry for my poor python knowledge, but what am I missing here?

Kind regards

(Antoine Albertelli) #2


From the page you linked:

Standard definitions can be reached directly from the module namespace, e.g. uavcan.protocol.NodeStatus. Vendor-specific definitions can be accessed via the pseudo-module uavcan.thirdparty. Both standard and vendor-specific types are also accessible via the global dictionaries uavcan.DATATYPES and uavcan.TYPENAMES.

That means you should access your custom data type like this:

msg = uavcan.thirdparty.mydefs.broadcast_type_test(value=47)



Aha! Thanks, I misunderstood that…