4.6. Raspberry set up#
4.6.1. Install OS#
This project is using Ubuntu 20.04 as the base OS. Use the official ubuntu guide and follow step by step installation process. [1]
Note: Ubuntu Desktop 2020 is not available in the rpi-imager so Ubuntu Server 2020 is the one used. And the following command is needed to download the necessary package to configure the desktop version.
sudo apt update sudo apt install ubuntu-desktop
4.6.2. Set up ROS#
Follow the ROS installation guide [2] to install ROS noetic.
4.6.3. Install pigpio lib#
Install the pigpio library with the following commands [3].
apt install unzip
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install
sudo rm -rf master.zip pigpio-master
4.6.4. Get project#
This project is configured as a ROS package. Clone the repo inside your workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/cychitivav/pai
4.6.5. Build the ROS package#
cd ~/catkin_ws
catkin build
source devel/setup.bash
4.6.6. Run robot#
roslaunch pai run_robot.launch
rostopic pub -r 0.5 /front_right_wheel_ctrl/command std_msgs/Float64 "64.0"
rostopic pub -r 0.5 /cmd_vel geometry_msgs/Twist "linear:
x: 1.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.1"
For further configuration check out the Miscellaneous section.
4.6.7. Slow boot time#
At start up the systemd-networkd-wait-online.service waits for a network to be connected. Which makes the the start up time really long if no network is connected. You change the configuration of the service in order to reduce the wait time. Find the line that starts with ExecStart=[PATH]inside the systemd-networkd-wait-online.service and add the parameter --timeout=10
sudo systemctl disable NetworkManager-wait-online.service
sudo nano systemd-networkd-wait-online.service
# ExecStart=/lib/systemd/systemd-networkd-wait-online --timeout=10
4.6.8. Autostart pigpio deamon at boot#
If pigpio is installed from the source code, the deamon needs to be started manually, due to the fact that the installation process does not create a service. To start the deamon at boot, create a service configuration file in the following path /etc/systemd/system/pigpiod.service.d/public.conf and add the following lines.
[Service]
ExecStart=
ExecStart=/usr/local/bin/pigpiod
Then, create the service file /lib/systemd/system/pigpiod.service and add the following lines.
[Unit]
Description=Daemon required to control GPIO pins via pigpio
[Service]
ExecStart=/usr/local/bin/pigpiod
ExecStop=/bin/systemctl kill -s SIGKILL pigpiod
Type=forking
[Install]
WantedBy=multi-user.target
And finally, enable and start the service.
sudo systemctl deamon-reload
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
4.6.9. I²C setup#
In some cases the I²C bus is not enabled by default. To check if the I²C bus is enabled, run the following command.
ls /dev/i2c*
If the command does not return any result, the I²C bus is not enabled. To enable the I²C bus, run the following commands
Open the file
/etc/modulesand add the following lines at the end of the file.
i2c-dev
i2c-bcm2708
Open the file
/boot/config.txtand add the following lines at the end of the file.
dtparam=i2c_arm=on
dtparam=i2c1=on
Reboot the system.
Finally, check if the I²C bus is enabled by running the following command.
sudo i2cdetect -y 1
Note: Install the
i2c-toolspackage fromaptto use thei2cdetectcommand.
Miscellaneous configuration
ssh remote.
development environment (install vscode and list of vscode extensions).
add raspbian apt archive.
configure vnc server.