Arduino library for providing a convenient C++ interface for accessing UAVCAN.

107-Arduino-UAVCAN

Arduino Library Badge Unit Tests codecov Compile Examples Arduino Lint keywords.txt Checks General Formatting Checks Spell Check

Arduino library for providing a convenient C++ interface for accessing UAVCAN (v1.0-beta) utilizing libcanard.

This library works for

Reference-Implementation UAVCAN on Arduino

Example

Note: Please be advised that the examples shipped with this library are to be considered minimal examples to get you started working with UAVCAN. They are known to violate section 2.1.2.2 Regulation of the UAVCAN Specification due to their reliance on hard-coded port identifiers. A compliant implementation would instead provide configurable port-IDs and support the Register Interface (section 5.3 Application-layer functions). Fully compliant examples that implement reconfigurable port-IDs are shipped separately; e.g., UAVCAN-GNSS-Node.

#include <ArduinoUAVCAN.h>
/* ... */
ArduinoUAVCAN uavcan(13, transmitCanFrame);
Heartbeat_1_0 hb;
/* ... */
void loop() {
  /* Update the heartbeat object */
  hb.uptime(millis() / 1000);
  hb.mode = Heartbeat_1_0::Mode::OPERATIONAL;

  /* Publish the heartbeat once/second */
  static unsigned long prev = 0;
  unsigned long const now = millis();
  if(now - prev > 1000) {
    uavcan.publish(hb);
    prev = now;
  }

  /* Transmit all enqeued CAN frames */
  while(uavcan.transmitCanFrame()) { }
}
/* ... */
bool transmitCanFrame(CanardFrame const & frame) {
  /* ... */
}

Contribution

How to add missing wrappers

Step 1) Generate C header files from DSDL

Option A) Use nunavut/nnvg

  • Install nunavut: pip install nunavut (you will need a functional Python installation)
  • Get some DSDL
git clone https://github.com/UAVCAN/public_regulated_data_types
  • Generate C header files from DSDL
nnvg --target-language c \
     --pp-max-emptylines=1  \
     --pp-trim-trailing-whitespace \
     --target-endianness=any \
     --enable-serialization-asserts \
     --outdir public_regulated_data_types/uavcan-header \
     public_regulated_data_types/uavcan

nnvg --target-language c \
     --pp-max-emptylines=1  \
     --pp-trim-trailing-whitespace \
     --target-endianness=any \
     --enable-serialization-asserts \
     --lookup public_regulated_data_types/uavcan \
     --outdir public_regulated_data_types/reg-header \
     public_regulated_data_types/reg

Option B) Use nunaweb

Step 2) Copy generated C header files to src/types
types/reg/drone/physics/electricity/
├── Power_0_1.h
├── PowerTs_0_1.h
├── Source_0_1.h
└── SourceTs_0_1.h
Step 3) Fix include path in generated C header files by prefixing it with <types/
-#include <uavcan/file/Path_1_0.h>
+#include <types/uavcan/file/Path_1_0.h>
...
-#include <reg/drone/physics/electricity/Power_0_1.h>
+#include <types/reg/drone/physics/electricity/Power_0_1.h>
Step 4) Manually implement wrapper classes in src/wrappers
wrappers/reg/drone/physics/electricity/
├── Power_0_1.hpp
├── PowerTs_0_1.hpp
├── Source_0_1.hpp
└── SourceTs_0_1.hpp
Step 5) Add the wrapper clases to src/ArduinoUAVCANTypes.h
+#include "wrappers/reg/drone/physics/electricity/Power_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/PowerTs_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/Source_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/SourceTs_0_1.hpp"
Step 6) Create PR to mainline your changes

Note: Only UAVCAN types listed in public_regulated_data_types:master will be accepted into this repository.

