TO BE UPDATED. GUIDE MIGHT STILL WORK.
The key idea of this guide is to have a RPi running as a node in a ROS network. Of this network, the core shall be running in the VM, hence we also need to install ROS locally. Most of the steps of this guide are described at the ROS wiki
As ROS is installed via apt-get
, no additional packages need to be installed.
XCS~$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
XCS~$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
XCS~$ sudo apt-get update
XCS~$ sudo apt-get install ros-kinetic-desktop
XCS~$ rosdep update
No synchronisation is required.
Prerequisites:
Steps:
XCS~$ source ~/rpicross_notes/scripts/ros_native
helloros
code without the toolchain.
XCS~$ mkdir -p ~/build/hello/ros
XCS~$ cd ~/build/hello/ros
XCS~$ cmake ~/rpicross_notes/hello/ros/
XCS~$ make
roscore
in the first
XCS~$ source ~/rpicross_notes/scripts/ros_native
XCS~$ roscore
... logging to /home/pi/.ros/log/9c219342-0fc9-11e7-b1fd-08002741e196/roslaunch-XCS-rpizero-2600.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://XCS-rpizero:45758/
ros_comm version 1.12.7
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.7
NODES
auto-starting new master
process[master]: started with pid [2611]
ROS_MASTER_URI=http://XCS-rpizero:11311/
setting /run_id to 9c219342-0fc9-11e7-b1fd-08002741e196
process[rosout-1]: started with pid [2624]
started core service [/rosout]
helloros
in the second
XCS~$ source ~/rpicross_notes/scripts/ros_native
XCS~$ ~/build/hello/ros/devel/lib/helloros/helloros
[ INFO] [1490274566.925321564]: hello world 0
[ INFO] [1490274567.026256196]: hello world 1
[ INFO] [1490274567.125635032]: hello world 2
[ INFO] [1490274567.225916579]: hello world 3
[ INFO] [1490274567.325554161]: hello world 4
...
Code for this test is partially taken from http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B)