I am interested in having my Pixhawk 1 communicate with a payload over CAN bus. As a first step, I would like the Pixhawk to ‘listen’ to the CAN messages and record such data to the SD card.
Next step will be to have the Pixhawk respond to certain CAN messages, such as RTL in the event of a fault with the payload.
And finally, the Pixhawk shall be able to send commands over CAN to the payload in response to a input from the pilot, such as a change in flight mode.
I am curious where I should start with this effort as this would be a custom implementation rather than a CAN node that can already be recognized by the Pixhawk. I have the development environment setup on Ubuntu as well as SIL up and running.
I’m not sure how I can help. As you’ve said, this is a custom implementation so you’ll need to do some coding - you need to start by studying the ArduPilot codebase.
I’ll also say that we are currently doing changes in CAN. We only supported UAVCAN in PX4 boards (Pixhawk, Pixracer, The Cube) through the PX4Firmware layer, but we are changing this to an in-tree implementation - still only supporting UAVCAN, but ready to be extended to other CAN protocols.
Thank you for the reply. I am in the process of studying the codebase. I have the dev environment setup on Linux along with SITL. I am learning about writing apps at the moment and running them within the existing loops. Do you have any examples of interfacing with the Pixhawk CAN system?
No, I don’t. Are you going to use UAVCAN with a custom message or pure CAN? After Monday we’ll have merged the change to CAN I talked about above, it should be easier then for you to look at how we get and use UAVCAN messages.
Our payload does not use UAVCAN. Unfortunately the payload was developed prior to knowing what flight controller was going to be used. I may need to write some translator of some kind. The CAN bus will only have 3 nodes, 2 on the payload and the Pixhawk. There are very few message in the protocol as well, so it should be fairly straightforward.
The first step is to simply have the Pixhawk listen to and log the raw CAN packets from the payload. Are you able to assist with this? From there we can worry about converting the messages into actionable items.
Do you have any documentation on this new CAN implementation you are working on?
If it doesn’t have UAVCAN, it is going to be more work for you. I can try to give you some tips, but you’ll really need to learn the codebase. Also, we have a Gitter room where you can ask and people will try to help (just note that there are very few developers with the required knowledge there): https://gitter.im/ArduPilot/CANBUS
I’m also interested in recording data from a CAN input onto the SD card of a Pixhawk Cube 2.1.
Specifically, a signal given by an Arduino Uno which is converting an analogue signal from a load cell. I’m currently busy with the Arduino code.
Are there any specific guidelines to getting this to work? Any specific protocol for the CAN to allow the Pixhawk to read/store?