Comments
  • Initial draft for a simpler wrapper implementation.

    Initial draft for a simpler wrapper implementation.

    This is a first draft for simplifying the currently manually coded wrapper system. A template base-class DSDLBaseType is parametrized according to the need of the desired wrapper type. One thing I've not figured out yet is how to "automatically" bind the port id for fixed ID DSDL types. Any suggestion @pavel-kirienko?

  • Add missing wrappers for uavcan/si

    Add missing wrappers for uavcan/si

    This PR is intended as a draft PR related to https://github.com/107-systems/107-Arduino-UAVCAN/issues/98. I started with uavcan/si/sample/acceleration. I plan on creating wrappers like this for all uavcan/si data types, but I would be very grateful if you @aentinger are able to check if this is the correct approach and how you intended it to be done before I move on to the rest.

  • Where does nunavut generated files get copied to ?

    Where does nunavut generated files get copied to ?

    There is a src folder where the -types --uavcan -utility .... is present I see that the automatically generated header files are all edited to account for the fact that Arduino cannot be given an additional -I flag to include the "types" folder. This would mean that all the autogenerated files are manually edited. Is this right ?

  • Create use case to demonstrate how to use 107-Arduino-UAVCAN to build a UAVCAN node

    Create use case to demonstrate how to use 107-Arduino-UAVCAN to build a UAVCAN node

    Suggestion by @pavel-kirienko in UAVCAN Weekly Dev Call 2020/11/18.

    Possibly a GPS node using @generationmake ElaraGNSSMKRShield? Further suggestions welcome.

  • Added fixed PortIDs to all wrappers

    Added fixed PortIDs to all wrappers

    As was discussed in #99

    I noticed that:

    • ./uavcan/node/430.GetInfo.1.0.uavcan
    • ./uavcan/node/434.GetTransportStatistics.0.1.uavcan
    • ./uavcan/node/435.ExecuteCommand.1.0.uavcan
    • ./uavcan/node/435.ExecuteCommand.1.1.uavcan
    • ./uavcan/node/7509.Heartbeat.1.0.uavcan

    Arent templated so i left those as is.

    I also noticed that the wrappers for: uavcan/node/port/* are missing.

  • ToF-Sensor Example

    ToF-Sensor Example

    ~~The prev_heartbeat is set to 0 at each iteration of the loop:~~ EDIT: It is not, see this reply by @pavel-kirienko : https://github.com/107-systems/107-Arduino-UAVCAN/pull/132#issuecomment-917652444

    Also, do you plan on completing the ToF-Sensor example in order to publish ranges instead of just the heartbeat? Please let me know if I can contribute something there.

  • generates corrupted CAN messages

    generates corrupted CAN messages

    The library generates corrupted CAN messages when received with a MCP2518FD:

    ip -details -statistics link show type can

    shows

    4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
        link/can  promiscuity 0 minmtu 0 maxmtu 0 
        can state ERROR-PASSIVE (berr-counter tx 0 rx 131) restart-ms 0 
    	  bitrate 250000 sample-point 0.875 
    	  tq 50 prop-seg 34 phase-seg1 35 phase-seg2 10 sjw 1
    	  mcp251xfd: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
    	  mcp251xfd: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
    	  clock 20000000
    	  re-started bus-errors arbit-lost error-warn error-pass bus-off
    	  0          0          0          2061       9048       0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
        RX: bytes  packets  errors  dropped overrun mcast   
        3400308    639469   0       18      0       0       
        TX: bytes  packets  errors  dropped carrier collsns 
        0          0        0       0       0       0       
    

    Testsetup:

    • Arduino MKR WiFi with Arduino CAN MKR Shield, Sketch: UAVCAN-Heartbeat-Publish example without modifications
    • Raspberry Pi with MCP2518FD on SPI bus

    Findings so far:

    • the sketch generates the receive errors as shown above.
    • using 107-Arduino-MCP2515 and the example from teh Readme alone doesn't generate any errors
    • using an MCP2515 on the Raspberry Pi side doesn't generate any errors
    • using other CAN libraries like https://github.com/sandeepmistry/arduino-CAN doesn't generate any receive errors

    Sorry that I can't give a better error description.I have tested several things but nothing worked. Maybe someone with a CAN analyzer could help here.

  • Add Bit.1.0 and LED example

    Add Bit.1.0 and LED example

    I added functions for custom subjects for the area of unregulated identifiers. There is also an example which allows turn the builtin LED of the Arduino on and off using uavcan.

    However there are some drawbacks with these changes:

    • The Subject-IDs are hard coded into the library. This is against the UAVCAN spec which wants them to be configurable. Additionally only one data type per instance is possible.
    • Code-generation by DSDL was not used
    • The datatypes are maybe in the wrong folder
    • By now only two data types are implemented: scalar.Bit.1.0 and scalar.Real32.1.0
  • Fix: Assign fixed port IDs for DSDL wrappers which have a fixed port ID assigned

    Fix: Assign fixed port IDs for DSDL wrappers which have a fixed port ID assigned

    All existing DSDL wrappers stored in src/wrappers need to be checked against the DSDL specification in public_regulated_data_types. Any type that has a fixed-port ID (can be identified by a number prefixed to the type name), e.g. 409.Write.1.0.uavcan, the corresponding wrapper need to be modified as shown below:

    -template <CanardPortID ID>
    +template <CanardPortID ID = uavcan_file_Write_1_0_FIXED_PORT_ID_>
    class Request
    {
    ...
    -template <CanardPortID ID>
    +template <CanardPortID ID = uavcan_file_Write_1_0_FIXED_PORT_ID_>
    class Response
    {
    ...
    
  • Fix errors in Compile Examples CI workflow

    Fix errors in Compile Examples CI workflow

    GitHub Actions has the unfortunate behavior of failing silently when the workflow is invalid. Although you can still see the failed runs in the "Actions" page, they don't affect the status of the CI build, so it's easy to not notice one missing workflow when you have other workflows running during the CI build.


    There is still one outstanding issue that will cause the Compile Examples run for this PR to fail: the "size-report-sketch" used by the workflow, Orel-20-Status was removed by https://github.com/107-systems/107-Arduino-UAVCAN/commit/06f31fe729002397f51e60db64a895513bf2467e, which results in the error:

    ##[error]size-report-sketch: Orel-20-Status was not found
    

    So I need to change that to one of the existing examples. @aentinger, which of the two examples do you want to use as the size report sketch for the Report Size Deltas workflow?

    • UAVCAN-Heartbeat-Publish
    • UAVCAN-Heartbeat-Subscribe

    Once I have done that, I'll take the PR out of draft status and it will be ready for merge

  • Update to libcanard:v3.0.0

    Update to libcanard:v3.0.0

    Depends on https://github.com/107-systems/107-Arduino-MCP2515/pull/58.

    Hi @generationmake :coffee: :wave:

    Can you please test one (or more) of the examples on hardware?

  • Implement Subscription loosely following the ROS2 API.

    Implement Subscription loosely following the ROS2 API.

    Note: Since the service server/client API has not been cleanly separated in the past with the API for message subscription this is leading to a couple of CI build errors now. Regardless fixing request/response API is out-of-scope for this PR and will be fixed in a sub-sequent one.

  • [Feature Request] Automate C++ wrapper generation

    [Feature Request] Automate C++ wrapper generation

    ⚡ Feature Request

    Currently the generation of C++ wrappers is done manually. This is tedious, work-intensive and error-prone.

    Some work to automatically generate the wrapper files has been started here, but has since come to a stand-still.

    Note: While tackling this issue it might make sense to upgrade to generating C++ headers directly.

  • [Feature Request] Implement support for CAN FD (64 Bytes MTU)

    [Feature Request] Implement support for CAN FD (64 Bytes MTU)

    ⚡ Feature Request

    Although the API indicates that CAN FD (with 64 Bytes MTU) are supported the reality is that right now the library only supports 8 bytes of MTU (CAN Classic).

  • [Feature Request] Support x86 as compilation target

    [Feature Request] Support x86 as compilation target

    ⚡ Feature Request

    This library should not be only used in combination with various Arduino cores but should be also compilable as a static C++ library and used with executable compiled for and executed on x86.

  • [Feature Request] Remodel API to emulate ROS publish/subscribe APIs

    [Feature Request] Remodel API to emulate ROS publish/subscribe APIs

    ⚡ Feature Request

    Doing so would simplify the internal logic of Node.

    auto heartbeat_pub = node_hdl.create_publisher<uavcan::node::Heartbeat>(/* to be defined */);
    heartbeat_pub.publish(heartbeat_msg);
    
    auto heartbeat_sub = node_hdl.::create_subscription<uavcan::node::Heartbeat>(/* to be defined */);
    
