diff --git a/clearpath_robot/scripts/generate b/clearpath_robot/scripts/generate index d1628ec..6cc368c 100644 --- a/clearpath_robot/scripts/generate +++ b/clearpath_robot/scripts/generate @@ -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 diff --git a/clearpath_robot/scripts/install b/clearpath_robot/scripts/install index 7552ab8..e578e28 100755 --- a/clearpath_robot/scripts/install +++ b/clearpath_robot/scripts/install @@ -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) diff --git a/clearpath_robot/services/clearpath-discovery.service b/clearpath_robot/services/clearpath-discovery.service new file mode 100644 index 0000000..78b1bb2 --- /dev/null +++ b/clearpath_robot/services/clearpath-discovery.service @@ -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 diff --git a/clearpath_robot/services/clearpath-platform.service b/clearpath_robot/services/clearpath-platform.service index 457a62b..7884546 100755 --- a/clearpath_robot/services/clearpath-platform.service +++ b/clearpath_robot/services/clearpath-platform.service @@ -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 diff --git a/clearpath_robot/services/clearpath-robot.service b/clearpath_robot/services/clearpath-robot.service index 36c6061..d33733a 100644 --- a/clearpath_robot/services/clearpath-robot.service +++ b/clearpath_robot/services/clearpath-robot.service @@ -1,5 +1,5 @@ [Unit] -Description=Application +Description="Clearpath robot main generation and bringup service" [Service] User=administrator diff --git a/clearpath_robot/services/clearpath-sensors.service b/clearpath_robot/services/clearpath-sensors.service index 2fe9afa..d6beda3 100755 --- a/clearpath_robot/services/clearpath-sensors.service +++ b/clearpath_robot/services/clearpath-sensors.service @@ -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