Skip to content

Commit fad35c7

Browse files
Merge pull request #269 from clearpathrobotics/rc/jazzy/2.8
Jazzy 2.8 Release
2 parents 02714d8 + 3b55f44 commit fad35c7

File tree

10 files changed

+104
-12
lines changed

10 files changed

+104
-12
lines changed

clearpath_generator_common/clearpath_generator_common/bash/generator.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
# modification, is not permitted without the express permission
3333
# of Clearpath Robotics.
3434

35+
from datetime import datetime, UTC
36+
3537
from clearpath_config.common.types.discovery import Discovery
3638
from clearpath_generator_common.bash.writer import BashWriter
3739
from clearpath_generator_common.common import BaseGenerator, BashFile
@@ -48,18 +50,34 @@ def generate_setup_bash(self) -> None:
4850
clearpath_setup_bash = BashFile(filename='setup.bash', path=self.setup_path)
4951
bash_writer = BashWriter(clearpath_setup_bash)
5052

51-
workspaces = self.clearpath_config.system.workspaces
53+
bash_writer.add_comment(f'Bash setup generated at {datetime.now(UTC)}')
54+
55+
# Additional ROS sources
56+
sources = self.clearpath_config.system.bash.additional_sources
57+
envs = self.clearpath_config.system.bash.additional_envars
58+
if len(sources) > 0 or len(envs) > 0:
59+
bash_writer.add_comment('Additional bash configuration from robot.yaml')
60+
for s in sources:
61+
bash_writer.add_source(BashFile(filename=s))
62+
63+
for e in envs:
64+
bash_writer.add_export(e, envs[e])
5265

5366
# Source core ROS
67+
bash_writer.add_comment('Core ROS setup')
5468
ros_setup_bash = BashFile(filename='setup.bash', path=ROS_DISTRO_PATH)
5569
bash_writer.add_source(ros_setup_bash)
5670

5771
# Additional workspaces
58-
for workspace in workspaces:
59-
bash_writer.add_source(
60-
BashFile(filename='setup.bash', path=workspace.strip('setup.bash')))
72+
workspaces = self.clearpath_config.system.workspaces
73+
if len(workspaces) > 0:
74+
bash_writer.add_comment('Additional workspaces')
75+
for workspace in workspaces:
76+
bash_writer.add_source(
77+
BashFile(filename='setup.bash', path=workspace.strip('setup.bash')))
6178

6279
# ROS_DOMAIN_ID
80+
bash_writer.add_comment('ROS configuration')
6381
domain_id = self.clearpath_config.system.domain_id
6482
bash_writer.add_export('ROS_DOMAIN_ID', domain_id)
6583

@@ -87,4 +105,17 @@ def generate_setup_bash(self) -> None:
87105
else:
88106
bash_writer.add_unset('ROS_DISCOVERY_SERVER')
89107

108+
# ROS automatic discovery range
109+
bash_writer.add_export(
110+
'ROS_AUTOMATIC_DISCOVERY_RANGE',
111+
self.clearpath_config.system.middleware.automatic_discovery_range.upper(),
112+
)
113+
if len(self.clearpath_config.system.middleware.static_peers) > 0:
114+
bash_writer.add_export(
115+
'ROS_STATIC_PEERS',
116+
f'"{";".join(self.clearpath_config.system.middleware.static_peers)}"',
117+
)
118+
else:
119+
bash_writer.add_unset('ROS_STATIC_PEERS')
120+
90121
bash_writer.close()

clearpath_generator_common/clearpath_generator_common/bash/writer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ def write(self, string, indent_level=0):
4444
self.file.write(f'{self.tab * indent_level}{string}\n')
4545

4646
def add_export(self, envar: str, value, indent_level=0):
47-
self.write(f'{self.tab * indent_level}export {envar}={value}')
47+
value = str(value)
48+
if (
49+
value.startswith('"') and value.endswith('"')
50+
) or (
51+
value.startswith("'") and value.endswith("'")
52+
):
53+
self.write(f'{self.tab * indent_level}export {envar}={value}')
54+
else:
55+
self.write(f'{self.tab * indent_level}export {envar}="{value}"')
4856