Arduino-compatible library to interface RC1701HP-OSP/WIZE radio modules.
Arduino-compatible library to interface RC1701HP-OSP/WIZE radio modules.

AllWize Arduino-compatible library to interface RC1701HP-OSP/WIZE radio modules. Compatible radios: RadioCrafts RC1701HP-OSP (Ondeo version) RadioCraf

Aug 3, 2022
Arduino Arduino library for the CloudStorage server project. The library provides easy access to server-stored values and operations.

Arduino-CloudStorage Arduino/ESP8266 library that allows you to easly store and retreive data from a remote (cloud) storage in a key/value fashion. Cl

Jan 30, 2022
Unified interface for selecting hardware or software SPI implementations on Arduino platforms

AceSPI Unified interface for selecting hardware or software SPI implementations on Arduino platforms. The code was initially part of the AceSegment li

Oct 22, 2021
Unified interface for selecting different implementations for communicating with a TM1637 LED controller chip on Arduino platforms

AceTMI Unified interface for communicating with a TM1637 LED controller chip on Arduino platforms. The code was initially part of the AceSegment libra

Feb 2, 2022
Unified interface for selecting different I2C implementations on Arduino platforms

AceWire Wrapper classes that provide a simple, unified interface for different I2C implementations on Arduino platforms. The code was initially part o

