-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from clearpathrobotics/dependency_rework
Dependency rework
- Loading branch information
Showing
56 changed files
with
849 additions
and
7,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(clearpath_generator_robot) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(ament_cmake_python REQUIRED) | ||
|
||
install(PROGRAMS | ||
${PROJECT_NAME}/launch/generate_launch | ||
${PROJECT_NAME}/param/generate_param | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
ament_python_install_package(${PROJECT_NAME}) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# comment the line when a copyright and license is added to all source files | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# comment the line when this package is in a git repo and when | ||
# a copyright and license is added to all source files | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() |
Empty file.
31 changes: 31 additions & 0 deletions
31
clearpath_generator_robot/clearpath_generator_robot/launch/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Software License Agreement (BSD) | ||
# | ||
# @author Roni Kreinin <[email protected]> | ||
# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# * Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# * Neither the name of Clearpath Robotics nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Redistribution and use in source and binary forms, with or without | ||
# modification, is not permitted without the express permission | ||
# of Clearpath Robotics. |
46 changes: 46 additions & 0 deletions
46
clearpath_generator_robot/clearpath_generator_robot/launch/generate_launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Software License Agreement (BSD) | ||
# | ||
# @author Roni Kreinin <[email protected]> | ||
# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# * Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# * Neither the name of Clearpath Robotics nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Redistribution and use in source and binary forms, with or without | ||
# modification, is not permitted without the express permission | ||
# of Clearpath Robotics. | ||
|
||
from clearpath_generator_common.common import BaseGenerator | ||
from clearpath_generator_robot.launch.generator import RobotLaunchGenerator | ||
|
||
|
||
def main(): | ||
setup_path = BaseGenerator.get_args() | ||
rlg = RobotLaunchGenerator(setup_path) | ||
rlg.generate() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
125 changes: 125 additions & 0 deletions
125
clearpath_generator_robot/clearpath_generator_robot/launch/generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Software License Agreement (BSD) | ||
# | ||
# @author Roni Kreinin <[email protected]> | ||
# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# * Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# * Neither the name of Clearpath Robotics nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Redistribution and use in source and binary forms, with or without | ||
# modification, is not permitted without the express permission | ||
# of Clearpath Robotics. | ||
|
||
from clearpath_generator_common.common import LaunchFile, Package | ||
from clearpath_generator_common.launch.writer import LaunchWriter | ||
from clearpath_generator_common.launch.generator import LaunchGenerator | ||
from clearpath_generator_robot.launch.sensors import SensorLaunch | ||
|
||
from clearpath_config.platform.platform import Platform | ||
|
||
import os | ||
|
||
|
||
class RobotLaunchGenerator(LaunchGenerator): | ||
def generate_sensors(self) -> None: | ||
sensors_service_launch_writer = LaunchWriter(self.sensors_service_launch_file) | ||
sensors = self.clearpath_config.sensors.get_all_sensors() | ||
|
||
for sensor in sensors: | ||
if sensor.get_launch_enabled(): | ||
sensor_launch = SensorLaunch( | ||
sensor, | ||
self.sensors_launch_path, | ||
self.sensors_params_path) | ||
sensor_writer = LaunchWriter(sensor_launch.get_launch_file()) | ||
# Add default sensor launch file | ||
sensor_writer.add_launch_file(sensor_launch.get_default_launch_file()) | ||
# Generate sensor launch file | ||
sensor_writer.generate_file() | ||
# Add sensor to top level sensors launch file | ||
sensors_service_launch_writer.add_launch_file(sensor_launch.get_launch_file()) | ||
|
||
sensors_service_launch_writer.generate_file() | ||
|
||
def generate_platform(self) -> None: | ||
platform_service_launch_writer = LaunchWriter(self.platform_service_launch_file) | ||
platform_service_launch_writer.add_launch_file(self.platform_launch_file) | ||
|
||
if self.platform_model == Platform.J100: | ||
# Add micro ros agent | ||
uros_node = LaunchFile.Node( | ||
name='micro_ros_agent', | ||
package='micro_ros_agent', | ||
executable='micro_ros_agent', | ||
arguments=[ | ||
'serial', '--dev', '/dev/clearpath/j100' | ||
]) | ||
platform_service_launch_writer.add_node(uros_node) | ||
|
||
# Set domain ID on MCU | ||
set_domain_id = LaunchFile.Process( | ||
name='set_domain_id', | ||
cmd=[ | ||
['\'export ROS_DOMAIN_ID=0;\''], | ||
['FindExecutable(name=\'ros2\')', | ||
'\' service call platform/mcu/set_domain_id \'', | ||
'\' clearpath_platform_msgs/srv/SetDomainId \'', | ||
'\'"domain_id: \'', | ||
'EnvironmentVariable(\'ROS_DOMAIN_ID\', default_value=\'0\')', | ||
'\'"\''] | ||
]) | ||
platform_service_launch_writer.add_process(set_domain_id) | ||
|
||
# IMU filter | ||
imu_filter_config = LaunchFile.LaunchArg( | ||
'imu_filter', | ||
default_value=os.path.join(self.platform_params_path, 'imu_filter.yaml') | ||
) | ||
platform_service_launch_writer.declare_launch_arg(imu_filter_config) | ||
|
||
imu_filter_node = LaunchFile.Node( | ||
package='imu_filter_madgwick', | ||
executable='imu_filter_madgwick_node', | ||
name='imu_filter_node', | ||
parameters=['imu_filter'], | ||
remappings=[ | ||
('\'imu/data_raw\'', '\'platform/sensors/imu_0/data_raw\''), | ||
('\'imu/mag\'', '\'platform/sensors/imu_0/magnetic_field\''), | ||
('\'imu/data\'', '\'platform/sensors/imu_0/data\'') | ||
], | ||
) | ||
platform_service_launch_writer.add_node(imu_filter_node) | ||
|
||
# Wireless watcher | ||
wireless_watcher_launch = LaunchFile( | ||
name='watcher', | ||
package=Package('wireless_watcher'), | ||
args={ | ||
'connected_topic': 'platform/wifi_connected' | ||
} | ||
) | ||
platform_service_launch_writer.add_launch_file(wireless_watcher_launch) | ||
|
||
platform_service_launch_writer.generate_file() |
107 changes: 107 additions & 0 deletions
107
clearpath_generator_robot/clearpath_generator_robot/launch/sensors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Software License Agreement (BSD) | ||
# | ||
# @author Roni Kreinin <[email protected]> | ||
# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# * Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# * Neither the name of Clearpath Robotics nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Redistribution and use in source and binary forms, with or without | ||
# modification, is not permitted without the express permission | ||
# of Clearpath Robotics. | ||
|
||
from clearpath_config.sensors.base import BaseSensor | ||
from clearpath_config.sensors.lidars_2d import BaseLidar2D, HokuyoUST10, SickLMS1XX | ||
from clearpath_config.sensors.lidars_3d import BaseLidar3D, VelodyneLidar | ||
from clearpath_config.sensors.cameras import BaseCamera, IntelRealsense | ||
from clearpath_config.sensors.imu import BaseIMU, Microstrain | ||
from clearpath_config.sensors.gps import BaseGPS, SwiftNavDuro | ||
|
||
from clearpath_generator_common.common import LaunchFile, Package, ParamFile | ||
|
||
|
||
class SensorLaunch(): | ||
class BaseLaunch(): | ||
CLEARPATH_SENSORS = 'clearpath_sensors' | ||
TOPIC_NAMESPACE = 'platform/sensors/' | ||
|
||
# Launch arguments | ||
PARAMETERS = 'parameters' | ||
NAMESPACE = 'namespace' | ||
|
||
def __init__(self, sensor: BaseSensor, | ||
launch_path: str, | ||
param_path: str) -> None: | ||
self.sensor = sensor | ||
self.parameters = ParamFile(self.get_name(), path=param_path) | ||
# Defaults | ||
self.default_sensor_package = Package(self.CLEARPATH_SENSORS) | ||
|
||
# Generated | ||
self.sensor_launch_file = LaunchFile( | ||
self.get_name(), | ||
path=launch_path) | ||
|
||
self.launch_args = { | ||
self.PARAMETERS: self.parameters.get_full_path(), | ||
self.NAMESPACE: self.get_namespace() | ||
} | ||
|
||
# Set launch args for default launch file | ||
self.default_sensor_launch_file = LaunchFile( | ||
self.get_model(), | ||
package=self.default_sensor_package, | ||
args=self.launch_args) | ||
|
||
def get_launch_file(self) -> LaunchFile: | ||
return self.sensor_launch_file | ||
|
||
def get_default_launch_file(self) -> LaunchFile: | ||
return self.default_sensor_launch_file | ||
|
||
def get_name(self) -> str: | ||
return self.sensor.get_name() | ||
|
||
def get_model(self) -> str: | ||
return self.sensor.SENSOR_MODEL | ||
|
||
def get_default_sensor_package(self) -> str: | ||
return self.default_sensor_package | ||
|
||
def get_launch_args(self) -> dict: | ||
return self.launch_args | ||
|
||
def get_namespace(self) -> str: | ||
return self.TOPIC_NAMESPACE + self.sensor.get_name() | ||
|
||
MODEL = { | ||
HokuyoUST10.SENSOR_MODEL: BaseLaunch, | ||
SickLMS1XX.SENSOR_MODEL: BaseLaunch, | ||
IntelRealsense.SENSOR_MODEL: BaseLaunch, | ||
Microstrain.SENSOR_MODEL: BaseLaunch, | ||
VelodyneLidar.SENSOR_MODEL: BaseLaunch, | ||
SwiftNavDuro.SENSOR_MODEL: BaseLaunch | ||
} | ||
|
||
def __new__(cls, sensor: BaseSensor, launch_path: str, param_path: str) -> BaseLaunch: | ||
return SensorLaunch.MODEL[sensor.SENSOR_MODEL](sensor, launch_path, param_path) |
Empty file.
46 changes: 46 additions & 0 deletions
46
clearpath_generator_robot/clearpath_generator_robot/param/generate_param
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Software License Agreement (BSD) | ||
# | ||
# @author Roni Kreinin <[email protected]> | ||
# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# * Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# * Neither the name of Clearpath Robotics nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Redistribution and use in source and binary forms, with or without | ||
# modification, is not permitted without the express permission | ||
# of Clearpath Robotics. | ||
|
||
from clearpath_generator_common.common import BaseGenerator | ||
from clearpath_generator_robot.param.generator import RobotParamGenerator | ||
|
||
|
||
def main(): | ||
setup_path = BaseGenerator.get_args() | ||
rpg = RobotParamGenerator(setup_path) | ||
rpg.generate() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.