4957
def add_unset(self, envar: str, indent_level=0):
5058
self.write(f'{self.tab * indent_level}unset {envar}')
@@ -55,5 +63,8 @@ def add_source(self, bash_file: BashFile, indent_level=0):
5563
def add_echo(self, msg: str, indent_level=0):
5664
self.write(f'{self.tab * indent_level}echo "{msg}"')
5765

66+
def add_comment(self, msg: str, indent_level=0):
67+
self.write(f'{self.tab * indent_level}# {msg}')
68+
5869
def close(self):
5970
self.file.close()

clearpath_generator_common/clearpath_generator_common/common.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,18 @@ def __add__(self, other):
295295

296296

297297
class BashFile():
298+
"""
299+
A bash file we can source.
300+
301+
:param filename: The name of the file or the absolute path to the file
302+
:param path: The absolute or relative directory containing the file if filename
303+
is not a complete path. package must be specified if path is not absolute
304+
:param package: The ROS package that contains path if it is not absolute
305+
"""
298306

299307
def __init__(self,
300308
filename: str,
301-
path: str,
309+
path: str = None,
302310
package: Package = None,
303311
) -> None:
304312
self.package = package
@@ -310,8 +318,10 @@ def full_path(self):
310318
if self.package:
311319
return os.path.join(
312320
get_package_share_directory(self.package.name), self.path, self.file)
313-
else:
321+
elif self.path:
314322
return os.path.join(self.path, self.file)
323+
else:
324+
return self.file
315325

316326

317327
class BaseGenerator():
@@ -326,7 +336,8 @@ def __init__(self,
326336
setup_path: str = '/etc/clearpath/') -> None:
327337
# Define paths
328338
self.config_path = os.path.join(setup_path, 'robot.yaml')
329-
assert os.path.exists(self.config_path)
339+
if not os.path.exists(self.config_path):
340+
raise FileNotFoundError(f'Config path {self.config_path} does not exist')
330341

331342
self.setup_path = setup_path
332343
self.sensors_params_path = os.path.join(

clearpath_generator_common/clearpath_generator_common/description/manipulators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
# of Clearpath Robotics.
3232
from typing import List
3333

34+
from clearpath_config.common.types.exception import (
35+
UnsupportedAccessoryException,
36+
)
3437
from clearpath_config.manipulators.types.arms import (
3538
BaseArm,
3639
Franka,
@@ -145,7 +148,10 @@ def __init__(self, gripper: FrankaGripper):
145148
class BaseRobotiqGripperDescription(BaseDescription):
146149

147150
def __init__(self, gripper: BaseGripper):
148-
assert isinstance(gripper, Robotiq2F85) or isinstance(gripper, Robotiq2F140)
151+
if not (isinstance(gripper, Robotiq2F85) or isinstance(gripper, Robotiq2F140)):
152+
raise UnsupportedAccessoryException(
153+
f'Gripper must be of type "Robotiq2F85" or "Robotiq2F140", not "{type(gripper)}"' # noqa: E501
154+
)
149155
super().__init__(gripper)
150156
if (gripper.arm.MANIPULATOR_MODEL == KinovaGen3Dof6.MANIPULATOR_MODEL or
151157
gripper.arm.MANIPULATOR_MODEL == KinovaGen3Dof7.MANIPULATOR_MODEL):

clearpath_generator_common/clearpath_generator_common/param/platform.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from clearpath_config.manipulators.types.arms import Franka
4040
from clearpath_config.manipulators.types.grippers import FrankaGripper
4141
from clearpath_config.platform.battery import BatteryConfig
42+
from clearpath_config.platform.wireless import PeplinkRouter
4243
from clearpath_config.sensors.types.cameras import BaseCamera, IntelRealsense
4344
from clearpath_config.sensors.types.gps import BaseGPS, NMEA
4445
from clearpath_config.sensors.types.imu import BaseIMU, PhidgetsSpatial
@@ -369,16 +370,37 @@ def generate_parameters(self, use_sim_time: bool = False) -> None:
369370
}
370371
})
371372

