Vendor specific type


According to specification at
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() = '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

  File "", 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


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)


1 Like

Aha! Thanks, I misunderstood that…