Skip to content

tmux

Tmux is a terminal multiplexer that allows you to create multiple terminal sessions within a single window. This is especially useful when working on remote systems, such as the car, as it allows you to keep your sessions alive even if your connection drops. Tmux also allows you to split your terminal window into multiple panes, making it easier to monitor multiple processes at once.

We use a tool called tmuxinator to manage our tmux sessions. Tmuxinator allows you to define your tmux sessions in a YAML file, making it easy to start and stop your sessions with a single command. The tmux and tmuxinator commands are different in that tmux is the underlying terminal multiplexer, while tmuxinator is a tool that helps you manage your tmux sessions. The basics of both are covered below.

Starting a tmux session

To start a new tmux session, simply run the command:

tmux

This will create a new tmux session and open a new terminal window within that session.

tmux modes

Tmux has two main modes: command mode and insert mode.

  • Command mode: This is the default mode when you start tmux. In this mode, you can use keyboard shortcuts to control tmux, such as creating new panes, switching between panes, and resizing panes.

  • Insert mode: This mode allows you to interact with the terminal as you normally would, typing commands and running programs.

Entering command mode is done by pressing Ctrl + b (the default prefix key), followed by another key to perform a specific action. For example, to create a new pane, you would press Ctrl + b, followed by % to split the window vertically or " to split it horizontally.

tmuxinator

Tmuxinator allows you to define multiple commands to be run in one tmux session in a YAML file. This file specifies the layout of your tmux session, including the number of panes, their sizes, and the commands to run in each pane.

To start a tmuxinator session, navigate to the directory containing the .tmuxinator.yml file and run the command:

tmuxinator

tmuxinator configurations

The folder ~/roboracer_ws/tmux/ contains several tmuxinator configuration files for different use cases. Each subfolder contains a .tmuxinator.yml file that defines the layout and commands for that specific use case.

These files provide a starting point for various tasks, such as teleoperating the car, running autonomous driving code, or recording data. You can customize these configurations or create your own to suit your specific needs.

Teleoperating Your Car

To drive your car using the PS4 joystick, the ~/roboracer_ws/tmux/teleop/.tmuxinator.yml file specifies all of the commands that need to be run to launch the teleoperation system. This configuration can be started using the tmuxinator command after entering ~/roboracer_ws/tmux/teleop/ folder:

cd ~/roboracer_ws/tmux/teleop/
tmuxinator

Creating Your Own tmuxinator Configuration

To create your own tmuxinator configuration, follow these steps:

  1. Create a new folder in ~/roboracer_ws/tmux/ for your configuration.

e.g. mkdir ~/roboracer_ws/tmux/my_custom_config/

  1. Create a new file named .tmuxinator.yml in the new folder, use the starting template, where my_custom_config is the name of your configuration:

Replace each element in the panes array with the commands you want to run in each pane.

name: my_custom_config
root: ~/roboracer_ws

windows:
  - simulator:
      layout: main-vertical
      panes:
        - 
        - ros2 launch mpu6050driver mpu6050driver_launch.py
        - ros2 run orin_rp2_csi mono_processor --ros-args -p width:=320 -p height:=240 -p framerate:=30 -p display_mode:="none"
        - ros2 launch ut_automata hokuyo_10lx.launch.py
        - ros2 run ut_automata vesc_driver
        - ros2 run ut_automata joystick
        - ros2 launch roboracer_description description.launch.py
        - ros2 launch foxglove_bridge foxglove_bridge_launch.xml
        - ros2 run ut_automata gui

Note: This file is written in YAML format, so be sure to maintain proper indentation.