372-
if self.clearpath_config.platform.enable_wireless_watcher:
373+
# We have a few optional nodes that go into the Networking section
374+
# collect them all and then create the aggregator node
375+
networking_contains = []
376+
networking_expected = []
377+
378+
if self.clearpath_config.platform.wireless.enable_wireless_watcher:
379+
networking_contains.append('Wi-Fi')
380+
networking_expected.append('wireless_watcher: Wi-Fi Monitor')
381+
382+
if self.clearpath_config.platform.wireless.router:
383+
if self.clearpath_config.platform.wireless.router == PeplinkRouter.MODEL:
384+
networking_contains.append('Router')
385+
networking_expected.append('router_node: Router')
386+
# Put additional supported router hardware here...
387+
388+
if self.clearpath_config.platform.wireless.base_station:
389+
if self.clearpath_config.platform.wireless.base_station == PeplinkRouter.MODEL:
390+
networking_contains.append('Base Station')
391+
networking_expected.append('base_station_node: Base Station')
392+
# Put additional supported base station hardware here...
393+
394+
if len(networking_contains) > 0:
373395
self.param_file.update({
374396
self.DIAGNOSTIC_AGGREGATOR_NODE: {
375397
'platform': {
376398
'analyzers': {
377399
'networking': {
378400
'type': 'diagnostic_aggregator/GenericAnalyzer',
379401
'path': 'Networking',
380-
'contains': ['Wi-Fi'],
381-
'expected': ['wireless_watcher: Wi-Fi Monitor']
402+
'contains': networking_contains,
403+
'expected': networking_expected,
382404
}
383405
}
384406
}

clearpath_generator_common/package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<exec_depend version_gte="2.5.0">clearpath_diagnostics</exec_depend>
2121
<exec_depend version_gte="2.5.0">clearpath_manipulators</exec_depend>
2222

23+
<exec_depend>python3-apt</exec_depend>
24+
2325
<test_depend>ament_lint_auto</test_depend>
2426
<test_depend>ament_lint_common</test_depend>
2527
<test_depend>ament_cmake_pytest</test_depend>

clearpath_generator_common/test/test_generator_bash.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_samples(self):
5757
print(f'Unsupported accessory: {e}. Skipping')
5858
except UnsupportedPlatformException as e:
5959
print(f'Unsupported platform: {e}. Skipping')
60+
except FileNotFoundError as e:
61+
print(f'File not found: {e}. Skipping')
6062
except Exception as e:
6163
errors.append("Sample '%s' failed to load: '%s'" % (
6264
sample,

clearpath_generator_common/test/test_generator_description.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def test_samples(self):
6262
except UnsupportedPlatformException as e:
6363
print(f'Unsupported platform. {e}. Skipping')
6464
continue
65+
except FileNotFoundError as e:
66+
print(f'File not found: {e}. Skipping')
67+
continue
6568
except Exception as e:
6669
errors.append("Sample '%s' failed to load: '%s'" % (
6770
sample,

clearpath_generator_common/test/test_generator_discovery_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_samples(self):
5757
print(f'Unsupported accessory. {e}')
5858
except UnsupportedPlatformException as e:
5959
print(f'Unsupported platform. {e}')
60+
except FileNotFoundError as e:
61+
print(f'File not found: {e}. Skipping')
6062
except Exception as e:
6163
errors.append("Sample '%s' failed to load: '%s'" % (
6264
sample,

clearpath_generator_common/test/test_generator_vcan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def test_samples(self):
5555
print(f'Unsupported accessory: {e}. Skipping')
5656
except UnsupportedPlatformException as e:
5757
print(f'Unsupported platform: {e}. Skipping')
58+
except FileNotFoundError as e:
59+
print(f'File not found: {e}. Skipping')
5860
except Exception as e:
5961
errors.append("Sample '%s' failed to load: '%s'" % (
6062
sample,

0 commit comments

Comments
 (0)