Giter Site home page Giter Site logo

cyphal_lua_ardupilot's Introduction

linter tests coverage

ArduPilot Cyphal/CAN LUA Driver

This driver implements support for Cyphal ESCs such as Myxa, Mini node, kotleta20 and other devices.

It supports the minimal required features for a Cyphal node: uavcan.node.Heartbeat.

It supports ESC service for up to 8 ESC:

The driver does not provide support for features such as uavcan.node.GetInfo, Register interface and uavcan.node.port.List.

1. USAGE

Step 1. Upload ArduPilot firmware

First, you need to upload an ArduPilot firmware to the FMU. In general, it should work with any version of ArduPilot that supports LUA. It has been tested with the latest stable version v4.4.4. The easiest ways to upload the firmware are to use QGroundControl or MissionPlanner.

QGroundControl MissionPlanner
drawing drawing

Alternatively, you can manually build a binary and upload the firmware via cli. Here is an example for CUAVv5:

./waf list_boards
./waf configure --board CUAVv5
./waf copter
./waf --targets bin/arducopter --upload

Step 2. Load Cyphal.lua to microSD card

This driver should be loaded by placing the lua script in the APM/scripts directory on the microSD card, which can be done either directly or via MAVFTP.

Copy directly Using MAVFtp
drawing drawing

Step 3. Enable LUA on CAN

The following parameters should be set to start the script and configure the CAN driver:

SCR_ENABLE 1 1 means scripting is enabled, 0 means disabled
CAN_D1_PROTOCOL 10 10 means scripting
CAN_P1_DRIVER First driver
CAN_P1_BITRATE 1000000 Default bitrate for most of the applications

Then the flight controller should be rebooted and parameters should be refreshed.

Some parameters appear only after setting other parameters, so you may need to reboot the autopilot a few times

Step 4. Set Cyphal registers

Once Cyphal.lua script is succesfully executed, a few Cyphal registers will appear in the parameters.

The autopilot node has the following Cyphal-related parameters:

CYP_ENABLE 1 1 means Cyphal is enabled, 0 means disabled
CYP_NODE_ID 1-127 Node identifier in Cyphal-network. Usually, 127 is reserved for debugging tools and 1 is used for an autopilot.
CYP_TESTS 0 If set to 1, self tests will be runned at the beginning of the application.

and it has the following Port-registers:

CYP_RD 1-8191 Readiness port id. Enabled if less then 8191, otherwise disabled. By default, 65535.
CYP_SP 1-8191 Setpoint port id for ESCs. Enabled if less then 8191, otherwise disabled. By default, 65535.
CYP_FB 1-8191 ESC Feedback array of port id. Enabled if less then 8191, otherwise disabled. By default, 65535. When enabled, it occupies 8 consecutive port identifiers. For example, if it is 3000, it will occupy [3000, 3007] identifiers.

It's well researched, but sometimes parameters don't appear in the Ground Control Station. A simple reboot of QGC solves this problem.

Step 5. Try with yakut

Configure the yakut-related environment variables, connect autopilot and CAN-sniffer together.

drawing

If you run y mon, you should get:

drawing

Here, we have 2 nodes: autopilot with node_id=1 (it is configured in CYP_NODE_ID) and yakut with node_id=127. The autopilot publishes setpoint with port_id=2000 (CYP_SP) with ~234 Hz and readiness with port_id=2001 (CYP_RD) with ~10 Hz.

Since the node doesn't support anything except uavcan.node.Heartbeat, it doesn't have a name and registers are not avaliable via Cyphal/CAN interface.

Additionally, you can subscribes to the setpoint and readiness topics:

y sub 2001:reg.udral.service.common.Readiness
y sub 2000:reg.udral.service.actuator.common.sp.Vector8

Step 6. Publish emulated ESC feedback

in process

2. CONTRIBUTING

Before pushing a commit:

  1. Check code style with lua-check
  2. Run tests with lua tests/all.lua

3. USEFUL LINKS

Reference: https://opencyphal.org/specification/Cyphal_Specification.pdf

4. KNOWN ISSUES

1. Insufficent memory loading

Try to disable some feature as it is recommended on the ardupilot forum.

For example, LOG_FILE_BUFSIZE = 8 can help.

2. Why Cyphal paramters are float?

Docs says all scripting defined parameters are of type FLOAT, ie floating point numbers.

cyphal_lua_ardupilot's People

Contributors

ponomarevda avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.