- Start
- Setup XCS and RPi
- Setup RPi Network and SSH
- Setup RPi Peripherals
- Setup Cross-compile environment
- Cross-compile and Install Userland
- Cross-compile and Install OpenCV
- > Cross-compile and Install ROS
- Compile and Install OpenCV
- Compile and Install ROS
- Remote ROS (RPi node and XCS master)
- ROS package development (RPi/XCS)
- Compile and Install WiringPi
TO BE UPDATED. GUIDE MIGHT STILL WORK.
Before continuing, please make sure you followed the steps in:
In this document the steps for crosscompiling ROS are described.
As ROS has its own package-management system and eco system, multiple dependencies need to be installed on both the RPi and the VM. The VM requires foremost Python packages to process ROS dependencies, whereas the RPi requires additional information-processing libraries.
-
Install packages
XCS~$ sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall python-empy XCS~$ ssh rpizero-local RPI~$ sudo apt-get install pkg-config python2.7 python-dev python-pip sbcl libboost-all-dev libtinyxml-dev libgtest-dev liblz4-dev libbz2-dev libyaml-dev python-nose python-empy python-netifaces python-defusedxml RPI~$ sudo pip install -U rospkg catkin_pkg
The call to
sudo apt-get install
on the RPi might take a while as approximately 250Mb extracted and installed. Installingrospkg
andcatkin_pkg
may produce several errors when buildingyaml
support while finishing gracefully. My guess is that all might be fine, but perhaps some future tests might show some issues. -
Sync RPi libs to VM
XCS~$ ~/rpicross_notes/scripts/sync-rpi-xcs.sh
As mentioned before, the use of rsync
results in broken symlinks. Hence we need to restore the ones required for ROS
:
-
Restore symlinks after syncing
When using the
sync
-scripts, this step can be omitted.XCS~$ ln -sf /home/pi/rpi/rootfs/lib/arm-linux-gnueabihf/librt.so.1 /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf/librt.so XCS~$ ln -sf /home/pi/rpi/rootfs/lib/arm-linux-gnueabihf/libbz2.so.1.0 /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libbz2.so XCS~$ ln -sf /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libpython2.7.so.1.0 /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf/libpython2.7.so
-
ROS
usesgtest
for several tests. Theapt-get
call forlibgtest-dev
only installs the source forgtest
, therefore we need to crosscompile it for ourselfs to generate the libraries, using rpi-generic-toolchain.XCS~$ mkdir -p ~/rpi/build/gtest XCS~$ cd ~/rpi/build/gtest XCS~$ cmake \ -D CMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake \ /home/pi/rpi/rootfs/usr/src/gtest XCS~$ make XCS~$ mv *.a /home/pi/rpi/rootfs/usr/lib
SOURCE: https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/ There is not
make install
so the generated libraries need to be copied manually to the appropriate folder. -
We also need an utility called
console_bridge
, which we compile and install from source too. Again we use rpi-generic-toolchain.XCS~$ cd ~/rpi/src XCS~$ git clone https://github.com/ros/console_bridge XCS~$ mkdir -p ~/rpi/build/console_bridge XCS~$ cd ~/rpi/build/console_bridge XCS~$ cmake \ -D CMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake \ /home/pi/rpi/src/console_bridge XCS~$ make XCS~$ make install DESTDIR=/home/pi/rpi/rootfs
-
After installing all dependencies, init
rosdep
.XCS~$ sudo rosdep init XCS~$ rosdep update
-
Create
catkin
workspace for the RPi-builds.Note that this workspace is not located in the
~/rpi
or~/rpi/rootfs
directories. Because ROS comes with its own environment management system, a seperate directory is created which is synced with the RPi in a similar way asrootfs
. Most important is that the path of the workspace in the VM equals (/home/pi/ros/src_cross
) the path to which the workspace is synchronised on the RPi (which will be/home/pi/ros/src_cross
).XCS~$ mkdir -p ~/ros/src_cross XCS~$ cd ~/ros/src_cross
-
Download
ROS
core packages and init workspaceXCS~$ rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall XCS~$ wstool init -j8 src kinetic-ros_comm-wet.rosinstall
-
Build
ROS
XCS~$ ./src/catkin/bin/catkin_make_isolated \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake
This creates two folders:
devel_isolated
andbuild_isolated
of which the latter can be ignored.
When additional ros-packages are needed, but ROS is already build, the following steps can be taken:
-
Goto the crosscompilation
catkin
-workspace:XCS~$ cd ~/ros/src_cross
-
Use
rosinstall_generator
to create an additional.rosinstall
, including the specified package(s). E.gsensor_msgs
:XCS~$ rosinstall_generator sensor_msgs --rosdistro kinetic --deps --wet-only --tar > sensor_msgs.rosinstall
-
Merge the file with the existing
.rosinstall
and update ROS it's source treeXCS~$ wstool merge -t src sensor_msgs.rosinstall XCS~$ wstool update -t src
-
Finally, rebuild
ROS
XCS~$ ./src/catkin/bin/catkin_make_isolated \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake
In addition to updates of rootfs
we also need to synchronise src_cross
.
Starting with rootfs
:
- Use a direct call:
XCS~$ sudo rsync -auHWv --no-perms --no-owner --no-group /home/pi/rpi/rootfs/ rpizero-local-root:/
- Or use the link-correcting script:
XCS~$ /home/pi/rpicross_notes/scripts/sync-xcs-rpi.sh
And for ~/ros/src_cross
:
-
Use a direct call:
XCS~$ rsync -auHWv --no-perms --no-owner --no-group /home/pi/ros/src_cross/devel_isolated rpizero-local:/ XCS~$ rsync -auHWv --no-perms --no-owner --no-group /home/pi/ros/src_cross/src rpizero-local:/
Which copies both
devel_isolated
andsrc
from/home/pi/ros/src_cross/*
(VM) to/home/pi/ros/src_cross/*
(RPi) -
Or use this script:
XCS~$ /home/pi/rpicross_notes/scripts/sync-ros.sh
-
Unfortunatly ROS includes the path to
rootfs
and subsequent libraries in its binairies. To enable ROS on the RPi to find the proper libraries, a symbolic link is created, simulating the path torootfs
XCS~$ ssh rpizero-local RPI~$ mkdir -p /home/pi/rpi RPI~$ ln -s / /home/pi/rpi/rootfs
Testing the compiled ROS
-libraries and catkin
workspace
Prerequisites:
Steps:
-
Set bash to use the crosscompile-ros settings
XCS~$ source ~/rpicross_notes/scripts/ros_cross
ROS biniaries such as
catkin_make
are actually python scripts. Therefore we can use several libraires/scripts from the crosscompiled workspace on both the RPi and VM. -
Cross-compile the
helloros
code with the toolchain in this repositiory.XCS~$ mkdir -p ~/rpi/build/hello/ros XCS~$ cd ~/rpi/build/hello/ros XCS~$ cmake \ -D CMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake \ ~/rpicross_notes/hello/ros/ XCS~$ make
Note that the toolchain sets the proper path for pkg-config (
/home/pi/ros/src_cross/devel_isolated
) to findXXXConfig.cmake
files for ROS. -
Transfer
helloros
to the RPi (located indevel/lib/helloros
)XCS~$ scp devel/lib/helloros/helloros rpizero-local:~/
-
Connect two terminals with the RPi
-
Launch
roscore
in the firstXCS~$ ssh rpizero-local RPI~$ source ~/ros/src_cross/devel_isolated/setup.bash RPI~$ roscore ... logging to /home/pi/.ros/log/9d57fc26-0efa-11e7-97cb-b827eb418803/roslaunch-rpizw-hessel.local-893.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://rpizw-hessel.local:42774/ ros_comm version 1.12.7 SUMMARY ======== PARAMETERS * /rosdistro: kinetic * /rosversion: 1.12.7 NODES auto-starting new master process[master]: started with pid [911] ROS_MASTER_URI=http://rpizw-hessel.local:11311/ setting /run_id to 9d57fc26-0efa-11e7-97cb-b827eb418803 process[rosout-1]: started with pid [924] started core service [/rosout]
-
Launch
helloros
in the secondXCS~$ ssh rpizero-local RPI~$ source ~/ros/src_cross/devel_isolated/setup.bash RPI~$ ./helloros [ INFO] [1490185604.127013218]: hello world 0 [ INFO] [1490185604.226970277]: hello world 1 [ INFO] [1490185604.326862336]: hello world 2 [ INFO] [1490185604.426858394]: hello world 3 ...
-
Code for this test is partially taken from http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B)