Skip to content

Commit

Permalink
Merge pull request #48 from clearpathrobotics/discovery-server
Browse files Browse the repository at this point in the history
Added discovery server service
luis-camero authored Mar 8, 2024
2 parents 37e344d + 2c1f544 commit c22596f
Showing 6 changed files with 66 additions and 8 deletions.
4 changes: 4 additions & 0 deletions clearpath_robot/scripts/generate
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash
source /opt/ros/humble/setup.bash

# Generate and source setup.bash
ros2 run clearpath_generator_common generate_bash
source /etc/clearpath/setup.bash

# Generate discovery server start file
ros2 run clearpath_generator_common generate_discovery_server

# Generate description
ros2 run clearpath_generator_common generate_description

50 changes: 45 additions & 5 deletions clearpath_robot/scripts/install
Original file line number Diff line number Diff line change
@@ -58,7 +58,11 @@ class PlatformProvider(robot_upstart.providers.Generic):
"/lib/systemd/system/clearpath-platform.service": {
"content": platform_service_contents,
"mode": 0o644
}}
},
"/etc/systemd/system/clearpath-robot.service.wants/clearpath-platform.service": {
"symlink": "/lib/systemd/system/clearpath-platform.service"
}
}


class SensorsProvider(robot_upstart.providers.Generic):
@@ -81,7 +85,39 @@ class SensorsProvider(robot_upstart.providers.Generic):
"/lib/systemd/system/clearpath-sensors.service": {
"content": sensors_service_contents,
"mode": 0o644
}}
},
"/etc/systemd/system/clearpath-robot.service.wants/clearpath-sensors.service": {
"symlink": "/lib/systemd/system/clearpath-sensors.service"
}
}


class DiscoveryServerProvider(robot_upstart.providers.Generic):
def post_install(self):
pass

def generate_install(self):
discovery_service_path = os.path.join(
get_package_share_directory('clearpath_robot'),
'services/clearpath-discovery.service')
with open(discovery_service_path) as f:
discovery_service_contents: str = ''
discovery_service_lines = f.readlines()
for line in discovery_service_lines:
# Replace User with username from config
if 'User=' in line:
line = 'User={0}\n'.format(clearpath_config.system.username)
discovery_service_contents += line

return {
"/lib/systemd/system/clearpath-discovery.service": {
"content": discovery_service_contents,
"mode": 0o644
},
"/etc/systemd/system/clearpath-robot.service.wants/clearpath-discovery.service": {
"symlink": "/lib/systemd/system/clearpath-discovery.service"
}
}


class RobotProvider(robot_upstart.providers.Generic):
@@ -123,8 +159,8 @@ class RobotProvider(robot_upstart.providers.Generic):
"/usr/sbin/clearpath-robot-check": {
"content": robot_service_exec_contents,
"mode": 0o755
},
}
}
}


setup_path = BaseGenerator.get_args()
@@ -146,7 +182,7 @@ config = read_yaml(config_path)
# Parse YAML into config
clearpath_config = ClearpathConfig(config)

rmw = clearpath_config.system.rmw_implementation
rmw = clearpath_config.system.middleware.rmw_implementation
domain_id = clearpath_config.system.domain_id

# Platform
@@ -175,6 +211,10 @@ sensors.install()
sensors_extras = robot_upstart.Job(workspace_setup=workspace_setup)
sensors_extras.install(Provider=SensorsProvider)

# Discovery Server
discovery_server = robot_upstart.Job(workspace_setup=workspace_setup)
discovery_server.install(Provider=DiscoveryServerProvider)

# Robot
robot = robot_upstart.Job(workspace_setup=workspace_setup)
robot.install(Provider=RobotProvider)
14 changes: 14 additions & 0 deletions clearpath_robot/services/clearpath-discovery.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description="Clearpath FastDDS discovery server"
PartOf=clearpath-robot.service
After=clearpath-robot.service

[Service]
User=administrator
Type=simple
Restart=on-failure
RestartSec=1
ExecStart=/bin/bash -e /etc/clearpath/discovery-server-start

[Install]
WantedBy=clearpath-robot.service
2 changes: 1 addition & 1 deletion clearpath_robot/services/clearpath-platform.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description="bringup clearpath-platform"
Description="Clearpath robot sub-service, launch all platform nodes"
PartOf=clearpath-robot.service
After=clearpath-robot.service

2 changes: 1 addition & 1 deletion clearpath_robot/services/clearpath-robot.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=Application
Description="Clearpath robot main generation and bringup service"

[Service]
User=administrator
2 changes: 1 addition & 1 deletion clearpath_robot/services/clearpath-sensors.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description="bringup clearpath-sensors"
Description="Clearpath robot sub-service, launch all sensor nodes"
PartOf=clearpath-robot.service
After=clearpath-robot.service

0 comments on commit c22596f

Please sign in to comment.