脚本bash

这是一个用于ROS(Robot Operating System)机器人的系统配置和管理的脚本,包括构建、启动、记录和管理lidar、camera、serial、gpio等组件。用户可以根据输入的选择执行不同的操作,如构建log4cpp、启动传感器、录制rosbag、管理服务等。
摘要由CSDN通过智能技术生成

输入脚本文件

#!/bin/bash
#log4
echo 'Input a number,Pay attention to the ip address of the lidar:
      0) Exit                                   1) Build all
      2) Build log4cpp                          3) Build ros sense
      4) Build ros algorithm                    5) Start sense one Terminal
      6) Start sensors                          7) Start rosbag record
      8) Stop positec.service                   9) Rosnode kill all
     10) Rviz display                          11) Add sense rules to tx2
     12) Start camera                          13) Start serial
     14) Start gpio                            15) Ros workspace
     16) Build update package                  17) Update software
     18) Serive start                          19) tx2 cope work to desktop 
'
read x
if [ "$x" == "" ] || [ "$x" == "0" ];then
    echo "You enter 0 or no input and the system will exit!"
    exit 5
fi

if [ "$x" == "2" ] || [ "$x" == "1" ];then
  cd robot_lib/log4cpp
  chmod 777 configure
  ./configure --build=arm-linux --with-pthreads
  make
  make check
  sudo make install
  sudo ldconfig
  cd ..
  cd ..
fi

