Last active
November 7, 2022 14:24
-
-
Save alexswerner/cdc9b9185cd2da0eefc2c404ce405f0f to your computer and use it in GitHub Desktop.
Turtlebot4 Network setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Modifications to turtlebot4 image version 1.0.2 | |
## Disable Base Wi-Fi | |
* Factory-Reset the base (`curl 'http://192.168.186.2/api/factory-reset' -X 'POST' `) | |
If you don't do this and the robot disconnects from Wi-Fi, it will restart the ROS2 | |
services and those will become unavailble even over the USB interface. | |
## Configure to FASTDDS | |
* Set base to use FastDDS in web interface for a specific ROS_DOMAIN_ID e.g. 1 | |
* Set raspberry pi to use FastDDS for a specific ROS_DOMAIN_ID | |
Install fastdds | |
``` | |
sudo apt install -y ros-galactic-rmw-fastrtps-cpp | |
``` | |
Modify `usr/local/bin/install.py` to | |
``` | |
turtlebot4_job = robot_upstart.Job(name='turtlebot4', | |
rmw='rmw_fastrtps_cpp', | |
rmw_config='/etc/fastdds_rpi.xml', | |
workspace_setup=workspace_setup, | |
ros_domain_id=domain_id) | |
``` | |
Add a file /etc/fastdds_rpi.xml: | |
``` | |
<?xml version="1.0" encoding="UTF-8" ?> | |
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles"> | |
<transport_descriptors> | |
<transport_descriptor> | |
<transport_id>CustomUdpTransport</transport_id> | |
<type>UDPv4</type> | |
<interfaceWhiteList> | |
<address>192.168.186.3</address> | |
</interfaceWhiteList> | |
</transport_descriptor> | |
</transport_descriptors> | |
<participant profile_name="participant" is_default_profile="true"> | |
<rtps> | |
<userTransports> | |
<transport_id>CustomUdpTransport</transport_id> | |
</userTransports> | |
<useBuiltinTransports>false</useBuiltinTransports> | |
</rtps> | |
</participant> | |
</profiles> | |
``` | |
Add a file `/home/ubuntu/.rosenv` with the contents: | |
``` | |
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp | |
export FASTRTPS_DEFAULT_PROFILES_FILE=/etc/fastdds_rpi.xml | |
source /opt/ros/galactic/setup.bash | |
export ROS_DOMAIN_ID=${ROS_DOMAIN_ID} | |
``` | |
Source this file in .bashrc of the user `ubuntu` | |
``` | |
echo "source ~/.rosenv" >> .bashrc | |
``` | |
Install the turtlebot4 services via start via systemd with new parameters: | |
``` | |
install.py standard ${ROS_DOMAIN_ID} | |
``` | |
Reboot the robot, ros2 topic from base and rpi should work (e.g. `ros2 topic echo /odom` and `ros2 topic echo /scan`). | |
## VPN setup | |
This can be done with any Layer2 VPN. We found that openvpn causes substantial | |
CPU load even with encryption turned off. This is only an issue when streaming | |
high bandwidth data (e.g. camera data). Hence we went for a gretap VPN. This is | |
started with (ran the client): | |
``` | |
ssh ubuntu@${REMOTE_IP} "sudo ip link del gretap1 2> /dev/null; sudo modprobe fou; sudo ip fou add port 52323 gue; sudo ip link add name gretap1 type gretap local ${REMOTE_IP} remote ${LOCAL_IP} ignore-df nopmtudisc encap gue encap-sport auto encap-dport 52323 && sudo ip add add 192.168.186.11/24 dev gretap1 && sudo ip link set gretap1 mtu 1500 && sudo ip link set gretap1 master bridge && sudo ip link set gretap1 promisc on&& sudo ip link set up gretap1 && echo Remote ready" | |
``` | |
where `$REMOTE_IP` is the IP of the rpi on the Wi-Fi (read from the display), and `$LOCAL_IP` is the IP of the client | |
computer on this Wi-Fi. | |
On the client the connection can be established with | |
``` | |
sudo ip link del gretap1 2> /dev/null || /bin/true | |
sudo modprobe fou | |
sudo ip fou del port 52323 gue 2> /dev/null || /bin/true | |
sudo ip fou add port 52323 gue | |
sudo ip link add name gretap1 type gretap local ${LOCAL_IP} remote ${REMOTE_IP} ignore-df nopmtudisc encap gue encap-sport auto encap-dport 52323 | |
sudo ip link set gretap1 mtu 1500 | |
sudo ip addr add 192.168.186.10/24 dev gretap1 | |
sudo ip link set up gretap1 | |
``` | |
Through this tunnel you can ping the rpi at 192.168.186.3 and the base at | |
192.168.186.2 if things work correctly. | |
After this `ros2 topic list` should work. If not, first restart the ros2 | |
daemon with `ros2 daemon stop` and try again. | |
## Optional things | |
Avoid lengthy UDP connection stalls because packages got lost on Wi-Fi. Should also be set on the client | |
``` | |
sudo sysctl net.ipv4.ipfrag_time=3 | |
sudo sysctl net.ipv4.ipfrag_high_thresh=134217728 | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment