Skip to content

Cheatsheet

Marija Golubović edited this page Mar 3, 2023 · 27 revisions

ROS

Stack

ssh [email protected]
source ~/ros2_ws/install/local_setup.bash

ros2 launch mep3_bringup robot_launch.py color:=blue namespace:=big bt:=false strategy:=demo

For example, if you are testing the motion then you can turn off the behavior tree (bt:=false).

Strategy

You can transfer a local strategy file to the Raspberry Pi:

scp first_strategy.xml [email protected]/home/ubuntu/ros2_ws/src/mep3/mep3_behavior/strategies/big

To execute the strategy run the robot_launch.py file (ros2 launch mep3_bringup robot_launch.py strategy:=first_strategy ...).

Alternatively, you can mount the strategy folder:

nautilus sftp://[email protected]/home/ubuntu/ros2_ws/src/mep3/mep3_behavior_tree/strategies

The command should open Nautilus (a file explorer) with all available strategies.

Run the Strategy Executor Standalone

Given that the strategy executor is a standalone node and the ROS' distributed nature (ROS 2 allows nodes to interact anywhere on a network) we can start the strategy executor independently:

ros2 run mep3_behavior mep3_behavior --ros-args -r __ns:=/big -p strategy:=first_strategy

This should significantly speed up the development process, especially considering that you can start the strategy outside of Raspberry Pi, for example on your PC. Note that you have to start the rest of the ROS stack without the strategy executor on the Raspberry Pi:

ros2 launch mep3_bringup robot_launch.py bt:=false ...

Mount strategies directory to local machine

This allows you to access the strategy folder located on the robot from your computer. In the location where you want to mount the directory, execute this commands:

mkdir mbig or mkdir msmall

sshfs  ubuntu@<robot IP adress>:/home/ubuntu/ros2_ws/src/mep3/mep3_behavior/strategies/ ~/<the name of the previously created directory>/

Linux

SSH with Hostname

sudo apt install avahi-discover

Change Hostname

sudo hostnamectl set-hostname $NEW_HOSTNAME
hostnamectl

Manage Users

sudo useradd --create-home $NEW_USERNAME
sudo passwd $NEW_USERNAME

Configure WiFi

sudo vim /etc/netplan/*.yaml
sudo netplan apply

Authentification

You don't need a password to login into a Raspberry Pi, you can use a public-private key pair. Append the content of the ~/.ssh/id_rsa.pub file (host) to the ~/.ssh/authorized_keys file (Raspberry Pi).

Tmux

Session management

Run a new tmux session

tmux

Attach to latest session

tmux attach

To detach from active session press Ctrl + B, write :detach and press Return key.

Attach to session named 0 Name is displayed on the left of the bottom green bar in brackets.

tmux attach-session -t 0

List all running sessions

tmux list-sessions

Logging

Save last 10000 lines inside an active session

Press Ctrl + B and write :capture-pane -S -10000 followed by a Return key. After that, press Ctrl + B again and write :save-buffer ~/tmux_session_log.out and press Return key.

To save all of the lines in the session, replace -10000 with -.

Save last 10000 lines of an active tmux session named 0

tmux capture-pane -t 1 -pS -10000 > ~/tmux_session_log.out