- 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.
When all previous steps are followed the setup should currently be able to:
- (cross) compile aribtrary c(++)-code
- (cross) compile OpenCV code
- (cross) compile ROS code
- Run the native-compiled code in the VM
- Run the cross-compiled code on the RPi
- Update and synchronise the RPi
- Call OpenCV and ROS functions from Python
- Start/Stop ROS-nodes on both the VM and RPi
The next step is to setup extend the communication functions between the RPi and VM, such that we can run roscore
in the VM and connect a node from the RPi.
ROS nodes connect to a master (roscore
) via a tcp-connection. This allows a ROS system to have external nodes, hence we should be able to connect the RPi to our VM.
Unfortunally there is a challenge: the VM is configured to be attached to the NAT, therefore it is not visible by any device in the network except the HOST~$
. As a result, the RPi is cannot detect the VM and hence cannot connect to the ROS-master (roscore
) running in the VM.
The nodes in a ROS system connect to an IP address by communicating with a specific port (by default 11311). When the calls to this port on the HOST~$
are forwarded to our VM and the ROS-master is set to the ip-address of the HOST~$
we can circumvent this problem and have external nodes communicating with the RPi. The setup then becomes:
HOST
has an IP namedHOST_IP
HOST
forwards port 2222 to 22 in the VM (see Installation)HOST
forwards port 11311 to 11311 in the VMVM
has a (local) IP namedVM_IP
. This IP is only accessible by theHOST
VM
runs SSH at port 22VM
runsroscore
at port11311
.VM
runs internal a ROS-node calledsubscriber
which connects toHOST_IP
:11311 (and thereforeroscore
)VM
communicated with thenatdnsresolver
of the host in order to resolve dns-names such asrpizw-hessel.local
.RPi
has an IP namedRPi_IP
RPi
runs SSH at port 22RPi
runs internal a ROS-node calledpublisher
which connects toHOST_IP
:11311 (and thereforeroscore
)HOST
andRPi
are connected to the same network and are able to connect to each other.
In a similar manner as the SSH-setting (see Installation), a forward rule in VirtualBox needs to be set. After selecting the VM in VirtualBox:
- Machine > Settings > Network > Advanced > Port Forwarding > New Rule
- Name: ROS_MASTER
- Protocol: TCP
- Host IP: (leave empty)
- Host Port: 11311
- Guest IP: (leave empty)
- Guest Port: 11311
-
Compile for VM
XCS~$ source ~/rpicross_notes/scripts/ros-native XCS~$ mkdir -p ~/build/ros/chatter XCS~$ cd ~/build/ros/chatter XCS~$ cmake ~/rpicross_notes/ros/chatter XCS~$ make
-
Compile for RPi
XCS~$ source ~/rpicross_notes/scripts/ros-cross XCS~$ mkdir -p ~/ros/chatter_cross XCS~$ cd ~/ros/chatter_cross XCS~$ cmake \ -DCMAKE_TOOLCHAIN_FILE=/home/pi/rpicross_notes/rpi-generic-toolchain.cmake \ ~/rpicross_notes/ros/chatter XCS~$ make XCS~$ ~/rpicross_notes/scripts/sync-ros.sh
-
First we need to determine the (external) IP (or hostname) of the
HOST~$
on which the VM is active. This is the IP on which the ROS-master will be reachable. When using an unix system, the hostname can be determined by:HOST~$ hostname Hessels-MacBook-Pro.local
While the IP of the host can also be used, in different networks different IPs might be active. Using the hostname of the
HOST~$
eliminates this potential issue. -
Open three terminals in the VM:
-
Source ROS-files and start
roscore
XCS~$ source ~/rpicross_notes/scripts/ros-native <hostname> <rpiname> XCS~$ roscore
The values
<hostname>
and<rpiname>
need to be set in order for the RPi to connect properly to the VM via the HOST. This scripts fetches the IP of<hostname>
, updatesROS_MASTER_URI
locally, sends the update via~/ros/rossetup-rpi
to<rpiname>
and finally sources ROS files on the VM. For my setup the full command is:XCS~$ source ~/rpicross_notes/scripts/ros-native Hessels-MacBook-Pro.local rpizero-local
Note that
roscore
complains about the IP ofROS_MASTER_URI
as it differs from the IP of the VM. More about this in issue #7 . -
After starting ROS, start the subscriber-node
XCS~$ source ~/rpicross_notes/scripts/ros-native <hostname> XCS~$ rosrun chatter subscriber
Note that we do not need to update the RPi anymore.
-
Start publisher on rpi
XCS~$ ssh rpizero-local RPI~$ source ~/ros/rossetup-rpi RPI~$ rosrun chatter publisher
The contents of
~/ros/rossetup-rpi
are created by copying and adapting~/rpicross_notes/ros/rossetup-rpi
in the VM.
-
-
When succesfull, you should see:
- Publisher (RPi):
RPI~$ rosrun chatter publisher [ INFO] [1490361500.794854734]: hello world 0 [ INFO] [1490361500.894476970]: hello world 1 [ INFO] [1490361500.994248202]: hello world 2 [ INFO] [1490361501.094246431]: hello world 3 [ INFO] [1490361501.194246659]: hello world 4 [ INFO] [1490361501.294338885]: hello world 5 [ INFO] [1490361501.394404112]: hello world 6 [ INFO] [1490361501.494347342]: hello world 7 [ INFO] [1490361501.594348570]: hello world 8 ...
- Subscriber (VM):
XCS~$ rosrun chatter subscriber [ INFO] [1490361501.387607575]: I heard: [hello world 5] [ INFO] [1490361501.486619994]: I heard: [hello world 6] [ INFO] [1490361501.588621491]: I heard: [hello world 7] [ INFO] [1490361501.688693481]: I heard: [hello world 8] ...
Note that some packages are lost..
- Publisher (RPi):
It can become quite tedious to constantly source
the ros-files. Luckily we can do this by adding the source
command to ~/.bashrc
. Upon a ssh-call, ~/.bashrc
is loaded by the unix OS, hence the ROS binairies will be sourced automatically.
-
Add source-command to
~/.bashrc
in the VMXCS~$ nano ~/.bashrc
Add the following to the bottom of the file
# Load ROS biniaries and setup ROS_MASTER_URI source ~/rpicross_notes/scripts/ros-native Hessels-MacBook-Pro.local
-
Add source-command to
~/.bashrc
on the RPiXCS~$ ssh rpizero-local RPI~$ nano ~/.bashrc
Add the following to the bottom of the file
# Load ROS biniaries source ~/ros/rossetup-rpi
So, the steps to execute the example become:
- Open three terminals in the VM:
-
Start ros
XCS~$ roscore
If
ROS_MASTER_URI
has changed, or the RPi has not yet been configured, an initial call beforeroscore
is required:XCS~$ source ~/rpicross_notes/scripts/ros-native Hessels-MacBook-Pro.local rpizero-local XCS~$ roscore
-
Start subscriber in the second terminal
XCS~$ rosrun chatter subscriber
-
Start publisher on RPi
XCS~$ ssh rpizero-local RPI~$ rosrun chatter publisher
-