-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoperator.bash
More file actions
29 lines (25 loc) · 839 Bytes
/
operator.bash
File metadata and controls
29 lines (25 loc) · 839 Bytes
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
#!/bin/bash
set -e -o pipefail
if [ -z "$OPERATOR" ]; then
echo "Error: OPERATOR environment variable is not defined."
echo "Please set it with: export OPERATOR=your_name"
echo "Or run with OPERATOR=your_name bash operator.bash"
exit 1
fi
# Cleanup function to kill background processes
cleanup() {
echo "Shutting down..."
kill -KILL -- -"$PID_JOY" 2>/dev/null || true
wait "$PID_JOY" 2>/dev/null || true
}
trap cleanup SIGINT SIGTERM EXIT
setsid ros2 run joy joy_node --ros-args -r __ns:="/${OPERATOR}" -p deadzone:=0.025 -p autorepeat_rate:=0.0 &
PID_JOY=$!
setpgid "$PID_JOY" "$PID_JOY" 2>/dev/null || true
ros2 run ms_operator operator \
--ros-args \
-p joint_speed:=0.15 \
-p wheel_speed:=0.2 \
-p translation_speed:=50.0 \
-p rotation_speed:=0.15 \
-r /joy:="/${OPERATOR}/joy"