Skip to content

BeyondRobotix/Arduino-DroneCAN

Repository files navigation

Arduino DroneCAN

This repository allows easy integration of sensors to be used with Ardupilot and PX4 via DroneCAN. Sensors can be integrated within minutes by using pre-existing Arduino libraries for sensors, and through this library which abstracts the DroneCAN layer so you can focus on sending and receiving messages.

By using the Arduino core and PlatformIO with pre-configured board setups, you can start developing instantly.

This isn't intended to be used in the same way as AP_Periph, which supports a bunch of Ardupilot sensors all at once and is adaptable without writing code. This is intended for writing a DroneCAN interface for any sensor or system, without having to deal with a large code base and lots of boilerplate.

Features

API changes can happen at any time in master. See the releases page to download a specific verison for your project.

  • Send DroneCAN messages ✅
  • Receive DroneCAN messages ✅
  • Standard DroneCAN under the hood (allocation, node info) ✅
  • DroneCAN Parameters ✅
  • Firmware update over CAN ✅

Code Usage

Apart from calling usual init functions and our library update function, sending a DroneCAN message boils down to this:

uavcan_equipment_power_BatteryInfo pkt{};
pkt.voltage = analogRead(PA1);
pkt.current = analogRead(PA0);

sendUavcanMsg(dronecan.canard, pkt);

See Beyond Robotix Gitbooks ArduinoCAN documentation for more information!

Currently Supported Hardware

This repository is plug and play with the Beyond Robotix CAN node series!

See Beyond Robotix Can Node

We've got some handy docs for the node hardware and some more software explaination and examples here CAN node gitbook

Support

If you get stuck with this repository, the discussions section will allow us to help out.

For dedicated engineering support on your application, contact [email protected]. We can also quote for writing custom firmware for you!

Repository structure

This repository is designed to be cloned and run straight away using the example application in ./src/main.cpp.

All 3 of the following libraries are required:

  • ./lib/arduino_dronecan contains the library which has been written to make dronecan plug and play
  • ./lib/dronecan contains the actual dronecan message types generated by dronecan_dsdlc
  • ./lib/libcanard contains the canard library which handles parsing of dronecan messages

There is some platformio boilerplate to do to support new boards

  • ./boards
  • ./variants

The required repos to generate the dronecan messages etc are in ./dronecan, although ./lib already contains the generated files so these are just for reference.

Standing on the shoulders of Giants.

This repo is built on many resources:

Other stuff which didn't get used but interesting

Other notes

Dronecan DSDLC

If you want to generate the dronecan message headers from scratch, ensure you have the submodules cloned, then:

cd dronecan

python dronecan_dsdlc/dronecan_dsdlc.py -O ../lib/dronecan

dronecan generate files