Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added discovery server service #48

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Expand Down
50 changes: 45 additions & 5 deletions clearpath_robot/scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
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

Expand Down
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
Expand Down
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

Expand Down
Loading