Created
December 14, 2017 21:38
-
-
Save OAkyildiz/930cbc66e393ac15654047db58125d70 to your computer and use it in GitHub Desktop.
Output a .json file for TRINA server configuration. Use tih as a stub to attach quote marks to vairables' provide verbose and help output with scripts, and to cat multiline text. Will be updated s oon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
verbose(){ | |
cat $output | |
} | |
help(){ | |
echo "trina-config: generate json file for the trina server" | |
echo "usage : trina-config" | |
echo "-h output this message" | |
echo "-v print out the json output" | |
} | |
#put quotes if the variable is not null | |
nullcheck(){ | |
if [ "$1" == "null" ];then | |
echo $1 | |
else | |
echo -e \"$1\" | |
fi | |
} | |
#generate the .json output, push it to the file | |
#using bash trickery (refer to nullcheck()) to put quotes if arg is not null | |
makejson(){ | |
rm -f $output | |
cat >$output<<EOL | |
# generated by trina-config script. Run the script again, | |
# or modify manually toupdate config. | |
{ | |
"torso_enabled":true, | |
"left_gripper_enabled":true, | |
"right_gripper_enabled":true, | |
"left_gripper":"reflex", | |
"right_gripper":"reflex", | |
"base_enabled":true, | |
"klampt_model":"klampt_models/ebolabot_col.rob" | |
"motion_computer_ip":$(nullcheck $motion_ip), | |
"state_server_computer_ip":$(nullcheck $state_ip), | |
"torso_vision_computer_ip":$(nullcheck $torso_vis_ip), | |
"left_hand_vision_computer_ip":$(nullcheck $left_vis_ip), | |
"right_hand_vision_computer_ip":$(nullcheck $right_vis_ip), | |
"pointer_arduino_ip":$(nullcheck $pointer_ard_ip), | |
"remote_start_arduino_ip":$(nullcheck remote_ard_ip), | |
"ui_computer_ip":$(nullcheck $ui_computer_ip), | |
"gamepad_port":$(nullcheck gamepad_p), | |
"slider_port":$(nullcheck slider_p), | |
"haptic_server_computer_ip":$(nullcheck $haptic_ip), | |
} | |
EOL | |
} | |
#file | |
output=/home/trina/iml-internal/Ebolabot/Common/system_config.json | |
if [ -z $1 ];then | |
help | |
exit 1 | |
else | |
#IP adresses, arguments | |
motion_ip=$1 | |
state_ip=$2 | |
torso_vis_ip=null | |
left_vis_ip=null | |
right_vis_ip=null | |
pointer_ard_ip=null | |
remote_ard_ip=null | |
ui_computer_ip=$ROS_IP | |
gamepad_p=null | |
slider_p=null | |
haptic_ip="tcp://192.168.0.103:3456" | |
makejson | |
if [ "$verbose" == true ]; then | |
verbose | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment