-
Notifications
You must be signed in to change notification settings - Fork 34
Tinq embedded, Tinq Desktop chat example using ChatMsg.
The following example shows how to set up an STM3240G-eval embedded board to use ROS 2 Embedded and publish/subscribe to a ChatMsg topic which will be used to interoperate with the same code running in a Desktop machine
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/dds #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)
Note that you won't see any package until there's at least one endpoint listening to the same topic
Get the code, compile and run it:
cd ~/
git clone https://github.com/ros2/tinq-core
cd tinq-core/dds/apps/chat
make
./chat0
Now you should be able to see the messages from one side (e.g. embedded) being sent to the other one (e.g. Desktop) and viceversa:
victor@frcsim:~/Dropbox/OSRF/tinq-core/dds/apps/chat$ ./chat0
Welcome to the Technicolor chatroom.
Anything you type will be sent to all chatroom attendees.
Type '!help' for chatroom options.
.pid.16545:
hola
hola
.pid.16545: hola
amigo
amigo
.pid.16545: amigo
.pid.2:
.pid.2:
.pid.2: que tal
.pid.2:
Instead of using the tinq-core code you can also use ros2_embedded_nuttx for Desktop purposes. The instructions needed would be:
cd ros2_embedded_nuttx/dds/apps/chat
make clean # important to clean the object files generated previously with the cross-compiler
make
Then launch chat0
. It should equally interoperate.