Raspberry and ROS: Difference between revisions

From Rsewiki
Line 64: Line 64:


Install subversion and other tools
Install subversion and other tools
Note: if you are on DTU network, then the date on the Raspberry will most likely not be set correct, and that may give problems for updating the operating system. If so you may need to install NTP and NTPDATE first and then configure /etc/ntpconf as described below.


  ntp              # time setup
  ntp              # time setup

Revision as of 14:07, 18 January 2023

Back to Robobot

Installation from blank SD-flash

Install Raspberry

Use Raspberry pi imager (download from https://www.raspberrypi.com/software/)

rpi-imager

First configure settings: click the gear icon, and set:

  • enable ssh, hostname, English language, Danish keyboard, possibly SSID, time zone, username (local) and password (remember to spell the password correctly).

then

Select operating system 'Raspberry Pi OS lite' and storage, an empty SD-flash of at least 16GB, then write.

When finished, mount the SD into the Raspberry

Start Raspberry

If everything is configured as above, then you just need to figure out the IP.

else

You need a screen and keyboard. Connect to the network to get an IP and for updating and date/time.

Find your IP address using:

sudo apt install net-tools nmap
ifconfig

Or from another computer on the same local net (if your local net is 192.168.2.XX)

nmap -sP 192.168.2.0/24

Wifi connect

The Raspberry uses the configuration in

cd /etc/wpa_supplicant
sudo nano wpa_supplicant.conf

@todo how to setup - copy from old installguide?

SSH from another computer

If the Raspberry has an IP of 192.168.2.39, then:

ssh local@192.168.2.39

or

ssh -X local@192.168.2.39

If your computer support X-graphics, e.g. has X-ming installed

Putty or other tools could be used too.

Install tools

Install subversion and other tools

Note: if you are on DTU network, then the date on the Raspberry will most likely not be set correct, and that may give problems for updating the operating system. If so you may need to install NTP and NTPDATE first and then configure /etc/ntpconf as described below.

ntp               # time setup
ntpdate           # time setup from DTU net
libreadline-dev   # command line memory
libopencv-dev     # openCV
python3-pyqtgraph # fancy graphs in Python
python3-scipy     # scientific functions 
pyqt5-dev         # QT designed GUI
pyqt5-dev-tools   # design QT GUI
festival          # text to sound
sox               # sound format read/write
libsox-fmt-all    # formats for SOX
v4l-utils         # video utilities
apt-file          # for finding missing system files (optional)
qv4l2             # for testing camera (optional)
kate              # graphical editor (optional - nano is faster)
xinit             # to run server (graphical user interface)
cmake             # to build apps
pip               # Python package install
sudo apt update
sudo apt dist-upgrade
sudo apt install ntp ntpdate libreadline-dev subversion libopencv-dev python3-pyqtgraph python3-scipy pyqt5-dev pyqt5-dev-tools festival sox libsox-fmt-all apt-file kate qv4l2 v4l-utils xinit cmake pip

NTP when on DTU net

Network time protocol (NTP), to keep clocks in sync. At DTU most clock sources are blocked, the clock source needs to be configured.

At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to the NTP server pool, like:

...
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool ntp.ait.dtu.dk
pool 0.ubuntu.pool.ntp.org iburst
...

This should ensure a proper date on a DTU net and when the internet is available elsewhere.

Sync time (if on DTU net)

sudo ntpdate -u ntp.ait.dtu.dk
date

Install ROS base

I will use Noetic (if it is ethical to do so).

Follow the instructions at http://wiki.ros.org/noetic/Installation/Ubuntu but it may fail with "The repository 'http://packages.ros.org/ros/ubuntu jammy Release' does not have a Release file."

The repository adds a file /etc/apt/sources.list.d/ros-latest.list. Modify the line in the file to be

deb [trusted=yes] http://packages.ros.org/ros/ubuntu jammy main

and then redo the

sudo apt update

Install ros-desktop-full-dev or ros-desktop-full and a bit more to use a Catkin workspace:

sudo apt install ros-desktop-full
sudo apt install python3-rosinstall
sudo apt install libmap-msgs-dev

Robobot from SVN

Install the needed Regbot and Fejemis packages. Fejemis is for the bridge, which also is a ROS bridge. Regbot is for the firmware, and the user interface used for the sensor calibration.

We will install these packages in an 'svn' directory, and make an easy link to the relevant parts.

mkdir cvn
cd svn
svn checkout svn://repos.gbar.dtu.dk/jcan/fejemis
svn checkout svn://repos.gbar.dtu.dk/jcan/regbot

and then the links

cd
ln -s svn/regbot/regbot_gui
ln -s svn/fejemis/ROS/catkin_ws

Initialize the ROS environment

Initialize sets up the needed environment variables and makes a script for remaining settings for this project.

cd ~/catkin_ws
rosws init . /usr/share

This outputs a message about the location of the ROS setup script:

rosinstall update complete.
Type 'source /home/local/svn/fejemis/ROS/catkin_ws/setup.bash' to change into this environment. 
Add that source command to the bottom of your ~/.bashrc to set it up every time you log in.

Put this script into ~/.bashrc, e.g. by

echo "source /home/local/svn/fejemis/ROS/catkin_ws/setup.bash" >> ~/.bashrc

Run catkin_make in the catkin_ws directory

cd ~/catkin_ws
catkin_make

Autostart ROSCORE and bridge

Link the startup script to the root of user 'local'

cd
ln -s svn/robobot/setup/start_bridge.sh

This script starts roscore and the bridge in this order.

Add the script to autostart at boot

crontab -e

In the editor add this line

@reboot /home/local/start_bridge

For info, the start script is executed as user 'local' and has the following content:

#!/bin/bash
# start roscore and bridge
# this script is added as a root cronjob
# to see and edit the job
# $ crontab -e
#
cd /home/local/
date >> rebootinfo.txt
/usr/bin/roscore &
# wait for ROSCORE to start
sleep 8    
#start the bridge (as daemon)
./bridge -d  &
echo "Bridge started with PID:" >> rebootinfo.txt
sleep 1
pgrep -l bridge >> rebootinfo.txt
exit 0

If all goes well, then the 'rebootinfo.txt' should end with something like this:

Sun 27 Nov 13:03:52 CET 2022
Bridge started with PID:
426 start_bridge.sh
617 bridge

Clone the just installed image

Use SD card clone/copier (on Raspberry??)

- rpi-clone script should work (not tested).