if [ "$x" == "3" ] || [ "$x" == "1" ];then
  cd ./robot
  #sudo apt-get install ros-melodic-jsk-recognition-msgs 
  #sudo apt-get install ros-melodic-jsk-rviz-plugins
  chmod 777 ./src/zvision_ros_driver/zvision_lidar/zvision_lidar_driver/cfg/*
  chmod 777 ./src/zvision_ros_driver/zvision_lidar/zvision_lidar_pointcloud/cfg/*
  #net dst ip(255/0 change other)  netmask 255.255.255.0 
  #launch 
  #ip lidar ip
  #port 2364
  # win10 timestamp set off /downsample off /save reboot
  sudo apt-get install libpcap-dev
  catkin_make -DCATKIN_WHITELIST_PACKAGES="zvision_lidar_msgs"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="zvision_lidar_driver" -j4
  catkin_make -DCATKIN_WHITELIST_PACKAGES="zvision_lidar"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="zvision_lidar_pointcloud"
  sudo apt-get install ros-melodic-ddynamic-reconfigure
  catkin_make -DCATKIN_WHITELIST_PACKAGES="realsense2_camera" -j4
  #catkin_make -DCATKIN_WHITELIST_PACKAGES="camera_pub"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="camera_pub"
  #make gps imu odom
  catkin_make -DCATKIN_WHITELIST_PACKAGES="serial_date"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="gpio_ss"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="fusion_result_pub"
  catkin_make -DCATKIN_WHITELIST_PACKAGES="start_robot"
  cd ..
fi
if [ "$x" == "4" ] || [ "$x" == "1" ];then
  exit 5
fi
if [ "$x" == "5" ];then
  source ./robot/devel/setup.bash
  roslaunch start_robot start_robot.launch
fi
if [ "$x" == "6" ];then
  if [ -e "/sys/class/gpio/gpio304" ];then
    echo "GPIO 304 exist"
  else 
    echo "GPIO 304 does not exist,make it"
    echo 304 > /sys/class/gpio/export
    sleep 1
    echo out > /sys/class/gpio/gpio304/direction
    sleep 1
    echo in > /sys/class/gpio/gpio304/direction
  fi
  if [ -e "/sys/class/gpio/gpio342" ];then
    echo "GPIO 342 exist"
  else 
    echo "GPIO 342 does not exist,make it"
    echo 342 > /sys/class/gpio/export
    sleep 1
    echo in > /sys/class/gpio/gpio342/direction
    sleep 1
    echo out > /sys/class/gpio/gpio342/direction
    sleep 1
    echo 1 > /sys/class/gpio/gpio342/value
  fi
  source ~/positec/robot/devel/setup.bash
  cd robot_start
  chmod 777 run.sh
  ./run.sh
  cd ..
fi
if [ "$x" == "7" ];then
  cd robot_bag
  ./rosbag_record.sh
  cd ..
fi
if [ "$x" == "8" ];then
  cd robot_stop
  chmod 777 stop.sh
  ./stop.sh
  cd ..
fi
if [ "$x" == "9" ];then
  rosnode kill -a
fi
if [ "$x" == "10" ];then
  cd robot/src/start_robot/rviz
  rviz -d rviz.rviz
  cd -
fi
if [ "$x" == "11" ];then
  if [ -e "/etc/udev/rules.d/positec.rules" ];then
    echo "File exist"
    cat /etc/udev/rules.d/positec.rules
  else 
    echo "File does not exist,make it,/etc/udev/rules.d,chown -R root:root positec.rules"
    cd robot_rules
    sudo cp -pf positec.rules /etc/udev/rules.d/
    cat positec.rules
    echo "123"|sudo -S chown -R root:root /etc/udev/rules.d/positec.rules
  fi
fi
if [ "$x" == "12" ];then
  source ~/positec/robot/devel/setup.bash
  roslaunch camera_pub camera_test.launch
fi
if [ "$x" == "13" ];then
  echo "123"|sudo -S chmod 777 /dev/ttyGS1
  echo "123"|sudo -S chmod 777 /dev/pps0
  source ~/positec/robot/devel/setup.bash
  roslaunch serial_date serial_data.launch
fi
if [ "$x" == "14" ];then
  if [ -e "/sys/class/gpio/gpio304" ];then
    echo "GPIO 304 exist"
  else 
    echo "GPIO 304 does not exist,make it"
    echo 304 > /sys/class/gpio/export
    sleep 1
    echo out > /sys/class/gpio/gpio304/direction
    sleep 1
    echo in > /sys/class/gpio/gpio304/direction
  fi
  source ~/positec/robot/devel/setup.bash
  roslaunch gpio_ss gpio.launch
fi
if [ "$x" == "15" ];then
  cd robot/src
  catkin_init_workspace
  cd -
fi
if [ "$x" == "16" ];then
  echo "Robot_update package update.tar.gz.enc replace robot devel src"
  cd robot_update
  bash generate.sh
  cd -
fi
if [ "$x" == "17" ];then
  echo "Robot_update package update.tar.gz.enc replace robot devel src"
  cd robot_update
  bash update.sh
  cd -
fi
if [ "$x" == "18" ];then
  sudo cp /home/nvidia/positec/robot_service/etc/systemd/system/positec.service /etc/systemd/system
  systemctl daemon-reload
  systemctl enable positec.service
fi

if [ "$x" == "19" ];then
  rm -rf ~/positec
  cp -rpf ../positec /home/nvidia/
  cat ./robot/misc/version
fi

系统脚本

#!/usr/bin/env bash
sleep 30
if [ -e "/sys/class/gpio/gpio304" ];then
   echo "GPIO 304 exist"
else 
   echo "GPIO 304 does not exist,make it"
   echo 304 > /sys/class/gpio/export
   sleep 1
   echo out > /sys/class/gpio/gpio304/direction
   sleep 1
   echo in > /sys/class/gpio/gpio304/direction
fi
if [ -e "/sys/class/gpio/gpio342" ];then
  echo "GPIO 342 exist"
else 
  echo "GPIO 342 does not exist,make it"
  echo 342 > /sys/class/gpio/export
  sleep 1
  echo in > /sys/class/gpio/gpio342/direction
  sleep 1
  echo out > /sys/class/gpio/gpio342/direction
  sleep 1
  echo 1 > /sys/class/gpio/gpio342/value
fi
rm -rf /home/nvidia/.ros/log/*
rm -rf /root/.ros/log/*
rm -rf /var/log/*
rm -rf /home/nvidia/positec/robot_slam/weeding_robot/src/VIW-Fusion/vins_estimator/viw_result/*
rm -rf /home/nvidia/positec/robot_slam/weeding_robot/src/Global-Sensor-Fusion/fusion_result/*
rm -rf /home/nvidia/positec/robot_slam/weeding_robot/src/LIO-Wheel/Log/programLog/*
/home/nvidia/positec/robot_service/syslog.sh &
jetson_clocks
echo 255 > /sys/devices/pwm-fan/target_pwm
echo 0 > /proc/sys/kernel/printk

bash -c "source /opt/ros/melodic/setup.bash && source /home/nvidia/positec/robot/devel/setup.bash && roslaunch start_robot start_robot.launch;exec bash"

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
git 脚本 bash shell 是一个用于自动化执行 git 操作的脚本,在当前目录下,使用 git pull 命令自动拉取所有 git 仓库的更新。该脚本可以在 Windows 上的 Git Bash 环境中运行,因为 Git Bash 是一个 mingw64 的环境,可以运行 Linux 的大部分命令。 该脚本的实现主要包括以下几个步骤: 1. 定义了一个函数 git_pull_all,该函数用于遍历当前目录下的所有子目录。 2. 在遍历过程中,对每个子目录执行以下操作: a. 切换到当前子目录:cd $cur_dir b. 显示 git 状态:git status c. 清除未跟踪文件和文件夹:git clean -xdf d. 更新子模块:git submodule update --init --force --recursive e. 拉取最新代码:git pull 3. 输出运行结果。 要运行该脚本,只需在 Git Bash 命令行中输入 ./git_pull_all.sh。 请注意,在 Windows 上运行 shell 脚本需要先安装好 Git,并配置好环境。你可以参考提供的教程来进行 Git 的安装和配置。 总结来说,git 脚本 bash shell 是一个用于自动拉取当前目录下所有 git 仓库的脚本,可以在 Windows 的 Git Bash 环境中运行。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [git bash shell 脚本 :自动拉取目录下所有的git 仓库](https://blog.csdn.net/tcjy1000/article/details/124786613)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [dotfiles:Git和bash首选项,以及用于在新笔记本电脑上进行设置的脚本](https://download.csdn.net/download/weixin_42102634/15497989)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [windows使用git bash运行shell脚本](https://blog.csdn.net/Amber__py/article/details/115199391)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值