#!/bin/bash print_log=$(tail -n 1000 /home/cti/.ros/cloud_scheduling_node/cloud_scheduling_node.log | grep -a 状态预览 | tail -n 1 | awk '{print $0}') reboot=false for argument in "$@";do if [[ $argument == "reboot" ]];then reboot=true echo reboot needed fi done building=$(echo $print_log | awk -F '大楼全称: "' '{print $2}' | awk -F '"' '{print $1}') floor=$(echo $print_log | awk -F '当前位置: \\(' '{print $2}' | awk -F 'F' '{print $1}') x=$(echo $print_log | awk -F 'x:' '{print $2}' | awk -F "y" '{print $1}') y=$(echo $print_log | awk -F 'y:' '{print $2}' | awk -F "yaw" '{print $1}') yaw=$(echo $print_log | awk -F 'yaw:' '{print $2}' | awk -F "]" '{print $1}') if $reboot;then echo rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" >topic.bash else echo rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" >topic.bash fi date echo 正在停止服务! sudo service br stop sleep 3 for package in "$@";do if [[ "$package" == br*.deb ]];then sudo dpkg -i --force-overwrite "$package" echo $package 版本升级成功 sleep 3 fi done #source /opt/cti/kinetic/setup.bash #cd /opt/cti/kinetic/share/br_bringup/launch/ #nohup roslaunch br_bringup start_br.launch &>/dev/null& #echo "###################################################################################################################################" #sleep 5 #echo "###################################################################################################################################" #if $reboot;then # date # date # date # echo "###################################################################################################################################" # rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" # echo rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" #else # date # date # date # echo "###################################################################################################################################" # rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" # echo rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" #fi
时间: 2024-03-07 14:53:21 浏览: 138
解决-BASH: /HOME/JAVA/JDK1.8.0_221/BIN/JAVA: 权限不够问题
这是一个Bash脚本,主要功能是根据指定的日志文件,提取出最后1000行中包含“状态预览”的行,并从中提取出大楼名称、楼层、位置坐标和偏航角等信息。根据脚本的参数,可以选择是否重启机器人,并在执行重启或者重新定位的操作之前,停止机器人相关的服务,并升级指定的软件包。
该脚本的注释已经很详细,但是可能需要根据实际情况进行一些修改才能正确运行。
阅读全文