forked from ERF2024/dog_challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_framework.sh
executable file
·144 lines (120 loc) · 3.77 KB
/
start_framework.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
# Get this script's path
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
set -e
USAGE="Usage: \n start_framework [OPTIONS...]
\n\n
Help Options:
\n
-h,--help \tShow help options
\n\n
Application Options:
\n
-n,--namespace \tDefine the ROS namespace [default=], example: -n robot_1
\n
-w,--world \tWorld name [default=navigation|locomotion], example: -w navigation
\n
-v,--volume \tMounted folder [default=$HOME/ros_ws], example: -v $HOME/ros_ws"
echo '
###########################################
# #
# WoLF #
# #
# https://github.com/graiola/wolf-setup #
# . #
# / V\ #
# / . / #
# << | #
# / | #
# / | #
# / | #
# / \ \ / #
# ( ) | | #
# ________| _/_ | | #
# <__________\______)\__) #
# #
###########################################
'
if [[ ( $1 == "--help") || $1 == "-h" ]]
then
echo -e $USAGE
exit 0
fi
# Default
NAMESPACE=
WORLD_NAME=navigation
MOUNTED_CODE_VOLUME=$HOME/ros_ws
while [ -n "$1" ]; do # while loop starts
case "$1" in
-n|--namespace)
NAMESPACE="$2"
shift
;;
-w|--world)
WORLD_NAME="$2"
shift
;;
-v|--volume)
MOUNTED_CODE_VOLUME="$2"
shift
;;
*) echo "Option $1 not recognized!"
echo -e $USAGE
exit 0;;
esac
shift
done
# Options (Do not modify them!)
ROS=noetic
CONTAINER_NAME="wolf-app"
IMAGE_TAG="focal"
ROBOT_MODEL=go1
WORLD_FILE=/home/root/dog_challenge/worlds/$WORLD_NAME/$WORLD_NAME.world
GAZEBO_GUI=true
SENSORS=true
INITIAL_XYZ=[0.0,0.0,1.0]
INITIAL_RPY=[0.0,0.0,0.0]
NET=host
GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/$ROS/share/wolf_gazebo_resources/models/:/home/root/dog_challenge/models
GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/home/root/dog_challenge/worlds/$WORLD_NAME
# Checks
if [[ ( $WORLD_NAME == "navigation") || ( $WORLD_NAME == "locomotion") ]]
then
echo "Selected world: $WORLD_NAME"
else
echo "Wrong world option!"
echo -e $USAGE
exit 0
fi
# Set initial pose based on the selected world
if [[ ( $WORLD_NAME == "navigation") ]]
then
INITIAL_XYZ=[-0.2,-9.8,1.0]
INITIAL_RPY=[0.0,0.0,0]
fi
if [[ ( $WORLD_NAME == "locomotion") ]]
then
INITIAL_XYZ=[1.0,0.0,1.0]
INITIAL_RPY=[0.0,0.0,-3.14]
fi
# Define the image name
IMAGE_NAME=serger87/$CONTAINER_NAME:$IMAGE_TAG
# Add docker to xhost
xhost +local:docker
if [ `sudo systemctl is-active docker` = "inactive" ]; then
echo "Docker inactive. Starting docker..."
sudo systemctl start docker
fi
#be sure there is no update on the image
docker pull $IMAGE_NAME
# Cleanup the docker container before launching it
docker rm -f $CONTAINER_NAME > /dev/null 2>&1 || true
docker run --user root:root --hostname $HOSTNAME --net=$NET --device=/dev/dri:/dev/dri --privileged -e "QT_X11_NO_MITSHM=1" -e GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH -e GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH -e SHELL -e DISPLAY -e DOCKER=1 --name $CONTAINER_NAME \
--gpus all \
--device=/dev/ttyUSB0 \
--volume="/tmp:/tmp:rw" \
--volume="$SCRIPTPATH:/home/root/dog_challenge:rw" \
--volume="$MOUNTED_CODE_VOLUME:/home/root/ros_ws:rw"\
-it $IMAGE_NAME $SHELL -c "source /opt/ros/$ROS/setup.bash; source /opt/xbot/setup.sh; roslaunch wolf_controller wolf_controller_bringup.launch robot_name:=$NAMESPACE robot_model:=$ROBOT_MODEL sensors:=$SENSORS gazebo_gui:=$GAZEBO_GUI initial_xyz:=$INITIAL_XYZ initial_rpy:=$INITIAL_RPY world_file:=$WORLD_FILE"