When I first started working through the ROS tutorials, one of the first annoyances I faced was the sheer number of terminals I was opening. In case you haven’t worked with ROS enough to get a feel for its unreasonable terminal demands, here’s a typical workflow. Let’s say I want to debug two nodes that talk to each other, like the “talker” and “listener” nodes used in the tutorials. All of the following processes need to be running simultaneously, and each should be started in its own terminal:
- The ROS Core, creatively named
roscore. It must be running whenever you want to run ROS code.
- The “talker” node
- The “listener” node
- Another terminal for running diagnostic commands like
rostopic pubwhile the nodes are running.
- An editing terminal, if I’m editing files using a terminal editor like Vim or Emacs
- It’s usually a good idea to have another terminal just for running catkin build commands, since builds can sometimes take a while and usually have to be run from a specific directory.
“Surely this can’t be right,” I thought to myself, as I haphazardly alt-tabbed between 5 terminals. “This is just what beginners do.” I thought there must be a development method that would not involve opening and switching between So. Many. Darn. Terminals.
Switching between terminals is something you might do, say, 50 times an hour (more while debugging, less while writing). If each switch takes you 1 second because you have to alt-tab through 4 terminal windows, that’s over 1% of your time going to switching terminals. Can you think of a task less worthy of your time? In many cases, this inefficiency is just the run of the mill when learning a new language or paradigm. Finding better tools and creating a workflow is just part of gaining mastery. You want to learn C, so you start by invoking
gcc yourself. After a while you realize just how annoying that is, and graduate to using Makefiles, then CMake. (If there are more steps in this progression that I haven’t taken, I’d love to hear about them!)
In the case of ROS, as it would turn out, some of those terminals (like the build terminal and the edit terminal) are dependent on your workflow and environment, and you can avoid needing them by working smarter. But you cannot avoid using the first 4 terminals, and that’s still about 3 more than you can easily put on your screen at once.Since you can’t reduce the number of terminals, the next-best solution is to manage them effectively. The default Ubuntu terminal does support terminal tabs, but switching between tabs is about as hard as switching from terminal to terminal. The number of required terminals can fluctuate throughout the day, so window tiling is also not an effective solution. And until the alt-tab interface in Ubuntu is fixed to work well with same-application windows (maybe Ubuntu 17 and GNOME do this better), it’s not a useful option either.
As a ROS developer, you’re left with a few options. You can struggle through a multi-window terminal setup. You can use a multiplexer like tmux, but that program makes you feel like you’re living in the 80s. It’s still very useful when logging into a remote machine, but the keyboard shortcuts are too arcane and there is a big barrier to entry. You have more important things to memorize than yet another set of keyboard shortcuts. What’s a dev to do?
For about a year, I struggled along in Multi-Window Terminal Hell, until one day I installed ROS at someone else’s lab. Their lab’s ROS setup instructions had me install Terminator, and my life was changed. Terminator has intuitive, shorter keyboard shortcuts. Would you rather type
ctrl-b + shift-5 Terminator also allows really easy panel resizing, quick switching between panels, and saved layouts. Using it was like switching to Python. Terminals were fun again! I added Terminator to my own personal ROS setup instructions and have not looked back since.
So much of your effectiveness as a software developer is how much time you spend on the “fiddly bits.” And ROS certainly has its share of fiddly bits, that just compound on those that already exist in Linux. ROS’s need for so many processes in turn forces you to face the pain of terminal switching. If you’re a ROS developer, it’s time to fix this. Install terminator, like I did. Use tmux if that’s your thing. Attach 5 monitors to your computer. Do what it takes to fix one of your computer’s inefficient annoyances today.