UAVCAN send CAN frames with customized hexadecimal CAN ID --> use of pixhawk 4 builing px4_fmu-v5_default

#1

Hi all,

I am working on enabling CAN communication between our pixhawk 4 and a vendor specific motor controller. This motor controller accepts raw CAN messages with either hex 11 bit identifier (for example 00A) or there is the option of using extended identifier 000000A0.

I have been looking at several useful posts: UAVCAN execution in px4 however I cannot find where and how is possible to forze UAVCAN to use specific hex identifiers.

My trials boil down to 2 options:

  1. I have already made use of libuavcan functions defined in https://github.com/UAVCAN/libuavcan/blob/dfcdf22eda16ff06847976fd6c7f40671fc92eb5/libuavcan_drivers/linux/apps/test_multithreading.cpp#L228 to circumvent the protocol stack such as: **virtual void injectTxFramesInto(uavcan::INode& main_node) = 0;**where I can as well as with socketCAN, define a CAN ID.

  2. I also tried to tackle the issue from px4 and understood as pointed here: https://github.com/PX4/Firmware/blob/327354705b3519472dd493e687b014ce44c6415d/src/drivers/uavcan/actuators/esc.cpp#L168 that is broadcast(msg) the function scheduling CAN frames to be sent. However the data type of msg () is linked to a data structure: uavcan::equipment::esc::RawCommand and the CAN ID seen in UAVCAN GUI (CAN ID = 05040601):

It is generated based on the UAVCAN specification. I tried to generate another data structure with the dsdlr compiler but the ID is generated automatically and I dont know how to modify it.
I understand that there is a good reason to specify in UAVCAN protocol the structure of ID to parse and classify different messages from different nodes, however the device I am working with will not recognize the CAN ID used by UAVCAN nodes.

so my questions are:
regarding 1.) how can I make use of injectTxFrame because my temporary attempt modified in esc.cpp:


does not work.

and regarding 2.) is there a way of creating custom dsdl data types with hexadecimal CAN IDs? or to generate CAN frames in px4 with customized hexadecimal format?

Any help would be much appreciated,
Thanks in advance.

#2

I’m not sure if you figured this out yet, but you should take a look at this webpage on the DSDL. You do not define the data ID in the message, it is defined in the filename and the compiler takes care of the rest. The compiler does not assign the ID randomly or automatically, it uses whatever type ID you have defined in the file name.

You could convert your hex string to decimal characters and use that as the ID.

Why are you concerned about specifying your type ID with hex or using a special hex format? Everything gets sent in binary anyway, so as long as you can encode/decode the 1’s and 0’s, you won’t have issues.

#4

Hi @Tere_uav

                   I was able to send CAN frames from pixhawk 4 to a vendor specific device. Yes, the CAN ID in GUI tool would show the hexadecimal value. Where the 3 to 4 bytes of this hexadecimal value would correspond to the data type ID of your CAN message from pixhawk 4.   With respect to que 2 I  mapped the hex ID from Pixhawk as CAN ID of my receiver device and it worked[I created a custom dsdl file]. Not sure if it would help you but its how I made it work.

Regards
Niran