Dec 14, 2022
Arduino library for making an IHC in or output module using an Arduino

Introduction This is an Arduino library for making an IHC in or output module using an Arduino. (IHC controller is a home automation controller made b

Mar 26, 2020
ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT Cloud

ArduinoIoTCloud What? The ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT

Dec 16, 2022
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32

The Approximate Library The Approximate library is a WiFi Arduino Library for building proximate interactions between your Internet of Things and the

Dec 7, 2022
Simple web interface builder for esp8266 and ESP32
Simple web interface builder for esp8266 and ESP32

GyverPortal Простой конструктор веб интерфейса для esp8266 и ESP32 Простой конструктор - делаем страницы без знаний HTML и CSS Библиотека является обё

Jan 8, 2023
Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.
Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.

107-Arduino-MCP2515 Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames. This library is prepared to interface easily

Nov 16, 2022
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

107-Arduino-NMEA-Parser Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages. This library

Jan 1, 2023
Arduino web server library.

aWOT Arduino web server library. Documentation 1. Getting started Hello World Basic routing Application generator Serving static files 2. Guide Routin

Jan 4, 2023
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485

ABB Aurora protocol You can refer the complete documentation on my site ABB Aurora PV inverter library for Arduino, esp8266 and esp32 I create this li

Nov 22, 2022
Arduino library for the MCP2515 CAN Controller

MCP2515 CAN Controller Library for Arduino Compatibility with the ACAN library This library is fully compatible with the Teensy 3.x ACAN library https

Dec 18, 2022
CAN / CANFD Arduino Library for Teensy 4.0

CAN Library for Teensy 4.0 / 4.1 It handles Controller Area Network (CAN) for CAN1, CAN2 and CAN3, and Controller Area Network with Flexible Data (CAN

Dec 9, 2022
Analog Devices Analog Digital Converter AD7173 Arduino library

AD7173-Arduino Analog Devices AD7173 analog digital converter Arduino library Mostly tested setup for this library: 1007 data rate external crystal co

Nov 20, 2022
Arduino library for nRF51822-based Adafruit Bluefruit LE modules

This library is for all nRF51 based Adafruit Bluefruit LE modules that use SPI or UART. Current nRF51 based Bluefruit LE products include: Bluefruit L

Nov 6, 2022
Arduino library for the Adafruit FONA

Adafruit FONA Library This library requires Arduino v1.0.6 or higher This is a library for the Adafruit FONA Cellular GSM Breakouts etc Designed speci

Dec 15, 2022
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.

Adafruit IO Arduino Library This library provides a simple device independent interface for interacting with Adafruit IO using Arduino. It allows you

Dec 23, 2022