Skip to content
This repository has been archived by the owner. It is now read-only.

ROSIMU demo (Imu ROS msg type, lis302dlh accel)

vmayoral edited this page Dec 11, 2014 · 2 revisions

Summary of the demo:

  • Embedded board publishing Imu messages that contain accelerometer values.
  • Rate of publishing: ~ 3 Hz.

Description

The following example shows how to use ROS 2 between Embedded and Desktop using the Imu ROS type. The embedded board (publisher) running ROS 2 embedded fetches accelerometer values from an LIS302DLH sensor and sends the data using Imu message types to the Desktop machine (subscriber).

Set up the embedded board

Clone the code, select the right configuration and compile the code:

cd ~/
git clone https://github.com/ros2/ros2_embedded_nuttx
cd ros2_embedded_nuttx/nuttx
cd tools
./configure.sh stm3240g-eval/rosimu_publisher #configure the board
cd ..
make

The output should look like:

CC:  up_selectlcd.c
CC:  up_deselectlcd.c
CC:  up_selectsram.c
CC:  up_deselectsram.c
CC:  up_extmem.c
AR:   up_boot.o up_spi.o up_autoleds.o up_lcd.o up_selectlcd.o up_deselectlcd.o up_selectsram.o up_deselectsram.o up_extmem.o
make[2]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/configs/stm3240g-eval/src'
LD: nuttx
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.8.2/armv7e-m/libgcc.a(bpabi.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.8.2/armv7e-m/libgcc.a(_divdi3.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
arm-none-eabi-ld: warning: /usr/lib/gcc/arm-none-eabi/4.8.2/armv7e-m/libgcc.a(_udivdi3.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/arm/src'
CP: nuttx.hex
CP: nuttx.bin

then program the board:

make program

the output:

victor@frcsim:~/Dropbox/OSRF/ros2_embedded_nuttx/nuttx$ make program
../tools/openocd/bin/openocd -f board/stm32f4discovery.cfg -c "init" -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000 bin" -c "verify_image nuttx.bin 0x8000000; reset run; exit"
Open On-Chip Debugger 0.9.0-dev-00112-g1fa24eb (2014-08-19-11:23)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 1000 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.231621
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080004b0 msp: 0x2000cdf0
auto erase enabled
Info : device id = 0x10016413
Info : flash size = 1024kbytes
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000042 msp: 0x2000cdf0
wrote 655360 bytes from file nuttx.bin in 23.783436s (26.909 KiB/s)
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000002e msp: 0x2000cdf0
verified 632572 bytes in 5.433960s (113.682 KiB/s)
make: [program] Error 1 (ignored)

You'll see in the serial console of the embedded board that after loading the DDS code, it starts publishing messages:

ABCDF
mm_initialize: Heap: start=2000ce04 size=78332
mm_addregion: Region 1: base=2000ce04 size=78320
mm_addregion: Region 2: base=64000000 size=2097152
Network configured, starting DDS chat:
List pools created.
String pool initialized.
Typecode pools created.
Typesupport initialized.
Socket handler initialized.
Timer pool initialized.
Data buffer pools created.
Random host identifier generated.
Unique GUID prefix created: ff3a34d9:00000002:00060000
Locator pools created.
History cache pools created.
Entities: reserved=98, maximum=4294967295
Domain pools created.
RTPS Initialised.
IP: scope = link..global
IP interfaces:
    eth0     : 192.168.0.3
RTPS over IPv4 Initialised.
QoS pools initialized.
DDS: core thread running.
DDS: core thread created.
DDS: DynamicType_register(ParticipantMessageData): 5 blocks, 264 bytes
Discovery initialized.
DCPS Initialised.
UDP: adding 192.168.0.3:7589 on [9]
UDP: adding 239.255.0.1:7401 on [10]
UDP: setsockopt (SO_REUSEADDR) 239.255.0.1:7401
UDP: ipmsfilter join group 239.255.0.1
RTPS: starting Discovery protocols.
UDP: adding 192.168.0.3:7588 on [11]
UDP: adding 239.255.0.1:7400 on [12]
UDP: setsockopt (SO_REUSEADDR) 239.255.0.1:7400
UDP: ipmsfilter join group 239.255.0.1
SPDP: registering Participant key.
SPDP: Send Participant data.
DDS: DynamicTypeSupport_create_type_support(Imu): 1 blocks, 52 bytes
I2C Successfully initialized
***********************************
REGISTERS:
***********************************
LIS302_CTRL_REG1 (0x20) register = 0x7f (127)
LIS302_CTRL_REG2 (0x21) register = 0x00 (0)
LIS302_CTRL_REG3 (0x22) register = 0x00 (0)
LIS302_CTRL_REG4 (0x23) register = 0x80 (128)
LIS302_CTRL_REG5 (0x24) register = 0x00 (0)
LIS302_OUT_X_L (0x28) register = 0x00 (0)
LIS302_OUT_X_H (0x29) register = 0xbf (191)
***********************************
elapsed: 3660 miliseconds to send 10 readings
SPDP: Connecting builtin endpoints.
SPDP: Connecting builtin endpoints.
elapsed: 3698 miliseconds to send 10 readings
elapsed: 3598 miliseconds to send 10 readings
elapsed: 3544 miliseconds to send 10 readings
elapsed: 3647 miliseconds to send 10 readings
elapsed: 3142 miliseconds to send 10 readings
elapsed: 3435 miliseconds to send 10 readings
elapsed: 3320 miliseconds to send 10 readings
elapsed: 3207 miliseconds to send 10 readings
elapsed: 3428 miliseconds to send 10 readings
elapsed: 3437 miliseconds to send 10 readings
elapsed: 3073 miliseconds to send 10 readings
...

Desktop side

OpenSplice

run ./rosimu_subscriber, after discovery between the two endpoints (embedded and Desktop), you'll see:

-------------------------
Got Imu msg
-------------------------
msg->linear_acceleration.x= -11.6424
msg->linear_acceleration.y= 0
msg->linear_acceleration.z= -1.5876
-------------------------
-------------------------
Got Imu msg
-------------------------
msg->linear_acceleration.x= -11.6424
msg->linear_acceleration.y= 0.3528
msg->linear_acceleration.z= -1.764
-------------------------
-------------------------
Got Imu msg
-------------------------
msg->linear_acceleration.x= -11.8188
msg->linear_acceleration.y= 0.1764
msg->linear_acceleration.z= -1.764
-------------------------
...

Connext

Still not working. Refer to https://github.com/ros2/ros2_embedded_nuttx/issues/26.

You can’t perform that action at this time.