Giter VIP home page Giter VIP logo

107-arduino-uavcan's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.