initial commit

This commit is contained in:
AhmedElsafy 2021-04-06 15:21:30 -03:00
commit e5961a913a
11 changed files with 115 additions and 0 deletions

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# Systemd Services
Services to run on startup
- Radio Listener to tune the cameras, restart TX2 or FCU with a flip of switch on the RC
- ROSCORE start
- MAVROS start
- Camera start
- GPU stereo vision start
- RTSP broadcaster start
# Install
Copy all files inside directory sbin to `/usr/sbin/` then run `sudo chmod +x` for each file after coping
Copy all files inside directory services to /etc/systemd/system/
Copy `env.sh` to `/etc/ros/`then run `sudo chmod +x env.sh`
Enable all services
sudo systemctl enable --now roslaunch
sudo systemctl enable --now ros_radio_listener
sudo systemctl enable --now roscore
sudo systemctl enable --now apriltag
sudo systemctl enable --now camlaunch

4
env.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
export ROS_HOSTNAME=$(hostname).local
export ROS_MASTER_URI=http://$ROS_HOSTNAME:11311
export SERVER_IP=192.168.195.50

7
sbin/apriltaglaunch Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source ~/catkin-ws/devel/setup.bash
source /etc/ros/env.sh
export ROS_HOME=$(echo ~spiri/.ros)
roslaunch apriltag_ros continuous_detection_nodelet.launch __ns:=stereo &
PID=$!
wait "$PID"

7
sbin/camlaunch Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source ~/catkin-ws/devel/setup.bash
source /etc/ros/env.sh
export ROS_HOME=$(echo ~spiri/.ros)
roslaunch jetson_csi_cam video-daylight-nodelet-800x600.launch
PID=$!
wait "$PID"

7
sbin/ros_radio_listener Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source ~/catkin-ws/devel/setup.bash
source /etc/ros/env.sh
export ROS_HOME=$(echo ~spiri/.ros)
roslaunch mavros_fly radio_listener.launch &
PID=$!
wait "$PID"

7
sbin/roslaunch Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source ~/catkin-ws/devel/setup.bash
source /etc/ros/env.sh
export ROS_HOME=$(echo ~spiri/.ros)
roslaunch mavros px4_spiri_avoid.launch &
PID=$!
wait "$PID"

10
service/apriltag.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Requires=camlaunch.service
PartOf=camlaunch.service
After=NetworkManager.service time-sync.target roscore.service camlaunch.service
[Service]
Type=simple
User=spiri
ExecStart=/usr/sbin/apriltaglaunch
[Install]
WantedBy=multi-user.target

10
service/camlaunch.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Requires=roscore.service
PartOf=roscore.service
After=NetworkManager.service time-sync.target roscore.service
[Service]
Type=simple
User=spiri
ExecStart=/usr/sbin/camlaunch
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,10 @@
[Unit]
Requires=roscore.service
PartOf=roscore.service
After=NetworkManager.service time-sync.target roscore.service roslaunch.service
[Service]
Type=simple
User=spiri
ExecStart=/usr/sbin/ros_radio_listener
[Install]
WantedBy=multi-user.target

15
service/roscore.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
After=NetworkManager.service time-sync.target
[Service]
Type=forking
User=spiri
# Start roscore as a fork and then wait for the tcp port to be opened
# —————————————————————-
# Source all the environment variables, start roscore in a fork
# Since the service type is forking, systemd doesnt mark it as
# started until the original process exits, so we have the
# non-forked shell wait until it can connect to the tcp opened by
# roscore, and then exit, preventing conflicts with dependant services
ExecStart=/bin/sh -c ". /opt/ros/melodic/setup.sh; . /etc/ros/env.sh; roscore & while ! echo exit | nc localhost 11311 > /dev/null; do sleep 1; done"
[Install]
WantedBy=multi-user.target

10
service/roslaunch.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Requires=roscore.service
PartOf=roscore.service
After=NetworkManager.service time-sync.target roscore.service
[Service]
Type=simple
User=spiri
ExecStart=/usr/sbin/roslaunch
[Install]
WantedBy=multi-user.target