Main repository for the Duckietown ROS2 CPS project.
Follow the instructions here to prepare a fresh SD card for the DB21M/jetson nano with ROS2 Foxy installed.
cd ~
git clone --branch main https://github.com/nicholas-gs/duckietown_ros2_cps
mv duckietown_ros2_cps/duckietown ~/
# We don't need the cloned repo anymore
rm -r duckietown_ros2_cps/
# append to bashrc
cat ~/duckietown/append_bash >> ~/.bashrc
source ~/.bashrc
The files in ~/duckietown/config
are used to store configuration settings for duckietown. Make sure the settings are correct for your robot. After making changes, make sure to source the ~/.bashrc
file again to take effect.
We need the following dependencies to use the hardware on the jetson nano.
pip3 install wheel
sudo apt install -y \
i2c-tools \
v4l-utils \
jetson-gpio-common \
python3-jetson-gpio
# usb permissions
sudo usermod -aG dialout $USER
# i2c permissions
sudo usermod -aG i2c $USER
# gpio permissions
sudo groupadd -f -r gpio
sudo usermod -aG gpio $USER
# video permissions
sudo groupadd -f -r video
sudo usermod -aG video $USER
sudo udevadm control --reload-rules && sudo udevadm trigger
Gstreamer and Opencv should be installed by default. Just make sure that Opencv was compiled with gstreamer support using cv2.getBuildInformation()
.
The default cv2 version installed should be 4.1. If not, follow this guide for a work around.
A reddish/pink tint may be present when capturing using the IMX219 camera, which will interfere with color detection. Try the following to fix the issue.
# Taken from https://www.waveshare.com/wiki/IMX219-160_Camera
cd ~/
wget https://www.waveshare.com/w/upload/e/eb/Camera_overrides.tar.gz
tar zxvf Camera_overrides.tar.gz
sudo cp camera_overrides.isp /var/nvidia/nvcam/settings/
sudo chmod 664 /var/nvidia/nvcam/settings/camera_overrides.isp
sudo chown root:root /var/nvidia/nvcam/settings/camera_overrides.isp
mkdir -p ~/dt_ws/src
cd ~/dt_ws
wget https://raw.githubusercontent.com/nicholas-gs/duckietown_ros2_cps/main/main.repos
vcs import src < main.repos
Since the L4T image is based off Ubuntu 18.04 which is a not officially supported OS for Foxy, using rosdep
is likely to cause complications due to depedency chains.
# Example only, not recommended to run!
rosdep install --from-paths src --ignore-src --rosdistro foxy --os ubuntu:focal -y
So instead we install the dependencies manually.
pip3 install smbus \
smbus2 \
transforms3d \
dataclasses \
numpy \
pyserial \
semver
sudo apt update
# Install the Adafruit PiOLED monochrome OLED driver
cd ~/dt_ws/src/non-ros/installPiOLED
./installPiOLED.sh
cd ~/dt_ws
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
echo "source ~/dt_ws/install/setup.bash" >> ~/.bashrc
source ~/.bashrc
You can run packages and demos that don't require Duckietown hardware, such as the image processing packages. This assumes you already have ROS2 foxy installed on Ubuntu 20.04.
cd ~
git clone --branch main https://github.com/nicholas-gs/duckietown_ros2_cps
mv duckietown_ros2_cps/duckietown ~/
# We don't need the cloned repo anymore
rm -r duckietown_ros2_cps/
The files in ~/duckietown/config
are used to store configuration settings for duckietown. You should still make sure that the settings are the same for as if you are running the robot.
Make sure you have Gstreamer and Opencv installed and that Opencv was compiled with gstreamer support using cv2.getBuildInformation()
.
mkdir -p ~/dt_ws/src
cd ~/dt_ws
wget https://raw.githubusercontent.com/nicholas-gs/duckietown_ros2_cps/main/main.repos
vcs import src < main.repos
cd ~/dt_ws/src
rosdep install --from-paths src --ignore-src --rosdistro foxy --os ubuntu:focal -y
cd ~/dt_ws
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
echo "source ~/dt_ws/install/setup.bash" >> ~/.bashrc
source ~/.bashrc