I will be experimenting with the newest ROS2 at the time of this writing; Humble Hawksbill. Image a raspberry PI 4 2Gb with 64-bit rasbian OS on a 32Gb microSD. I am using putty to ssh into the pi and VNCviewer to interface with GUIs.
Learn docker to install ROS2 on the RPI4
This is my first time using docker. After cloning the docker images repo, I went with the humble ros-base image.
The following are some useful docker commands:
- docker ps
- docker images
- docker container start [CONTAINER-ID]
- docker exec -ti [CONTAINER-ID] /bin/bash
- docker container list -f "status=exited"
- docker commit os_name image_name:version
- docker container update --help (this might have saved me some time and disk space. I was committing so that I could rerun with new parameters)
- docker rm container_id_or_name
- The config file is a json file at the location ‘ /var/lib/docker/containers/[container-id]/config.v2.json
- $ sudo docker rename [container#] ROS-TEST
Set the timezone in a container
- sudo rm -rf /etc/localtime
- sudo ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
- date
Moving on to the ROS2: Humble Hawksbill tutorials.
The environment set up without problems.
- source /opt/ros/humble/setup.bash
- echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
- printenv | grep -i ROS
- export ROS_DOMAIN_ID=24
- echo "export ROS_DOMAIN_ID=24" >> ~/.bashrc
The turtlebot tutorial took a while to download and setup. When running the turtlebot simulator an error occurred:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
The sim uses qt and qt can't find a display. Is this a problem with docker, vnc, or a combo of both?
Make an image of the current container to run with environmental variables set:
- --env="Display"
- --net=host
- FIX: in RPI terminal "xhost +local:docker". This needs to be done every reboot that you wish to use a GUI. It can also be run while a container is running
"exit" docker. The container is no longer running. "docker container start ROS-TEST", the container is running in the background.
Turtlesim GUI still launches with errors:
libGL error: MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to retrieve device information
libGL error: failed to create dri screen
libGL error: failed to load driver: vc4
libGL error: failed to open /dev/dri/card1: No such file or directory
libGL error: failed to load driver: vc4
qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 191, resource id: 0, major code: 140 (Unknown), minor code: 20
However, teleop keys work for the movement. I'll look into the errors above if I run into problems.
- --volume="$HOME/.Xauthority:/root/.Xauthority:rw"
^ Adding this didn't get rid of the errors. I'm not even sure if that is how to share the RPI's xserver as a volume to the docker container though...
Moving on... rqt install is 1198MB.
Everything works to finish the CLI tutorials.
The following error came up in Tutorials \Beginner: Client libraries \Using colcon to build packages.
CMake Error at CMakeLists.txt:14 (find_package): By not providing "Findexample_interfaces.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "example_interfaces", but CMake did not find one.
This is caused by a missing install and remedied by:
- sudo apt install ros-humble-example-interfaces
The RPI does not like "colcon build --symlink-install" very much. It went unresponsive for 1h 6m. Plus...more errors. I forgot to start from a clear directory though... When I re ran the build, it maxed out my ram and swap file, interrupting my VNC connection, and became generally unresponsive. 12 hours in, it was still unresponsive. I power cycled the RPI and got back into the container to try again. rm -r the ros2_ws directory and started over... It looks like it is going to have the same problem. Next attempt is to increase the RPI swap file from 100M to 1000M and reduce the amount of RAM the container has access to, it is currently unlimited.
- sudo dphys-swapfile swapoff
- sudo nano /etc/dphys-swapfile
- CONF_SWAPSIZE=100
- CONF_SWAPSIZE=2048 (Increased to 6144 later)
- sudo dphys-swapfile setup
- sudo dphys-swapfile swapon
- sudo reboot
- sudo cp /boot/cmdline.txt /boot/cmdline.txt.bak
- sudo nano /boot/cmdline.txt
- add "cgroup_enable=memory cgroup_memory=1 swapaccount=1" to the end of the line, not on a new line.
- verify with "docker info"
- docker run -it --name guiROSlimited --memory="1g" --memory-swap="2.5g" --cpus="3" --env="DISPLAY" --net=host [IMAGE NAME]
- want /var/swap=6144MByte, restricting to config limit: 2048MBytes, checking existing: keeping it
- uncomment CONF_MAXSWAP=2048 and change to CONF_MAXSWAP=6144
- docker run -it --name rosFresh1 --memory="1.25g" --memory-swap="4.5g" --cpus="3" --env="DISPLAY" --net=host ros_docker
- sudo apt update
- sudo apt upgrade
- --executor sequential
- --parallel-workers NUMBER
- This is only necessary when building multiple packages. It is not necessary yet when using --packages-select
- rm -rf build/ install/ log/
- colcon build --executor sequential
No comments:
Post a Comment