-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·44 lines (40 loc) · 1.19 KB
/
run.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
#!/bin/bash
# -*- coding: UTF-8 -*-
init(){
echo -e "All nodes start! "
gnome-terminal --window -- bash -c "source ~/workspace/yolov8_venv/bin/activate; roslaunch cv_joint_angle yolov8.launch"
sleep 8
}
runing(){
echo -e "All nodes are ready! "
key=""
# 定义一个循环,无限执行,直到按下任意键
while [ -z "$key" ]; do
echo -e "Runing... "
# 用read命令读取标准输入,-t选项表示超时时间,-n选项表示字符数,-s选项表示静默模式
# 如果在10秒内输入了一个字符,那么赋值给key变量,否则赋值为空
read -p "Press any key to exit..." -t 120 -n 1 -s key
if [ -z "$key" ]; then
echo " "
fi
trap key=1 SIGINT SIGTERM
done
echo " "
rosnode kill cv_joint_angle
}
exit(){
# 定义一个循环,无限执行,直到找不到有roslaunch的进程
while true; do
count=$(pgrep -f -c roslaunch)
if [ $count -eq 0 ]; then
break
fi
pkill -SIGINT -f roslaunch
sleep 1
done
echo -e "Use 'rm -rf ~/.ros/log' to trash log "
echo -e "All nodes have been shut down!"
}
init
runing
exit