add services
This commit is contained in:
0
drone_scripts/TerabeeLog.log
Normal file
0
drone_scripts/TerabeeLog.log
Normal file
32
drone_scripts/find_id.sh
Executable file
32
drone_scripts/find_id.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
lidarserial=00000000001A
|
||||||
|
heightserial=369A378F3439
|
||||||
|
|
||||||
|
find_by_id(){
|
||||||
|
v=${1%:*}; p=${1#*:} # split vid:pid into 2 vars
|
||||||
|
v=${v#${v%%[!0]*}}; p=${p#${p%%[!0]*}} # strip leading zeros
|
||||||
|
grep -il "^PRODUCT=$v/$p" /sys/bus/usb/devices/*:*/uevent |
|
||||||
|
sed s,uevent,, |
|
||||||
|
xargs -r grep -r '^DEVNAME=' --include uevent
|
||||||
|
}
|
||||||
|
ids=$(find_by_id 0483:5740)
|
||||||
|
echo $ids
|
||||||
|
|
||||||
|
for device in $ids
|
||||||
|
do
|
||||||
|
id=$(echo $device | cut -d "=" -f 2)
|
||||||
|
serial=$(/bin/udevadm info --name=/dev/$id | grep SERIAL_SHORT | cut -d = -f 2)
|
||||||
|
echo "device "$id" has serial number "$serial
|
||||||
|
if [ $serial = $lidarserial ]
|
||||||
|
then
|
||||||
|
echo "LIDAR on port" $id
|
||||||
|
echo $id > /home/ubuntu/drone_conf/lidar.conf
|
||||||
|
elif [ $serial = $heightserial ]
|
||||||
|
then
|
||||||
|
echo "height sensor on port" $id
|
||||||
|
echo $id > /home/ubuntu/drone_conf/height.conf
|
||||||
|
else
|
||||||
|
echo "unknown serial number" $serial
|
||||||
|
fi
|
||||||
|
done
|
||||||
10
drone_scripts/start_height_sensor.sh
Executable file
10
drone_scripts/start_height_sensor.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /home/ubuntu/source_ros2.sh
|
||||||
|
|
||||||
|
SERIAL=$(cat /home/ubuntu/drone_conf/height.conf)
|
||||||
|
echo "serial port is "$SERIAL
|
||||||
|
echo ros2 run height height_reader --ros-args -p height_serial_port:=/dev/${SERIAL}
|
||||||
|
ros2 run height height_reader --ros-args -p height_serial_port:=/dev/${SERIAL} | tee /home/ubuntu/drone_log/height.log
|
||||||
|
|
||||||
|
|
||||||
10
drone_scripts/start_lidar.sh
Executable file
10
drone_scripts/start_lidar.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /home/ubuntu/source_ros2.sh
|
||||||
|
|
||||||
|
SERIAL=$(cat /home/ubuntu/drone_conf/lidar.conf)
|
||||||
|
echo "serial port is "$SERIAL
|
||||||
|
echo ros2 run object_detection lidar_reader --ros-args -p lidar_serial_port:=/dev/${SERIAL}
|
||||||
|
ros2 run object_detection lidar_reader --ros-args -p lidar_serial_port:=/dev/${SERIAL} | tee /home/ubuntu/drone_log/lidar.log
|
||||||
|
|
||||||
|
|
||||||
1
get_usb_device_port.sh
Normal file
1
get_usb_device_port.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/bin/udevadm info --name=/dev/ttyACM0 | grep SERIAL_SHORT | cut -d = -f 2
|
||||||
12
services/drone_find_usb_devices.service
Normal file
12
services/drone_find_usb_devices.service
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Service to start the script that sets the serial ports for the USB sensors
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
User=ubuntu
|
||||||
|
ExecStart=/home/ubuntu/drone_scripts/find_id.sh
|
||||||
|
WorkingDirectory=/home/ubuntu
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
14
services/drone_height_sensor.service
Normal file
14
services/drone_height_sensor.service
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Height sensor for drone running in ROS 2
|
||||||
|
After=drone_find_usb_devices.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
User=ubuntu
|
||||||
|
ExecStart=/home/ubuntu/drone_scripts/start_height_sensor.sh
|
||||||
|
Environment="HOME=root"
|
||||||
|
WorkingDirectory=/home/ubuntu
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
14
services/drone_lidar.service
Normal file
14
services/drone_lidar.service
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Height sensor for drone running in ROS 2
|
||||||
|
After=drone_find_usb_devices.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
User=ubuntu
|
||||||
|
ExecStart=/home/ubuntu/drone_scripts/start_lidar.sh
|
||||||
|
Environment="HOME=root"
|
||||||
|
WorkingDirectory=/home/ubuntu
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Submodule src/px4_msgs updated: b64ef0475c...ffc3a4cd57
Reference in New Issue
Block a user