raspberrypi, jetson & ROS - feliyur/exercises GitHub Wiki

Flush and backup raspberry pi:

Flush OS to SD Card:

sudo dd if=<input image>.img of=/dev/<SD card device> bs=1M

Backup

ssh pi "sudo dd if=/dev/mmcblk0 bs=1M | gzip -" | dd of=~/Desktop/pibackup.gz

to see progress, use either pv command (might need to install), or dd ... status=progress option. See here.

Reset Raspbian password

Instructions taken from here.

Password is stored in /etc/shadow file. Removing user's pi password then running sudo pi will allow to change it without inputting the old one. Just delete the password, not the entire line! like so:

pi:$wjeg2hgojglaghlkhj0349guoihdajsdgjo39jfjalajgljg:17178:0:99999:7:::

more options here (tl; dr: either raspi-config from command line, or edit password in configuration GUI).

Can remove need for password by editing /etc/passwd file, deleting "x" for authentication: E.g. change pi:x:1000:1000:,,,:/home/pi:/bin/bash into pi::1000:1000:,,,:/home/pi:/bin/bash

If any file got corrupted can fix by re-connecting the SD card to a working linux machine, then mounting it locally and making required fixes to the files.

ROS 1

source /opt/ros/noetic/setup.bash or <workspace_dir>/devel/setup.bash.
catkin build (prefer over catkin make which is the older version).
catkin clean
rostopic list
rostopic echo TOPIC [-b bagfile] [-n num_messages]
rosbag record TOPIC1 [TOPIC2 TOPIC3 ...] -l<NUM> -O <output_name.bag> Record NUM messages on each topic.
rosrun rqt_reconfigure rqt_reconfigure Dynamic configure parameters.
export ROS_MASTER_URI=http://192.168.1.158:11311 Set URI of roscore

Utils

catkin
rostopic
rosmsg
rosbag
rospack
rviz

Installing ROS on Windows

http://wiki.ros.org/Installation/Windows

Using Raspi camera

Enable camera via Preferences ==> Raspberry Pi Configuration ==> Interfaces ==> Camera

Take a single shot:

raspistill -o test.jpg

Stream video

raspivid -o - -t 0 -w 800 -h 600 -fps 12  | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8091/}' :demux=h264

Source: this tutorial.

To reduce disconnects, can try to add --rtsp-timeout 10 --h264-fps=12 arguments to cvlc. Make sure that fps argument to raspivid matches that of cvlc, i.e. number of frames produced matches the number consumed.

Jetson

Boot from SSD

http://www.yahboom.net/study/Jetson-TX2-NX ==> Move the system to SSD

https://www.waveshare.com/wiki/JETSON_NANO_TX2_NX#Set_The_System_To_Boot_From_SSD

Make VNC remotely available

sudo vim /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml

Add key:

<key name='enabled' type='b'>
    <summary>Enable remote access to the desktop</summary>
    <description>
        If true, allows remote access to the desktop via the RFB protocol. Users on remote machines may then connect to the desktop using a VNC viewer.
    </description>
    <default>true</default>
</key>

Save and re-compile schemas:

sudo glib-compile-schemas /usr/share/glib-2.0/schemas

Now "Desktop Sharing" panel should have stopped. Open the app and tick checkboxes to allow access.

Alternatively (or if the above still doesn't work), using the command line:

export DISPLAY=:0
gsettings set org.gnome.Vino enabled true
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
/usr/lib/vino/vino-server

Should launch and start listening now. Can verify that server is listening using

netstat -tuln

and look for LISTENING on port 5900 or 5901 which are the default VNC ports.

Backup and restore

https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3261/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E06P0HA

Configure Jetson as Hotspot

  1. Settings => Network => Wireless => Turn hotspot on
  2. Connections menu at the top of the desktop => Edit connections => Edit Hotspot => Wi-Fi tab => Set Mode to Hotspot (and not ad-hoc).
  3. Connections menu again ==> Connect to hidden wi-fi network ==> connect.

Taken from https://www.youtube.com/watch?v=GAOvGAdwiHk

Tricks

Correctly copy entire tree, e.g. rootfs cp -ax <src> <tgt>

Kill all processes using a given port fuser -kv /dev/ttyUSB9

⚠️ **GitHub.com Fallback** ⚠️