This repository has been archived by the owner on Aug 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
DDSAccel demo (Vector3 ROS type Desktop Embedded)
vmayoral edited this page Dec 1, 2014
·
2 revisions
The following example shows how to use ROS 2 between Embedded and Desktop using the Vector3 ROS type. This type is used to send linear acceleration values fetched from a sensor in the embedded board (publisher) to the Desktop machine (subscriber).
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/imu_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 it starts publishing messages:
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 512, acc_z: 62208
IMU accel message: x=, y= and z=
acc_x: 48384, acc_y: 512, acc_z: 62464
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 512, acc_z: 62208
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 768, acc_z: 62464
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 512, acc_z: 61952
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 512, acc_z: 62464
IMU accel message: x=, y= and z=
acc_x: 48640, acc_y: 512, acc_z: 62208
IMU accel message: x=, y= and z=
acc_x: 48384, acc_y: 768, acc_z: 62464
IMU accel message: x=, y= and z=
acc_x: 48896, acc_y: 768, acc_z: 62208
...
run ./imu_subscriber_double__ros_middleware_opensplice_cpp
Get the code, compile and run it:
cd ~/
git clone https://github.com/ros2/ros2_embedded_nuttx
cd ros2_embedded_nuttx/dds/apps/imu_subscriber
make
./subscriber
Still not working. Refer to https://github.com/ros2/ros2_embedded_nuttx/issues/26.