输入脚本文件
#!/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"