Skip to content

Bash Scripts

Kenneth L edited this page Oct 22, 2023 · 2 revisions
  • The following are defined in ~/gra/.devcontainer/convenience.sh and the scripts that it sources. Please read further for more details.
  • Many environmental variables (settings!) are written in ~/gra/.devcontainer/env_vars.sh, modify that and you modify the behaviour of commands too.

General

  • dev: Runs the development bringup. Includes all nodes, and a debug GUI (rviz). Shortcut for roslaunch gra_dev dev.launch

    • IMPORTANT: Because many of the nodes are running remotely, you cannot see the logs using roslaunch alone. Use in tandem with the next command.
  • log: Logs all the node’s information out.

    Useful to run log & when you create a new terminal for running launch files, which means you run log in the background, still showing the new log entries while allowing you to enter other commands such as dev.

  • grainfo: Shows information about where you are running your command (devcontainer, or robot); and basic info of ROS

    Example

    root@mycomp:~/gra# grainfo
    Device: RoboCapture Dev Environment
    Master: Local
    roscore status: Not running
    Bot status (gra.local): Online on 192.168.0.106
  • pexport: Allows you to export environmental variables persistently.

    Example

    root@mycomp:~/gra# pexport TEST_VAR "Hello world"
    Variable TEST_VAR has been set to "Hello world" and pexported.
  • punset: Allows you to remove variable definitions set by pexport

    Example

    root@mycomp:~/gra# punset TEST_VAR
    Variable TEST_VAR has been unset and removed from pexported variables.

CD shortcuts

  • cdws: CD into the catkin_ws
  • cdrepo: CD into the repository

ROS

  • cb: catkin build all your packages, and makes them available instantly. Magically works everywhere, unlike catkin build, where you must be within your workspace.

    Example

    root@mycomp:~/gra# cb
    ----------------------------------------------------
    Profile:                     default
    Extending:          [cached] /opt/ros/noetic
    Workspace:                   /root/catkin_ws
    ----------------------------------------------------
    Build Space:        [exists] /root/catkin_ws/build
    Devel Space:        [exists] /root/catkin_ws/devel
    Install Space:      [unused] /root/catkin_ws/install
    Log Space:          [exists] /root/catkin_ws/logs
    Source Space:       [exists] /root/gra/ros
    DESTDIR:            [unused] None
    ----------------------------------------------------
    Devel Space Layout:          linked
    Install Space Layout:        None
    ----------------------------------------------------
    Additional CMake Args:       None
    Additional Make Args:        None
    Additional catkin Make Args: None
    Internal Make Job Server:    True
    Cache Job Environments:      False
    ----------------------------------------------------
    Buildlisted Packages:        None
    Skiplisted Packages:         None
    ----------------------------------------------------
    Workspace configuration appears valid.
    ----------------------------------------------------
    [build] Found 3 packages in 0.0 seconds.                                                                                                                          
    [build] Package table is up to date.                                                                                                                              
    Starting  >>> gra_base                                                                                                                                            
    Starting  >>> gra_navigation                                                                                                                                      
    Starting  >>> gra_state_manager                                                                                                                                   
    Finished  <<< gra_navigation                   [ 0.1 seconds ]                                                                                                    
    Finished  <<< gra_state_manager                [ 0.1 seconds ]                                                                                                    
    Finished  <<< gra_base                         [ 0.2 seconds ]                                                                                                    
    [build] Summary: All 3 packages succeeded!                                                                                                                        
    [build]   Ignored:   None.                                                                                                                                        
    [build]   Warnings:  None.                                                                                                                                        
    [build]   Abandoned: None.                                                                                                                                        
    [build]   Failed:    None.                                                                                                                                        
    [build] Runtime: 0.4 seconds total.
  • cbs: catkin build all your packages on both your development computer and the bot!

  • setbotmaster: Targets ROS_MASTER to the robot

  • setdevmaster: Targets ROS_MASTER to your development computer

Arduino

  • abl: a.k.a. Arduino build library; builds ROS message types for Arduino to consume via rosserial. Needs to be run every time your message types change.

  • ac: Arduino compile (compiles your .ino code). Requires an up-to-date rosserial ROS library built by abl.

  • au: Arduino upload, uploads your code to the Arduino. Currently requires the Arduino be connected via USB.

    Note: Dependent on the $ARDUINO_UPDATE_PORT variable, defaults to /dev/ttyACM0 (USB)

  • acu: ac + au, useful for quickly compiling and uploading your code.

  • acm: cb + abl + ac, useful for making sure your Arduino related code is all up to date and can be built

Robot

Note: The following are commands meant to be run on the Docker devconatiner. May not work correctly on the robot.

  • botdo: Runs any command on the robot. Like how sudo makes the superuser execute things for you, it makes the robot execute things for you!
  • botsh: Opens a shell on the bot.
  • botsync: Synchronizes the code on the bot with the code in the docker.
  • alldo: Relative of botdo, but runs it first locally, then on the robot

Docker

  • RUN: Emulates the RUN line in Dockerfiles. Meant to run installation commands while simultaneously adding it to the Dockerfile if it succeeds.

    Example

    root@mycomp:~/gra# RUN apt-get install -y x11-utils
    Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease        
    ... # (removed for brevity)
    Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
    The command succeeded with exit code 0. Adding to Dockerfile.
  • UNRUN: Allows you to practically undo RUN commands.

Clone this wiki locally