Operate APA102 LED Board via ROS2 on NavQPlus over UCANS32K1 Board
Objective: publish messages from ROS2, subscribe on UCANS32K1 and drive the APA102 LED Board connected to UCANS32K1.
Introduction
This tutorial explains how to operate APA102 LED Board via NavQPlus with ROS2 over UCANS32K1 Board. NavQPlus and UCANS32K1 boards will communicate via CAN-FD. UCANS32K1 and APA102 boards will communicate via SPI.
Items Needed
NavQPlus Board
USB-UART serial debugger cable
2 CAN Termination Resistor network
CAN connector cable
Micro SD Card
An APA102 based RGB LED board
UCANS32K146 or UCANS32K1SIC
Jumper wires
STEMMA QT / Qwiic JST SH 4-pin Cable
Segger J-Link debugger or similar debugger
Hardware Procedure
APA102 LED Board
Note: we will be using three 3-LED APA102 Boards in this tutorial, each containing three RGB LEDs. The boards will be connected in daisy-chain network.
NavQPlus Board
UCANS32K1 Board
Software Procedure
UCANS32K1
Software Setup
Enable 'apa102 led' driver and 'apa102 led' example in the menu. Note: You may search for their location in the menu by typing / followed by the name of the option. Ex: "/apa102" + enter.
Change the value of 'NUM_LEDS' macro in 'examples/apa102/apa102_main.c' to 3.
Building PX4
Note: if you get error in the following line: snerr("ERROR: Each LED uses 4 bytes, so (buflen % 4)", apply the following patch in the 'platforms/nuttx/NuttX/nuttx' sub-directory.
Flashing PX4
Note: You may flash the attached file (configured for a 3-LED APA102 board), to skip the above steps.
NavQPlus
NavQPlus WIC Image Clone & Setup
Clone and extract 'navqplus-image-22.04-230127.wic.bz2' from here.
Flash the WIC image on the SD Card, using HxD.
Set the boot switches on the NavQPlus Board to 'sdcard mode' (i.e. both switches should be on), then reset the board (by turning it off and on).
Credentials:
username: user.
password: user.
Receive heartbeat from UCANS32K1
Note: you may see the output using the 'ifconfig' command.
ROS2 Setup
Note: if you get 'server certificate verification failed', you may run 'git config --global http.sslverify false' to turn off this check, or add the necessary certificate to the trust store of your operating system. Please note that the former method is only for testing purposes.
Replace the config.json file in ros2_orchestrator with the config.json attached below.
Set the 'max_leds' parameter in config.json equal to the number of LEDs in your APA102 board.
Note: if you get 'clock skew' warning, running 'find . -type f | xargs -n 5 touch' should resolve it. Otherwise reset the system clock.
Note: you may be prompted after successful execution to run further commands.
ROS2 launcher may block the shell so you may need to open another shell via ssh on the ethernet ip to run your tests.
If you get 'could not read from remote repository', replace 'git@' with 'https://' in clone links in config.json. also, replace ':' with '/'. ex: 'git@github.com:rudislabs/opencyphal_led.git' would become 'https://github.com/rudislabs/opencyphal_led.git'.
If you get error related to usb0/mlan0 (which happens when these devices are not connected), comment out their tags in the '~/CycloneDDSConfig.xml' file.
Demonstration
Commands for publishing colors according to the number of leds in our setup: (Ex: we ran the command for 9-leds because we are using three 3-LED APA102 boards cascaded together.)
3-leds: ros2 topic pub /led_image sensor_msgs/msg/Image "{height: 1, width: 3, encoding: "rgb8", step: 9, data: [61,255,0, 255,255,61, 255,61,127]}".
6-leds: ros2 topic pub /led_image sensor_msgs/msg/Image "{height: 1, width: 6, encoding: "rgb8", step: 18, data: [0,0,255, 0,255,0, 255,0,0, 127,127,0, 127,0,127, 0,127,127]}".
9-leds: ros2 topic pub /led_image sensor_msgs/msg/Image "{height: 1, width: 9, encoding: "rgb8", step: 27, data: [0,0,255, 0,255,0, 255,0,0, 127,127,0, 127,0,127, 0,127,127, 61,255,31, 255,31,61, 61,31,255]}".
12-leds: ros2 topic pub /led_image sensor_msgs/msg/Image "{height: 1, width: 12, encoding: "rgb8", step: 36, data: [0,0,255, 0,255,0, 255,0,0, 128,128,0, 128,0,128, 0,128,128, 0,0,255, 0,255,0, 255,0,0, 128,128,0, 128,0,128, 0,128,128]}".
Last updated