From c4a56477097f1ac60ac32c001f3c190f9f0e7366 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Fri, 17 May 2024 11:54:50 -0600 Subject: [PATCH 01/10] Added initial draft of startup script. --- rosplane_sim/scripts/sim_start.sh | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 rosplane_sim/scripts/sim_start.sh diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh new file mode 100755 index 0000000..d750ac4 --- /dev/null +++ b/rosplane_sim/scripts/sim_start.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Create a new tmux session +tmux new-session -d -s rosplane_sim_session + +tmux source-file ~/.tmux.conf + +# Split the tmux window into 4 panes +tmux split-window -t rosplane_sim_session:0.0 -h +tmux split-window -t rosplane_sim_session:0.0 -v +tmux split-window -t rosplane_sim_session:0.2 -v + +# Arrange panes in each corner +tmux select-pane -t rosplane_sim_session:0.0 +tmux select-pane -t rosplane_sim_session:0.1 +tmux select-pane -t rosplane_sim_session:0.2 +tmux select-pane -t rosplane_sim_session:0.3 + +# tmux send-keys -t rosplane_sim_session:0.0 'echo "Window 1 - Top Left"' C-m +# tmux send-keys -t rosplane_sim_session:0.1 'echo "Window 2 - Bottom Left"' C-m +# tmux send-keys -t rosplane_sim_session:0.2 'echo "Window 3 - Top Right"' C-m +# tmux send-keys -t rosplane_sim_session:0.3 'echo "Window 4 - Bottom Right"' C-m + +tmux send-keys -t rosplane_sim_session:0.0 'cd ~/repos/rosflight_ws/' C-m +tmux send-keys -t rosplane_sim_session:0.0 'ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=anaconda' C-m +tmux send-keys -t rosplane_sim_session:0.2 'ros2 launch rosplane_sim sim.launch.py aircraft:=anaconda' C-m +tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m +sleep 5 +tmux send-keys -t rosplane_sim_session:0.1 'ros2 service call /calibrate_imu std_srvs/srv/Trigger' C-m + +# Attach to the tmux session +tmux attach-session -t rosplane_sim_session + From 58576910f4cac5484c1789e3691cd332012f1553 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Fri, 17 May 2024 15:56:11 -0600 Subject: [PATCH 02/10] Added --help functionality and an argument for rc_sim. --- rosplane_sim/scripts/sim_start.sh | 33 +++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index d750ac4..928203f 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -1,5 +1,22 @@ #!/bin/bash +# Function to print help instructions +print_help() { + echo "Usage: $0 [options]" + echo + echo "Options:" + echo " -h, --help Show this help message and exit" + echo " -r, --rc_sim Run the script for no physical transmitter" +} + +# Check if -h or --help is passed as the first argument +if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + print_help + exit 0 +fi + +rc_sim=$1 + # Create a new tmux session tmux new-session -d -s rosplane_sim_session @@ -16,16 +33,20 @@ tmux select-pane -t rosplane_sim_session:0.1 tmux select-pane -t rosplane_sim_session:0.2 tmux select-pane -t rosplane_sim_session:0.3 -# tmux send-keys -t rosplane_sim_session:0.0 'echo "Window 1 - Top Left"' C-m -# tmux send-keys -t rosplane_sim_session:0.1 'echo "Window 2 - Bottom Left"' C-m -# tmux send-keys -t rosplane_sim_session:0.2 'echo "Window 3 - Top Right"' C-m -# tmux send-keys -t rosplane_sim_session:0.3 'echo "Window 4 - Bottom Right"' C-m +# Window placement reference: +# rosplane_sim_session:0.0 Top Left +# rosplane_sim_session:0.1 Bottom Left +# rosplane_sim_session:0.2 Top Right +# rosplane_sim_session:0.3 Bottom Right tmux send-keys -t rosplane_sim_session:0.0 'cd ~/repos/rosflight_ws/' C-m tmux send-keys -t rosplane_sim_session:0.0 'ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=anaconda' C-m tmux send-keys -t rosplane_sim_session:0.2 'ros2 launch rosplane_sim sim.launch.py aircraft:=anaconda' C-m -tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m -sleep 5 +# Add check to see if rc_sim has been passed an arg +if [ "$rc_sim" == "--rc_sim" ] || [ "$rc_sim" == "-r" ]; then + tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m +fi +sleep 5 # Add a better way to check if calibration can be done. Really find an async way to do this tmux send-keys -t rosplane_sim_session:0.1 'ros2 service call /calibrate_imu std_srvs/srv/Trigger' C-m # Attach to the tmux session From 498892d2d7f7d1a015ace8a4f537a5163f840274 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Fri, 17 May 2024 16:01:17 -0600 Subject: [PATCH 03/10] Added some notes on future improvements. --- rosplane_sim/scripts/sim_start.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index 928203f..fa37c32 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -39,9 +39,17 @@ tmux select-pane -t rosplane_sim_session:0.3 # rosplane_sim_session:0.2 Top Right # rosplane_sim_session:0.3 Bottom Right +# TODO add argument to know whether to launch a docker containter using compose. Smart way to extract name of container? Try to reduce number of args. +# TODO Will this be run on the base station? If so, it needs to connect via ssh. + +# Send commands to run the sim. +# TODO change to take path argument, and have all windows go to the directory. tmux send-keys -t rosplane_sim_session:0.0 'cd ~/repos/rosflight_ws/' C-m +# TODO add argument to check for sim or not. (If done rename the whole script) tmux send-keys -t rosplane_sim_session:0.0 'ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=anaconda' C-m +# TODO add argument if tuning or not. tmux send-keys -t rosplane_sim_session:0.2 'ros2 launch rosplane_sim sim.launch.py aircraft:=anaconda' C-m + # Add check to see if rc_sim has been passed an arg if [ "$rc_sim" == "--rc_sim" ] || [ "$rc_sim" == "-r" ]; then tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m From a126a62199e696c1d960a56cea9cd33769650ecb Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Mon, 20 May 2024 14:56:26 -0600 Subject: [PATCH 04/10] Added additional options to fill out functionality. --- rosplane_sim/scripts/sim_start.sh | 98 +++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index fa37c32..7d9f444 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -2,21 +2,68 @@ # Function to print help instructions print_help() { - echo "Usage: $0 [options]" + usage echo echo "Options:" - echo " -h, --help Show this help message and exit" - echo " -r, --rc_sim Run the script for no physical transmitter" + echo " -h Show this help message and exit" + echo " -s Run as simulation of ROSflight" + echo " -t Run tuning version of ROSflight" + echo " -r Run the script with simulated transmitter" + echo " -a Aircraft parameter to pass to launch files, default is anaconda" } -# Check if -h or --help is passed as the first argument -if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then +usage() { + echo "Usage: $0 [-h] [-s] [-t] [-r] [-a] aircraft path/to/ROSflight/workspace" +} + +sim=false +tuning=false +rc_sim=false +aircraft='anaconda' + +# Parse options using getopts +while getopts ":hstra:" opt; do + case $opt in + h) + + print_help + exit 0 + ;; + s) + sim=true + ;; + t) + tuning=true + ;; + r) + rc_sim=true + if ! $sim; then + echo "Cannot run simulated transitter, while not running a simulation." + exit 1 + fi + ;; + a) + aircraft=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + print_help + exit 1 + ;; + esac +done + +shift $((OPTIND -1)) + +# Get the file path +filepath=$1 + +# Check if filepath is provided +if [ -z "$filepath" ]; then + echo "Absolute/relative file path is required" print_help - exit 0 fi -rc_sim=$1 - # Create a new tmux session tmux new-session -d -s rosplane_sim_session @@ -40,21 +87,34 @@ tmux select-pane -t rosplane_sim_session:0.3 # rosplane_sim_session:0.3 Bottom Right # TODO add argument to know whether to launch a docker containter using compose. Smart way to extract name of container? Try to reduce number of args. -# TODO Will this be run on the base station? If so, it needs to connect via ssh. +# TODO Will this be run on the base station? If so, it needs to connect via ssh. I think that this may be less intensive on the network but I could be wrong. # Send commands to run the sim. -# TODO change to take path argument, and have all windows go to the directory. -tmux send-keys -t rosplane_sim_session:0.0 'cd ~/repos/rosflight_ws/' C-m -# TODO add argument to check for sim or not. (If done rename the whole script) -tmux send-keys -t rosplane_sim_session:0.0 'ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=anaconda' C-m -# TODO add argument if tuning or not. -tmux send-keys -t rosplane_sim_session:0.2 'ros2 launch rosplane_sim sim.launch.py aircraft:=anaconda' C-m - -# Add check to see if rc_sim has been passed an arg -if [ "$rc_sim" == "--rc_sim" ] || [ "$rc_sim" == "-r" ]; then +tmux send-keys -t rosplane_sim_session:0.0 "cd $filepath" C-m + +if $sim; then + tmux send-keys -t rosplane_sim_session:0.0 "ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=$aircraft" C-m +else + # TODO add functionality if it is not in sim. + echo "Use -s argument." + exit 1 +fi + +tmux send-keys -t rosplane_sim_session:0.2 "cd $filepath" C-m +if $tuning; then + tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim_tuning.launch.py aircraft:=$aircraft" C-m +else + tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim.launch.py aircraft:=$aircraft" C-m +fi + + +tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m +# Check to see if rc_sim has been passed an arg +if $rc_sim; then tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m fi -sleep 5 # Add a better way to check if calibration can be done. Really find an async way to do this +tmux send-keys -t rosplane_sim_session:0.1 "cd $filepath" C-m +sleep 3 # It doesn't look like there is a clear way to do this better. This will have to do. tmux send-keys -t rosplane_sim_session:0.1 'ros2 service call /calibrate_imu std_srvs/srv/Trigger' C-m # Attach to the tmux session From 7801d0adecee1bb45cf441416ef7a24e7c704545 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Tue, 21 May 2024 12:38:45 -0600 Subject: [PATCH 05/10] Implemented additional functionality. Implemented initial docker setup and bag recording. Also added local tmux window rather than a single pane being run locally. --- rosplane_sim/scripts/sim_start.sh | 95 ++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 15 deletions(-) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index 7d9f444..a14bb30 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -5,24 +5,35 @@ print_help() { usage echo echo "Options:" - echo " -h Show this help message and exit" - echo " -s Run as simulation of ROSflight" - echo " -t Run tuning version of ROSflight" - echo " -r Run the script with simulated transmitter" - echo " -a Aircraft parameter to pass to launch files, default is anaconda" + echo " -h Show this help message and exit" + echo " -s Run as simulation of ROSflight" + echo " -t Run tuning version of ROSflight" + echo " -r Run the script with simulated transmitter" + echo " -a Aircraft option to pass to launch files" + echo " aircraft The aricraft parameter to be used in launch files, default is anaconda" + echo " -b Start a ROS bag" + ehco " bag_name Name of bag (optional)" + echo " -o Run the tmux session online (on remote host)" + echo " user@host Username and address of remote" + echo " -d Indicate that you should run a docker container of the given name (uses compose, and compose file should be in workspce directory)" + echo " docker_name Name of container" + echo " path/to/workspace Path to workspace" } usage() { - echo "Usage: $0 [-h] [-s] [-t] [-r] [-a] aircraft path/to/ROSflight/workspace" + echo "Usage: $0 [-h] [-s] [-t] [-r] [-a aircraft] [-b [bag_name]] [-o user@host] [-d docker_container_name] path/to/ROSflight/workspace" } sim=false tuning=false rc_sim=false aircraft='anaconda' +online=false +docker=false +bag=false # Parse options using getopts -while getopts ":hstra:" opt; do +while getopts ":hstra:o:d:" opt; do case $opt in h) @@ -45,6 +56,25 @@ while getopts ":hstra:" opt; do a) aircraft=$OPTARG ;; + b) + bag=true + bag_name=$OPTARG + ;; + o) + online=true + user_host=$OPTARG + if $sim; then + echo "Cannot run simulat on a remote." + exit 1 + fi + ;; + d) + docker=true + docker_name=$OPTARG + if ! $online; then + echo "Script not configured for Docker not on remote." + fi + ;; \?) echo "Invalid option: -$OPTARG" >&2 print_help @@ -86,11 +116,31 @@ tmux select-pane -t rosplane_sim_session:0.3 # rosplane_sim_session:0.2 Top Right # rosplane_sim_session:0.3 Bottom Right -# TODO add argument to know whether to launch a docker containter using compose. Smart way to extract name of container? Try to reduce number of args. -# TODO Will this be run on the base station? If so, it needs to connect via ssh. I think that this may be less intensive on the network but I could be wrong. +# Setup all panes to ssh into the remote +if $online; then + tmux send-keys -t rosplane_sim_session:0.0 "ssh $user_host" C-m + tmux send-keys -t rosplane_sim_session:0.1 "ssh $user_host" C-m + tmux send-keys -t rosplane_sim_session:0.2 "ssh $user_host" C-m + tmux send-keys -t rosplane_sim_session:0.3 "ssh $user_host" C-m +fi -# Send commands to run the sim. +# Send all of the panes to the working directory. tmux send-keys -t rosplane_sim_session:0.0 "cd $filepath" C-m +tmux send-keys -t rosplane_sim_session:0.1 "cd $filepath" C-m +tmux send-keys -t rosplane_sim_session:0.2 "cd $filepath" C-m +tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m + +# TODO test docker implementation. + +if $docker; then + tmux send-keys -t rosplane_sim_session:0.0 "docker compose up -d" C-m + tmux send-keys -t rosplane_sim_session:0.0 "docker compose exec bash -t" C-m # TODO check these commands. + tmux send-keys -t rosplane_sim_session:0.1 "docker compose exec bash -t" C-m + tmux send-keys -t rosplane_sim_session:0.2 "docker compose exec bash -t" C-m + tmux send-keys -t rosplane_sim_session:0.3 "docker compose exec bash -t" C-m +fi + +# Send commands to run the sim. if $sim; then tmux send-keys -t rosplane_sim_session:0.0 "ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=$aircraft" C-m @@ -100,7 +150,6 @@ else exit 1 fi -tmux send-keys -t rosplane_sim_session:0.2 "cd $filepath" C-m if $tuning; then tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim_tuning.launch.py aircraft:=$aircraft" C-m else @@ -108,14 +157,30 @@ else fi -tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m # Check to see if rc_sim has been passed an arg if $rc_sim; then tmux send-keys -t rosplane_sim_session:0.3 'ros2 run rosflight_sim rc_sim.py --ros-args --remap RC:=/fixedwing/RC' C-m fi -tmux send-keys -t rosplane_sim_session:0.1 "cd $filepath" C-m -sleep 3 # It doesn't look like there is a clear way to do this better. This will have to do. -tmux send-keys -t rosplane_sim_session:0.1 'ros2 service call /calibrate_imu std_srvs/srv/Trigger' C-m + +if $sim; then + sleep 3 # It doesn't look like there is a clear way to do this better. This will have to do. + tmux send-keys -t rosplane_sim_session:0.1 'ros2 service call /calibrate_imu std_srvs/srv/Trigger' C-m +fi + +if $bag; then + if [ ! -z $bag_name ]; then + tmux send-keys -t rosplane_sim_session:0.1 "ros2 bag record -a -o $bag_name" C-m + else + tmux send-keys -t rosplane_sim_session:0.1 "ros2 bag record -a" C-m + fi +fi + +# Create another window that is on the local machine. +online=true +if $online; then + tmux new-window -t rosplane_sim_session -n local_env +fi + # Attach to the tmux session tmux attach-session -t rosplane_sim_session From dcfa082d98b6593895da023cafe1f0ea3c0cf53c Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Tue, 21 May 2024 15:01:42 -0600 Subject: [PATCH 06/10] Added correct directory for bags when recording online. --- rosplane_sim/scripts/sim_start.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index a14bb30..49ab27e 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -168,6 +168,11 @@ if $sim; then fi if $bag; then + + if $online; then + tmux send-keys -t rosplane_sim_session:0.1 "cd bags" + fi + if [ ! -z $bag_name ]; then tmux send-keys -t rosplane_sim_session:0.1 "ros2 bag record -a -o $bag_name" C-m else From ef4e5d5417157ef27668bee1c0ef4698202ef10a Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Wed, 22 May 2024 17:05:41 -0600 Subject: [PATCH 07/10] Fixed remote login issues and docker starting. Script now functions! --- rosplane_sim/scripts/sim_start.sh | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane_sim/scripts/sim_start.sh index 49ab27e..e32d8c5 100755 --- a/rosplane_sim/scripts/sim_start.sh +++ b/rosplane_sim/scripts/sim_start.sh @@ -16,7 +16,7 @@ print_help() { echo " -o Run the tmux session online (on remote host)" echo " user@host Username and address of remote" echo " -d Indicate that you should run a docker container of the given name (uses compose, and compose file should be in workspce directory)" - echo " docker_name Name of container" + echo " container Name of container" echo " path/to/workspace Path to workspace" } @@ -33,7 +33,7 @@ docker=false bag=false # Parse options using getopts -while getopts ":hstra:o:d:" opt; do +while getopts ":hstra:b:o:d:" opt; do case $opt in h) @@ -70,7 +70,7 @@ while getopts ":hstra:o:d:" opt; do ;; d) docker=true - docker_name=$OPTARG + container=$OPTARG if ! $online; then echo "Script not configured for Docker not on remote." fi @@ -134,10 +134,11 @@ tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m if $docker; then tmux send-keys -t rosplane_sim_session:0.0 "docker compose up -d" C-m - tmux send-keys -t rosplane_sim_session:0.0 "docker compose exec bash -t" C-m # TODO check these commands. - tmux send-keys -t rosplane_sim_session:0.1 "docker compose exec bash -t" C-m - tmux send-keys -t rosplane_sim_session:0.2 "docker compose exec bash -t" C-m - tmux send-keys -t rosplane_sim_session:0.3 "docker compose exec bash -t" C-m + sleep 2 + tmux send-keys -t rosplane_sim_session:0.0 "docker compose exec $container bash" C-m # TODO check these commands. + tmux send-keys -t rosplane_sim_session:0.1 "docker compose exec $container bash" C-m + tmux send-keys -t rosplane_sim_session:0.2 "docker compose exec $container bash" C-m + tmux send-keys -t rosplane_sim_session:0.3 "docker compose exec $container bash" C-m fi # Send commands to run the sim. @@ -145,15 +146,19 @@ fi if $sim; then tmux send-keys -t rosplane_sim_session:0.0 "ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py aircraft:=$aircraft" C-m else - # TODO add functionality if it is not in sim. - echo "Use -s argument." - exit 1 + tmux send-keys -t rosplane_sim_session:0.0 "ros2 run rosflight_io rosflight_io --ros-args -p port:=/dev/ttyACM0" C-m fi if $tuning; then - tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim_tuning.launch.py aircraft:=$aircraft" C-m -else + if $sim; then + tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim_tuning.launch.py aircraft:=$aircraft" C-m + else + tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_tuning rosplane_tuning.launch.py aircraft:=$aircraft" C-m + fi +elif $sim; then tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane_sim sim.launch.py aircraft:=$aircraft" C-m +else + tmux send-keys -t rosplane_sim_session:0.2 "ros2 launch rosplane rosplane.launch.py aircraft:=$aircraft" C-m fi @@ -170,18 +175,17 @@ fi if $bag; then if $online; then - tmux send-keys -t rosplane_sim_session:0.1 "cd bags" + tmux send-keys -t rosplane_sim_session:0.3 "cd bags" C-m fi if [ ! -z $bag_name ]; then - tmux send-keys -t rosplane_sim_session:0.1 "ros2 bag record -a -o $bag_name" C-m + tmux send-keys -t rosplane_sim_session:0.3 "ros2 bag record -a -o $bag_name" C-m else - tmux send-keys -t rosplane_sim_session:0.1 "ros2 bag record -a" C-m + tmux send-keys -t rosplane_sim_session:0.3 "ros2 bag record -a" C-m fi fi # Create another window that is on the local machine. -online=true if $online; then tmux new-window -t rosplane_sim_session -n local_env fi From 4c8645996140cc93505020c9d9e9e88fbcedfb6a Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Wed, 22 May 2024 17:13:33 -0600 Subject: [PATCH 08/10] Moved and refactored the startup script to a more appropriate location. --- .../sim_start.sh => rosplane/scripts/rosplane_gcs_launch.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rosplane_sim/scripts/sim_start.sh => rosplane/scripts/rosplane_gcs_launch.sh (100%) diff --git a/rosplane_sim/scripts/sim_start.sh b/rosplane/scripts/rosplane_gcs_launch.sh similarity index 100% rename from rosplane_sim/scripts/sim_start.sh rename to rosplane/scripts/rosplane_gcs_launch.sh From 21bc3b8bc6b2f32c4c5a464514c53b1c440e48d3 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Mon, 3 Jun 2024 10:04:24 -0600 Subject: [PATCH 09/10] Implemented feedback from PR. Consists of fixing typos and removing comments. It also better documents the script in the code. --- rosplane/scripts/rosplane_gcs_launch.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rosplane/scripts/rosplane_gcs_launch.sh b/rosplane/scripts/rosplane_gcs_launch.sh index e32d8c5..e214fb7 100755 --- a/rosplane/scripts/rosplane_gcs_launch.sh +++ b/rosplane/scripts/rosplane_gcs_launch.sh @@ -10,9 +10,9 @@ print_help() { echo " -t Run tuning version of ROSflight" echo " -r Run the script with simulated transmitter" echo " -a Aircraft option to pass to launch files" - echo " aircraft The aricraft parameter to be used in launch files, default is anaconda" + echo " aircraft The aircraft parameter to be used in launch files, default is anaconda" echo " -b Start a ROS bag" - ehco " bag_name Name of bag (optional)" + echo " bag_name Name of the ROS bag (optional)" echo " -o Run the tmux session online (on remote host)" echo " user@host Username and address of remote" echo " -d Indicate that you should run a docker container of the given name (uses compose, and compose file should be in workspce directory)" @@ -64,7 +64,7 @@ while getopts ":hstra:b:o:d:" opt; do online=true user_host=$OPTARG if $sim; then - echo "Cannot run simulat on a remote." + echo "Cannot run simulator on a remote." exit 1 fi ;; @@ -72,7 +72,7 @@ while getopts ":hstra:b:o:d:" opt; do docker=true container=$OPTARG if ! $online; then - echo "Script not configured for Docker not on remote." + echo "Running docker on the local machine is not supported currently." fi ;; \?) @@ -97,7 +97,8 @@ fi # Create a new tmux session tmux new-session -d -s rosplane_sim_session -tmux source-file ~/.tmux.conf +# Uncomment this line if you want to use your own tmux config +# tmux source-file ~/.tmux.conf # Split the tmux window into 4 panes tmux split-window -t rosplane_sim_session:0.0 -h @@ -130,7 +131,7 @@ tmux send-keys -t rosplane_sim_session:0.1 "cd $filepath" C-m tmux send-keys -t rosplane_sim_session:0.2 "cd $filepath" C-m tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m -# TODO test docker implementation. +# The docker commands assume that the container uses -it commands to create a persistent terminal. if $docker; then tmux send-keys -t rosplane_sim_session:0.0 "docker compose up -d" C-m From 049bac8bf2f6ebe8fb3bcbb5689378d731f92768 Mon Sep 17 00:00:00 2001 From: Ian Reid Date: Mon, 3 Jun 2024 10:11:52 -0600 Subject: [PATCH 10/10] Fixed TODO --- rosplane/scripts/rosplane_gcs_launch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosplane/scripts/rosplane_gcs_launch.sh b/rosplane/scripts/rosplane_gcs_launch.sh index e214fb7..f87611f 100755 --- a/rosplane/scripts/rosplane_gcs_launch.sh +++ b/rosplane/scripts/rosplane_gcs_launch.sh @@ -136,7 +136,7 @@ tmux send-keys -t rosplane_sim_session:0.3 "cd $filepath" C-m if $docker; then tmux send-keys -t rosplane_sim_session:0.0 "docker compose up -d" C-m sleep 2 - tmux send-keys -t rosplane_sim_session:0.0 "docker compose exec $container bash" C-m # TODO check these commands. + tmux send-keys -t rosplane_sim_session:0.0 "docker compose exec $container bash" C-m tmux send-keys -t rosplane_sim_session:0.1 "docker compose exec $container bash" C-m tmux send-keys -t rosplane_sim_session:0.2 "docker compose exec $container bash" C-m tmux send-keys -t rosplane_sim_session:0.3 "docker compose exec $container bash" C-m