From 7fd8e4b9986c11f355fa0cfd9c47c6bef7b9129c Mon Sep 17 00:00:00 2001 From: zlynch2 Date: Mon, 9 Sep 2024 18:41:42 +0000 Subject: [PATCH] [nasa/nos3#84] fprime selection for configure, added fprime.sh script to cp to docker_launch when fprime selected --- fsw/fprime/fprime-nos3 | 2 +- scripts/configure.py | 4 + scripts/docker_checkout.sh | 58 ------------- scripts/docker_launch.sh | 1 - scripts/fprime.sh | 171 ++++++++++++++++++++++++++++++------- 5 files changed, 146 insertions(+), 90 deletions(-) diff --git a/fsw/fprime/fprime-nos3 b/fsw/fprime/fprime-nos3 index f964bb8a..6c86d670 160000 --- a/fsw/fprime/fprime-nos3 +++ b/fsw/fprime/fprime-nos3 @@ -1 +1 @@ -Subproject commit f964bb8ae9bbc8f206226b4287c080818e697029 +Subproject commit 6c86d6705cde471081bcc5f8aa70034d39e43a45 diff --git a/scripts/configure.py b/scripts/configure.py index ea394ddf..f5090b84 100755 --- a/scripts/configure.py +++ b/scripts/configure.py @@ -26,9 +26,13 @@ fsw_identified = 1 os.system('cp ./scripts/fsw_fprime_build.sh ./cfg/build/fsw_build.sh') os.system('cp ./scripts/fsw_fprime_launch.sh ./cfg/build/fsw_launch.sh') + os.system('cp ./scripts/fprime.sh ./scripts/docker_launch.sh') if (fsw_cfg == 'cfs'): fsw_identified = 1 + # os.system('cp ./scripts/fsw_fprime_build.sh ./cfg/build/fsw_build.sh') + # os.system('cp ./scripts/fsw_fprime_launch.sh ./cfg/build/fsw_launch.sh') + os.system('cp ./scripts/cfs_cosmos.sh ./scripts/docker_launch.sh') if (fsw_identified == 0): print('Invalid FSW in configuration file!') diff --git a/scripts/docker_checkout.sh b/scripts/docker_checkout.sh index 1befbc8d..ba1315f5 100755 --- a/scripts/docker_checkout.sh +++ b/scripts/docker_checkout.sh @@ -5,61 +5,3 @@ # https://github.com/nasa-itc/deployment # -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[1]}" )/scripts" &> /dev/null && pwd ) -source $SCRIPT_DIR/env.sh - -export SC_NUM="sc_1" -export SC_NETNAME="nos3_"$SC_NUM -# export SC_NETNAME="host" -export SC_CFG_FILE="-f nos3-simulator.xml" #"-f sc_"$i"_nos3_simulator.xml" - -echo "Create spacecraft network..." -$DNETWORK create $SC_NETNAME 2> /dev/null -echo "" - -# Debugging -# Replace `--tab` with `--window-with-profile=KeepOpen` once you've created this gnome-terminal profile manually - -#echo "42..." -#rm -rf $USER_NOS3_DIR/42/NOS3InOut -#cp -r $BASE_DIR/cfg/build/InOut $USER_NOS3_DIR/42/NOS3InOut -#xhost +local:* -#gnome-terminal --tab --title=$SC_NUM" - 42" -- $DFLAGS -e DISPLAY=$DISPLAY -v $USER_NOS3_DIR:$USER_NOS3_DIR -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name $SC_NUM"_fortytwo" -h fortytwo --network=$SC_NETNAME -w $USER_NOS3_DIR/42 -t $DBOX $USER_NOS3_DIR/42/42 NOS3InOut -#echo "" - -echo "NOS Core..." -gnome-terminal --tab --title="NOS Engine Server" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_nos_engine_server" -h nos_engine_server --network=$SC_NETNAME -w $SIM_BIN $DBOX /usr/bin/nos_engine_server_standalone -f $SIM_BIN/nos_engine_server_config.json -gnome-terminal --tab --title="NOS Time Driver" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name nos_time_driver --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE time -gnome-terminal --tab --title="NOS Terminal" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name "nos_terminal" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE stdio-terminal - -echo "Checkout..." -# Rename for your simulator under test to allow checkout -gnome-terminal --tab --title="Sample Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_sample_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE sample_sim - -#testing star tracker -gnome-terminal --tab --title="Generic Star Tracker" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_generic_star_tracker_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_star_tracker_sim -#testing generic mag -# gnome-terminal --tab --title="Generic Mag" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_generic_mag_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_mag_sim -# Example manual build for sample checkout: -# cd ./components/sample/support -# mkdir build -# cd build -# cmake .. -DTGTNAME=cpu1 -# make - -# Rename for your checkout under test to allow checkout -gnome-terminal --tab --title="FPrime" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_sample_checkout" --network=$SC_NETNAME -w $BASE_DIR $DBOX ./scripts/fsw_fprime_launch.sh -#gnome-terminal --title="Sample Checkout" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_sample_checkout" --network=$SC_NETNAME -w $BASE_DIR $DBOX ./components/sample/support/build/sample_checkout - -echo "" - -sleep 1 - -urlIP=$(docker container inspect sc_1_sample_checkout | grep -i IPAddress | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") - -sleep 10 - -firefox ${urlIP}:5000 - -echo "" - diff --git a/scripts/docker_launch.sh b/scripts/docker_launch.sh index e7eff394..3bf21255 100755 --- a/scripts/docker_launch.sh +++ b/scripts/docker_launch.sh @@ -94,7 +94,6 @@ do echo $SC_NUM " - Flight Software..." cd $FSW_DIR - # gnome-terminal --title=$SC_NUM" - NOS3 Flight Software" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_nos_fsw" -h nos_fsw --network=$SC_NETNAME -w $FSW_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $DBOX $SCRIPT_DIR/fsw_respawn.sh & gnome-terminal --tab --title="FPrime" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_sample_checkout" --network=$SC_NETNAME -w $BASE_DIR $DBOX ./scripts/fsw_fprime_launch.sh diff --git a/scripts/fprime.sh b/scripts/fprime.sh index 92f9f8af..3bf21255 100755 --- a/scripts/fprime.sh +++ b/scripts/fprime.sh @@ -8,43 +8,154 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source $SCRIPT_DIR/env.sh -export SC_NUM="sc_1" -export SC_NETNAME="nos3_"$SC_NUM -# export SC_NETNAME="host" -export SC_CFG_FILE="-f nos3-simulator.xml" #"-f sc_"$i"_nos3_simulator.xml" +# Check that local NOS3 directory exists +if [ ! -d $USER_NOS3_DIR ]; then + echo "" + echo " Need to run make prep first!" + echo "" + exit 1 +fi -echo "Create spacecraft network..." -$DNETWORK create $SC_NETNAME 2> /dev/null +# Check that configure build directory exists +if [ ! -d $BASE_DIR/cfg/build ]; then + echo "" + echo " Need to run make config first!" + echo "" + exit 1 +fi + +echo "Make data folders..." +# FSW Side +mkdir $FSW_DIR/data 2> /dev/null +mkdir $FSW_DIR/data/cam 2> /dev/null +mkdir $FSW_DIR/data/evs 2> /dev/null +mkdir $FSW_DIR/data/hk 2> /dev/null +mkdir $FSW_DIR/data/inst 2> /dev/null +# GSW Side +mkdir /tmp/nos3 2> /dev/null +mkdir /tmp/nos3/data 2> /dev/null +mkdir /tmp/nos3/data/cam 2> /dev/null +mkdir /tmp/nos3/data/evs 2> /dev/null +mkdir /tmp/nos3/data/hk 2> /dev/null +mkdir /tmp/nos3/data/inst 2> /dev/null +mkdir /tmp/nos3/uplink 2> /dev/null +cp $BASE_DIR/fsw/build/exe/cpu1/cf/cfe_es_startup.scr /tmp/nos3/uplink/tmp0.so 2> /dev/null +cp $BASE_DIR/fsw/build/exe/cpu1/cf/sample.so /tmp/nos3/uplink/tmp1.so 2> /dev/null + +echo "Create ground networks..." +$DNETWORK create \ + --driver=bridge \ + --subnet=192.168.41.0/24 \ + --gateway=192.168.41.1 \ + nos3_core +echo "" + +#echo "Launch GSW..." +$BASE_DIR/cfg/build/gsw_launch.sh +echo "" + +echo "Create NOS interfaces..." +export GND_CFG_FILE="-f nos3-simulator.xml" +gnome-terminal --tab --title="NOS Terminal" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name "nos_terminal" --network=nos3_core -w $SIM_BIN $DBOX ./nos3-single-simulator $GND_CFG_FILE stdio-terminal +gnome-terminal --tab --title="NOS UDP Terminal" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name "nos_udp_terminal" --network=nos3_core -w $SIM_BIN $DBOX ./nos3-single-simulator $GND_CFG_FILE udp-terminal echo "" -# Debugging -# Replace `--tab` with `--window-with-profile=KeepOpen` once you've created this gnome-terminal profile manually +# Note only currently working with a single spacecraft +export SATNUM=1 + +# +# Spacecraft Loop +# +for (( i=1; i<=$SATNUM; i++ )) +do + export SC_NUM="sc_"$i + export SC_NETNAME="nos3_"$SC_NUM + export SC_CFG_FILE="-f nos3-simulator.xml" #"-f sc_"$i"_nos3_simulator.xml" + + # Debugging + #echo "Spacecraft number = " $SC_NUM + #echo "Spacecraft network = " $SC_NETNAME + #echo "Spacecraft configuration = " $SC_CFG_FILE + + echo $SC_NUM " - Create spacecraft network..." + $DNETWORK create $SC_NETNAME 2> /dev/null + echo "" -#echo "42..." -#cd /opt/nos3/42/ -#rm -rf NOS3InOut -#cp -r $BASE_DIR/sims/cfg/InOut /opt/nos3/42/NOS3InOut -#xhost +local:* -#gnome-terminal --window-with-profile=KeepOpen --title="42" -- $DFLAGS -e DISPLAY=$DISPLAY -v /opt/nos3/42/NOS3InOut:/opt/nos3/42/NOS3InOut -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name $SC_NUM"_fortytwo" -h fortytwo --network=$SC_NETNAME -w /opt/nos3/42 -t $DBOX /opt/nos3/42/42 NOS3InOut -#echo "" + # echo $SC_NUM " - Connect COSMOS to spacecraft network..." + # $DNETWORK connect $SC_NETNAME cosmos_openc3-operator_1 --alias cosmos + # echo "" -echo "NOS Core..." -gnome-terminal --tab --title="NOS Engine Server" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_nos_engine_server" -h nos_engine_server --network=$SC_NETNAME -w $SIM_BIN $DBOX /usr/bin/nos_engine_server_standalone -f $SIM_BIN/nos_engine_server_config.json -gnome-terminal --tab --title="NOS Time Driver" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name nos_time_driver --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE time -gnome-terminal --tab --title="NOS Terminal" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name "nos_terminal" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE stdio-terminal + echo $SC_NUM " - 42..." + rm -rf $USER_NOS3_DIR/42/NOS3InOut + cp -r $BASE_DIR/cfg/build/InOut $USER_NOS3_DIR/42/NOS3InOut + xhost +local:* + gnome-terminal --tab --title=$SC_NUM" - 42" -- $DFLAGS -e DISPLAY=$DISPLAY -v $USER_NOS3_DIR:$USER_NOS3_DIR -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name $SC_NUM"_fortytwo" -h fortytwo --network=$SC_NETNAME -w $USER_NOS3_DIR/42 -t $DBOX $USER_NOS3_DIR/42/42 NOS3InOut + echo "" -echo "Checkout..." -# Rename for your simulator under test to allow checkout -gnome-terminal --tab --title="Sample Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_sample_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE sample_sim + echo $SC_NUM " - Flight Software..." + cd $FSW_DIR + gnome-terminal --tab --title="FPrime" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_sample_checkout" --network=$SC_NETNAME -w $BASE_DIR $DBOX ./scripts/fsw_fprime_launch.sh -# Example manual build for sample checkout: -# cd ./components/sample/support -# mkdir build -# cd build -# cmake .. -DTGTNAME=cpu1 -# make -# Rename for your checkout under test to allow checkout -# gnome-terminal --window-with-profile=KeepOpen --title="Sample f' test" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_sample_checkout" --network=$SC_NETNAME -w $BASE_DIR $DBOX ./components/sample/fprime/build/sample_checkout + echo "" + #gnome-terminal --window-with-profile=KeepOpen --title=$SC_NUM" - NOS3 Flight Software" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_nos_fsw" -h nos_fsw --network=$SC_NETNAME -w $FSW_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $DBOX $FSW_DIR/core-cpu1 -R PO & + echo "" + # Debugging + # Replace `--tab` with `--window-with-profile=KeepOpen` once you've created this gnome-terminal profile manually + + echo $SC_NUM " - CryptoLib..." + gnome-terminal --tab --title=$SC_NUM" - CryptoLib" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_cryptolib" --network=$SC_NETNAME --network-alias=cryptolib -w $BASE_DIR/gsw/build $DBOX ./support/standalone + echo "" + + echo $SC_NUM " - Simulators..." + cd $SIM_BIN + gnome-terminal --tab --title=$SC_NUM" - NOS Engine Server" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_nos_engine_server" -h nos_engine_server --network=$SC_NETNAME -w $SIM_BIN $DBOX /usr/bin/nos_engine_server_standalone -f $SIM_BIN/nos_engine_server_config.json + gnome-terminal --tab --title=$SC_NUM" - 42 Truth Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_truth42sim" -h truth42sim --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE truth42sim + + $DNETWORK connect $SC_NETNAME nos_terminal + $DNETWORK connect $SC_NETNAME nos_udp_terminal + + # Component simulators + gnome-terminal --tab --title=$SC_NUM" - CAM Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_cam_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE camsim + gnome-terminal --tab --title=$SC_NUM" - CSS Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_css_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_css_sim + gnome-terminal --tab --title=$SC_NUM" - EPS Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_eps_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_eps_sim + gnome-terminal --tab --title=$SC_NUM" - FSS Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_fss_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_fss_sim + gnome-terminal --tab --title=$SC_NUM" - GPS Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_gps_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE gps + gnome-terminal --tab --title=$SC_NUM" - IMU Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_imu_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_imu_sim + gnome-terminal --tab --title=$SC_NUM" - MAG Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_mag_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_mag_sim + gnome-terminal --tab --title=$SC_NUM" - RW 0 Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_rw_sim0" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic-reactionwheel-sim0 + gnome-terminal --tab --title=$SC_NUM" - RW 1 Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_rw_sim1" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic-reactionwheel-sim1 + gnome-terminal --tab --title=$SC_NUM" - RW 2 Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_rw_sim2" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic-reactionwheel-sim2 + + gnome-terminal --tab --title=$SC_NUM" - Radio Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_radio_sim" -h radio_sim --network=$SC_NETNAME --network-alias=radio_sim -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_radio_sim + + gnome-terminal --tab --title=$SC_NUM" - Sample Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_sample_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE sample_sim + gnome-terminal --tab --title=$SC_NUM" - StarTrk Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_startrk_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_star_tracker_sim + gnome-terminal --tab --title=$SC_NUM" - Torquer Sim" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name $SC_NUM"_torquer_sim" --network=$SC_NETNAME -w $SIM_BIN $DBOX ./nos3-single-simulator $SC_CFG_FILE generic_torquer_sim + echo "" +done + +echo "NOS Time Driver..." +sleep 8 +gnome-terminal --tab --title="NOS Time Driver" -- $DFLAGS -v $SIM_DIR:$SIM_DIR --name nos_time_driver --network=nos3_core -w $SIM_BIN $DBOX ./nos3-single-simulator $GND_CFG_FILE time +sleep 1 +for (( i=1; i<=$SATNUM; i++ )) +do + export SC_NUM="sc_"$i + export SC_NETNAME="nos3_"$SC_NUM + export TIMENAME=$SC_NUM"_nos_time_driver" + $DNETWORK connect --alias nos_time_driver $SC_NETNAME nos_time_driver +done echo "" + + +sleep 1 + +urlIP=$(docker container inspect sc_1_sample_checkout | grep -i IPAddress | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") + +sleep 10 + +firefox ${urlIP}:5000 + +echo "Docker launch script completed!"