コード例 #1
0
def generate_launch_description():
    executable = "executable" if ROS_DISTRO == ROS_DISTRO_FOXY else "node_executable"
    pkg_share = get_package_share_directory("tennis_court")
    gazebo_ros_share = get_package_share_directory("gazebo_ros")

    # Gazebo Server
    gzserver_launch_file = os.path.join(gazebo_ros_share, "launch",
                                        "gzserver.launch.py")
    world_file = os.path.join(pkg_share, "worlds", "court.world")
    gzserver_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(gzserver_launch_file),
        launch_arguments={
            "world": world_file,
            "verbose": "false",
            "pause": LaunchConfiguration("paused")
        }.items())

    # Gazebo Client
    gzclient_launch_file = os.path.join(gazebo_ros_share, "launch",
                                        "gzclient.launch.py")
    gzclient_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(gzclient_launch_file),
        condition=IfCondition(LaunchConfiguration("gui")))

    static_tf_node = Node(package="tf2_ros",
                          arguments=[
                              "0", "0", "8", "3.14159", "1.57079", "3.14159",
                              "map", "zenith_camera_link"
                          ],
                          **{executable: "static_transform_publisher"})

    # Ball Manager
    ball_manager_node = Node(package="tennis_court",
                             condition=IfCondition(
                                 LaunchConfiguration("manager")),
                             parameters=[{
                                 "use_sim_time": True
                             }],
                             output="screen",
                             emulate_tty=True,
                             **{executable: "ball_manager.py"})

    # Rviz
    rviz_config_file = os.path.join(pkg_share, "config", "config.rviz")
    rviz_node = Node(package="rviz2",
                     arguments=["-d", rviz_config_file],
                     condition=IfCondition(LaunchConfiguration("rviz")),
                     parameters=[{
                         "use_sim_time": True
                     }],
                     **{executable: "rviz2"})

    return LaunchDescription([
        DeclareLaunchArgument(name="gui", default_value="true"),
        DeclareLaunchArgument(name="paused", default_value="false"),
        DeclareLaunchArgument(name="rviz", default_value="false"),
        DeclareLaunchArgument(name="manager",
                              default_value="true"), gzserver_launch,
        gzclient_launch, static_tf_node, ball_manager_node, rviz_node
    ])
コード例 #2
0
def generate_launch_description():
    """Launch euclidean cluster and ray ground classifier nodes."""
    # euclidean cluster parameter file definition.
    vlp16_lexus_cluster_file_path = os.path.join(
        get_package_share_directory('euclidean_cluster_nodes'), 'param',
        'vlp16_lexus_cluster.param.yaml')
    euclidean_cluster_param_file = launch.substitutions.LaunchConfiguration(
        'params', default=[vlp16_lexus_cluster_file_path])

    # ray ground classifier parameter file definition.
    vlp16_lexus_ray_ground_file_path = os.path.join(
        get_package_share_directory('ray_ground_classifier_nodes'), 'param',
        'vlp16_lexus.param.yaml')
    ray_ground_param_file = launch.substitutions.LaunchConfiguration(
        'params', default=[vlp16_lexus_ray_ground_file_path])

    # euclidean cluster node execution definition.
    euclidean_cluster_node_runner = launch_ros.actions.Node(
        package='euclidean_cluster_nodes',
        node_executable='euclidean_cluster_node_exe',
        parameters=[euclidean_cluster_param_file],
        remappings=[("points_clustered", "cluster_points")])

    # ros1 bridge runner definition.
    ray_ground_runner = launch_ros.actions.Node(
        package='ray_ground_classifier_nodes',
        node_executable='ray_ground_classifier_cloud_node_exe',
        parameters=[ray_ground_param_file],
        remappings=[("points_in", "lidar_front/points_filtered")])

    return launch.LaunchDescription(
        [euclidean_cluster_node_runner, ray_ground_runner])
コード例 #3
0
def test_get_package_share_directory():
    set_ament_prefix_path(['prefix1', 'prefix2'])

    def get_package_share_directory_test(package_name, expect_prefix):
        full_share_dir = get_package_share_directory(package_name)
        left_over, dirname = os.path.split(full_share_dir)
        assert dirname == package_name, "Expected package name '{}'".format(
            package_name)
        left_over, dirname = os.path.split(left_over)
        assert dirname == 'share', "Expected 'share'"
        left_over, dirname = os.path.split(left_over)
        assert dirname == expect_prefix, "Expected '{}'".format(expect_prefix)

    get_package_share_directory_test('foo', 'prefix1')
    # found in both prefix1 and prefix2, but prefix1 is ahead on the APP
    get_package_share_directory_test('bar', 'prefix1')
    get_package_share_directory_test('baz', 'prefix2')

    try:
        get_package_share_directory('does_not_exist')
    except PackageNotFoundError:
        pass
    except Exception as exc:
        assert False, 'Expected PackageNotFoundError, got: {}'.format(
            type(exc))
コード例 #4
0
 def setUpClass(cls):
     cls.robot = urdf.Robot.from_xml_file(
         get_package_share_directory("march_description") +
         "/urdf/march6.urdf")
     cls.gait_directory = os.path.join(
         get_package_share_directory(VALID_PACKAGE), VALID_DIRECTORY)
     cls.gait_selection = GaitSelection(gait_package=VALID_PACKAGE,
                                        directory=VALID_DIRECTORY,
                                        robot=cls.robot)
コード例 #5
0
def generate_launch_description():

    map_data_prefix = get_package_share_directory('autoware_auto_avp_demo')

    # map_provider parameter file definition
    ndt_map_provider_file_path = os.path.join(map_data_prefix, "param",
                                              "map_publisher.param.yaml")
    map_provider_param_file = LaunchConfiguration(
        "params", default=[ndt_map_provider_file_path])

    # map provide map file arguments
    map_yaml_file_path = os.path.join(
        map_data_prefix, "data/autonomoustuff_parking_lot_lgsvl.yaml")
    map_pcd_file_path = os.path.join(
        map_data_prefix, "data/autonomoustuff_parking_lot_lgsvl.pcd")
    map_yaml_file_param = DeclareLaunchArgument(
        'map_yaml_file_arg',
        default_value=map_yaml_file_path,
        description='Map YAML file describing map origin')
    map_pcd_file_param = DeclareLaunchArgument(
        'map_pcd_file_arg',
        default_value=map_pcd_file_path,
        description='Map PCD file containing 3D point cloud data')

    # map_provide node execution definition
    map_provider_node_runner = launch_ros.actions.Node(
        package="ndt_nodes",
        node_executable="ndt_map_publisher_exe",
        node_namespace="localization",
        parameters=[
            map_provider_param_file, {
                "map_yaml_file": LaunchConfiguration('map_yaml_file_arg')
            }, {
                "map_pcd_file": LaunchConfiguration('map_pcd_file_arg')
            }
        ])

    # map downsampler paramter file definition
    ndt_map_downsampler_file_path = os.path.join(
        get_package_share_directory('ndt_nodes'), 'param',
        'pcl_map_voxel_grid_downsample.param.yaml')
    map_downsampler_param_file = launch.substitutions.LaunchConfiguration(
        'params', default=[ndt_map_downsampler_file_path])

    # map downsample node execution definition
    map_downsampler_node_runner = launch_ros.actions.Node(
        package='voxel_grid_nodes',
        node_executable='voxel_grid_node_exe',
        parameters=[map_downsampler_param_file],
        remappings=[("points_in", "viz_ndt_map"),
                    ("points_downsampled", "viz_ndt_map_downsampled")])

    # require a map file location
    return launch.LaunchDescription([
        map_yaml_file_param, map_pcd_file_param, map_provider_node_runner,
        map_downsampler_node_runner
    ])
コード例 #6
0
def generate_test_description(ready_fn):
    PORT = lidar_integration.get_open_port()

    # The nodes under test:
    velodyne_block_node = launch_ros.actions.Node(
        package="velodyne_node",
        node_executable="velodyne_cloud_node_exe",
        node_name="vlp16_test_node",
        node_namespace="lidar_front",
        parameters=[
            os.path.join(
                ament_index_python.get_package_share_directory("velodyne_node"),
                "vlp16_test.param.yaml"
            ),
            {
                "port": PORT,
            }
        ]
    )

    point_cloud_filter_transform_node = launch_ros.actions.Node(
        package="point_cloud_filter_transform_nodes",
        node_executable="point_cloud_filter_transform_node_exe",
        node_name="point_cloud_filter_transform_node",
        node_namespace="lidar_front",
        parameters=[
            os.path.join(
                ament_index_python.get_package_share_directory(
                    "point_cloud_filter_transform_nodes"),
                "param",
                "test.param.yaml"
            ),
            {
                "expected_num_ground_subscribers": 1,
                "expected_num_nonground_subscribers": 1,
            }
        ],
        remappings=[("points_in", "points_raw")]
    )

    filtered_points_checker = lidar_integration.make_pcl_checker(
        topic="points_filtered",
        size=16930,
        period=100,
        period_tolerance=1.0
    )

    return lidar_integration.get_lidar_launch_description(
        test_nodes=[velodyne_block_node, point_cloud_filter_transform_node],
        checkers=[filtered_points_checker],
        other_actions=[
            launch.actions.OpaqueFunction(function=lambda context: ready_fn())
        ],
        port=PORT
    )
コード例 #7
0
 def setUp(self):
     self.robot = urdf.Robot.from_xml_file(
         get_package_share_directory("march_description") + "/urdf/march6.urdf"
     )
     self.gait_directory = os.path.join(
         get_package_share_directory(TEST_PACKAGE), TEST_DIRECTORY
     )
     self.gait_selection = GaitSelection(
         gait_package=TEST_PACKAGE, directory=TEST_DIRECTORY, robot=self.robot
     )
     self.load_realsense_gaits()
def generate_launch_description():

    default_vehicle_characteristics_param = os.path.join(
        get_package_share_directory('simple_planning_simulator'),
        'param/vehicle_characteristics.param.param.yaml')

    vehicle_characteristics_param = DeclareLaunchArgument(
        'vehicle_characteristics_param_file',
        default_value=default_vehicle_characteristics_param,
        description='Path to config file for vehicle characteristics'
    )

    simple_planning_simulator_node = launch_ros.actions.Node(
        package='simple_planning_simulator',
        executable='simple_planning_simulator_exe',
        name='simple_planning_simulator',
        namespace='simulation',
        output='screen',
        parameters=[
            "{}/param/simple_planning_simulator_default.param.yaml".format(
                ament_index_python.get_package_share_directory(
                    "simple_planning_simulator"
                )
            ),
            LaunchConfiguration('vehicle_characteristics_param_file'),
        ],
        remappings=[
            ('input/vehicle_control_command', '/vehicle/vehicle_command'),
            ('input/ackermann_control_command', '/control/command/control_cmd'),
            ('input/gear_command', '/control/command/gear_cmd'),
            ('input/trajectory', '/planning/scenario_planning/trajectory'),
            ('output/twist', '/vehicle/status/velocity_status'),
            ('output/odometry', '/localization/kinematic_state'),
            ('output/steering', '/vehicle/status/steering_status'),
            ('output/gear_report', '/vehicle/status/gear_status'),
            ('output/control_mode_report', '/vehicle/status/control_mode'),
            ('/initialpose', '/initialpose'),
        ]
    )

    map_to_odom_tf_publisher = launch_ros.actions.Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        name='static_map_to_odom_tf_publisher',
        output='screen',
        arguments=['0.0', '0.0', '0.0', '0', '0', '0', 'map', 'odom'])

    ld = launch.LaunchDescription([
        vehicle_characteristics_param,
        simple_planning_simulator_node,
        map_to_odom_tf_publisher
    ])
    return ld
コード例 #9
0
def generate_test_description(ready_fn):
    # The node under test and the checker node that will pass/fail our tests:
    test_topic = "veloyne_cloud_node_test_topic"
    velodyne_cloud_node = launch_ros.actions.LifecycleNode(
        package="velodyne_node",
        node_executable="velodyne_cloud_node_exe",
        node_name="vlp16_driver_node",
        node_namespace="lidar_front",
        parameters=[
            "{}/param/vlp16_test.param.yaml".format(
                ament_index_python.get_package_share_directory("velodyne_node")
            ),
            {
                "cloud_size": 500,
                "topic": test_topic
            }
        ],
        arguments=["--model", "vlp16"]
    )

    context = {'vel_node': velodyne_cloud_node}

    return launch.LaunchDescription([
        ROSSpecificLaunchStartup(),
        velodyne_cloud_node,
        # Need to keep the launch alive by having an alive process
        launch_testing.util.KeepAliveProc(),
        # Start tests right away - no need to wait for anything
        launch.actions.OpaqueFunction(function=lambda context: ready_fn())]
    ), context
コード例 #10
0
    def setUp(self):
        self.gait_name = "walk"
        self.robot = urdf.Robot.from_xml_file(
            get_package_share_directory("march_description") +
            "/urdf/march6.urdf")
        self.resources_folder = os.path.join(
            get_package_share_directory("march_utility"), "test", "resources")

        self.default_yaml = os.path.join(self.resources_folder, "default.yaml")
        with open(self.default_yaml, "r") as default_yaml_file:
            default_config = yaml.load(default_yaml_file,
                                       Loader=yaml.SafeLoader)
        self.gait_version_map = default_config["gaits"]

        self.gait = Gait.from_file(self.gait_name, self.resources_folder,
                                   self.robot, self.gait_version_map)
コード例 #11
0
def generate_launch_description():
    params_file = LaunchConfiguration(
        'params', default=[ThisLaunchFileDir(), '/launch_params.yaml'])

    # make sure the dbc file gets installed with the launch file
    dbc_file_path = get_package_share_directory('raptor_dbw_can') + \
        "/launch/New_Eagle_DBW_3.3.388.dbc"

    return LaunchDescription([
        Node(
            package='raptor_dbw_can',
            executable='raptor_dbw_can_node',
            output='screen',
            namespace='raptor_dbw_interface',
            parameters=[{
                "dbw_dbc_file": dbc_file_path
            }],
            remappings=[
                ('/raptor_dbw_interface/can_rx', '/can_rx_tx/can_tx'),
                ('/raptor_dbw_interface/can_tx', '/can_rx_tx/can_rx'),
            ],
        ),
        LifecycleNode(package='kvaser_interface',
                      node_executable='kvaser_can_bridge',
                      node_name="kvaser_interface",
                      output='screen',
                      namespace='',
                      parameters=[params_file]),
    ])
コード例 #12
0
 def __init__(self,
              node: Node,
              gui,
              urdf_path=None,
              foot_link_names=[],
              terrain_height=0,
              field=False,
              robot="wolfgang"):
     super().__init__(node)
     # load simuation params
     load_parameter_file(
         node=node,
         node_name=self.node.get_name(),
         parameter_file=get_package_share_directory('wolfgang_pybullet_sim')
         + '/config/config.yaml',
         use_wildcard=True)
     self.gui = gui
     self.sim: Simulation = Simulation(gui,
                                       urdf_path=urdf_path,
                                       foot_link_names=foot_link_names,
                                       terrain_height=terrain_height,
                                       field=field,
                                       robot=robot)
     self.sim_interface: ROSInterface = ROSInterface(
         self.node, self.sim, declare_parameters=False)
コード例 #13
0
def generate_test_description():
    robot_information_node = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory("march_robot_information"),
                "launch",
                "robot_information.launch.py",
            )),
        launch_arguments=[("joint_names",
                           "[test_joint1, test_joint2, test_joint3]")],
    )
    safety_node = Node(
        package="march_safety",
        executable="march_safety_node",
        name="safety_node",
        namespace="march",
        output="screen",
        parameters=[
            {
                "input_device_connection_timeout":
                INPUT_DEVICE_CONNECTION_TIMEOUT
            },
            {
                "use_sim_time": False
            },
        ],
    )
    return (
        LaunchDescription([
            robot_information_node,
            safety_node,
            ReadyToTest(),
        ]),
        {},
    )
コード例 #14
0
def generate_test_description(ready_fn):
    PORT = lidar_integration.get_open_port()

    # The node under test and the checker node that will pass/fail our tests:
    test_topic = "veloyne_cloud_node_test_topic"
    velodyne_cloud_node = launch_ros.actions.LifecycleNode(
        package="velodyne_node",
        node_executable="velodyne_cloud_node_exe",
        node_name="vlp16_driver_node",
        node_namespace="lidar_front",
        parameters=[
            "{}/param/vlp16_test.param.yaml".format(
                ament_index_python.get_package_share_directory(
                    "velodyne_node")), {
                        "port": PORT,
                        "cloud_size": 10700,
                        "expected_num_subscribers": 1,
                    }
        ],
        remappings=[("points_raw", test_topic)],
        arguments=["--model", "vlp16"])

    pcl_checker = lidar_integration.make_pcl_checker(
        topic=test_topic,
        size=10700,
        period=50,
    )

    return lidar_integration.get_lidar_launch_description(
        test_nodes=[velodyne_cloud_node],
        checkers=[pcl_checker],
        other_actions=[
            launch.actions.OpaqueFunction(function=lambda context: ready_fn())
        ],
        port=PORT)
コード例 #15
0
def generate_launch_description():
    return LaunchDescription([
        DeclareLaunchArgument(
            name="config_path",
            default_value=os.path.join(
                get_package_share_directory("march_safety"),
                "config",
                "safety_settings.yaml",
            ),
            description="Path to the configuration for the safety settings",
        ),
        DeclareLaunchArgument(
            name="use_sim_time",
            default_value="true",
            description="Whether to use simulation time",
        ),
        Node(
            package="march_safety",
            executable="march_safety_node",
            name="safety_node",
            namespace="march",
            output="screen",
            parameters=[
                LaunchConfiguration("config_path"),
                {
                    "use_sim_time": LaunchConfiguration("use_sim_time")
                },
            ],
            # If this node exits, the entire system is shutdown
            # This is the ROS2 equivalent of required:=true
            # See: https://ubuntu.com/blog/ros2-launch-required-nodes
            on_exit=Shutdown(),
        ),
    ])
コード例 #16
0
ファイル: unbag2.py プロジェクト: Noam-Dori/unbag2
def generate_launch_description():
    config = DeclareLaunchArgument(
        'yaml',
        default_value=join(get_package_share_directory('unbag2'), 'cfg',
                           'unbag2.yml'),
        description=
        'path to the config file, by default the one stored in this package.')
    files = DeclareLaunchArgument(
        'files',
        default_value='',
        description=
        'string containing a list of all files/directories to try to read as '
        'bag files')
    config_param = LaunchConfiguration('yaml')
    files_param = LaunchConfiguration('files')

    return LaunchDescription([
        files, config,
        LogInfo(msg=["Un-Bagging files: ", files_param]),
        Node(package='unbag2',
             executable='unbag2',
             output='screen',
             name='unbag2',
             parameters=[config_param, {
                 'files': files_param
             }])
    ])
コード例 #17
0
def generate_launch_description():
    params_file = LaunchConfiguration(
        'params',
        default=[ThisLaunchFileDir(), '/launch_params.yaml'])

    # make sure the dbc file gets installed with the launch file
    dbc_file_path = get_package_share_directory('raptor_dbw_can') + \
        '/launch/New_Eagle_DBW_3.4.dbc'

    return LaunchDescription(
        [
            Node(
                package='raptor_dbw_can',
                executable='raptor_dbw_can_node',
                output='screen',
                namespace='raptor_dbw_interface',
                parameters=[
                    {'dbw_dbc_file': dbc_file_path},
                    params_file
                ],
            ),
            Node(
                package='kvaser_interface',
                executable='kvaser_can_bridge',
                output='screen',
                namespace='raptor_dbw_interface',
                parameters=[params_file]),
        ])
コード例 #18
0
ファイル: __init__.py プロジェクト: InigoMonreal/rcc
def get_filename(url, use_protocol=True):
    mod_url = url
    if url.find(PACKAGE_PREFIX) == 0:
        mod_url = url[len(PACKAGE_PREFIX):]
        pos = mod_url.find('/')
        if pos == -1:
            raise Exception(
                'Could not parse package:// format into file:// format for ' +
                url)

        package = mod_url[0:pos]
        mod_url = mod_url[pos:]
        package_path = get_package_share_directory(package)

        if use_protocol:
            protocol = 'file://'
        else:
            protocol = ''
        if sys.platform.startswith('win'):
            path_without_protocol = package_path + mod_url
            path_without_protocol = '/' + path_without_protocol.replace(
                '/', '\\')
            mod_url = protocol + path_without_protocol
        else:
            mod_url = protocol + package_path + mod_url
    return mod_url
コード例 #19
0
def generate_test_description(ready_fn):
    # The node under test and the checker node that will pass/fail our tests:
    test_topic = "veloyne_cloud_node_test_topic"
    node = launch_ros.actions.Node(
        package="voxel_grid_nodes",
        node_executable="voxel_grid_node_exe",
        node_name="voxel_grid_cloud_node",
        parameters=[
            "{}/param/vlp16_lexus_centroid.param.yaml".format(
                ament_index_python.get_package_share_directory(
                    "voxel_grid_nodes")
            )],
        remappings=[
            ("points_in", test_topic)
        ])

    ld, context = lidar_integration.get_point_cloud_mutation_launch_description(
        test_nodes=[node],
        checkers=[],  # TODO we only check that node does not crash for now
        topic=test_topic,
        other_actions=[
            launch.actions.OpaqueFunction(function=lambda context: ready_fn())
        ])

    return ld, context
コード例 #20
0
def init(node: Node):
    node.get_logger().info("Starting localization handler")

    global_params_dict = get_parameters_from_other_node(
        node, "parameter_blackboard", ["field_length", "team_id"])
    global_params = [("field_length", global_params_dict["field_length"]),
                     ("team_id", global_params_dict["team_id"])]
    node.declare_parameters(parameters=global_params, namespace="")

    blackboard = LocalizationBlackboard(node)

    dirname = get_package_share_directory("bitbots_localization_handler")
    node.get_logger().info(dirname)
    dsd = DSD(blackboard, "debug/dsd/localization", node)
    dsd.register_actions(os.path.join(dirname, 'actions'))
    dsd.register_decisions(os.path.join(dirname, 'decisions'))
    dsd.load_behavior(os.path.join(dirname, 'localization.dsd'))

    node.create_subscription(PoseWithCovarianceStamped, "pose_with_covariance",
                             blackboard._callback_pose, 1)
    node.create_subscription(GameState, "gamestate",
                             blackboard.gamestate.gamestate_callback, 1)
    node.create_subscription(RobotControlState, "robot_state",
                             blackboard._callback_robot_control_state, 1)

    return dsd
コード例 #21
0
    def generate(self, package_name, interface_files, include_paths,
                 output_path):
        package_share_path = \
            pathlib.Path(get_package_share_directory('rosidl_generator_cpp'))
        templates_path = package_share_path / 'resource'

        # Normalize interface definition format to .idl
        idl_interface_files = []
        non_idl_interface_files = []
        for path in interface_files:
            if not path.endswith('.idl'):
                non_idl_interface_files.append(path)
            else:
                idl_interface_files.append(path)
        if non_idl_interface_files:
            idl_interface_files.extend(
                translate(
                    package_name=package_name,
                    interface_files=non_idl_interface_files,
                    include_paths=include_paths,
                    output_format='idl',
                    output_path=output_path / 'tmp',
                ))

        # Generate code
        with legacy_generator_arguments_file(
                package_name=package_name,
                interface_files=idl_interface_files,
                include_paths=include_paths,
                templates_path=templates_path,
                output_path=output_path) as path_to_arguments_file:
            return generate_cpp(path_to_arguments_file)
コード例 #22
0
def generate_test_description(ready_fn):
    # The node under test and the checker node that will pass/fail our tests:
    state_estimation_node = launch_ros.actions.Node(
        package="state_estimation_node",
        node_executable="state_estimation_node_exe",
        node_name="state_estimation_node",
        node_namespace="state_estimation_namespace",
        parameters=[
            "{}/param/state_estimation_node_test.param.yaml".format(
                ament_index_python.get_package_share_directory(
                    "state_estimation_node")
            ),
            {"output_frequency": 30.0}
        ]
    )

    context = {'state_node': state_estimation_node}

    return launch.LaunchDescription([
        ROSSpecificLaunchStartup(),
        state_estimation_node,
        # Need to keep the launch alive by having an alive process
        launch_testing.util.KeepAliveProc(),
        # Start tests right away - no need to wait for anything
        launch.actions.OpaqueFunction(function=lambda context: ready_fn())]
    ), context
コード例 #23
0
def generate_test_description():
    robot_information_node = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory("march_robot_information"),
                "launch",
                "robot_information.launch.py",
            )
        ),
        launch_arguments=[("joint_names", f"[{','.join(JOINT_NAMES)}]")],
    )
    safety_node = Node(
        package="march_safety",
        executable="march_safety_node",
        name="safety_node",
        namespace="march",
        output="screen",
        parameters=[CONFIG_PATH, {"use_sim_time": False}],
    )
    return (
        LaunchDescription(
            [
                robot_information_node,
                safety_node,
                ReadyToTest(),
            ]
        ),
        {},
    )
コード例 #24
0
 def setUpClass(cls):
     rclpy.init()
     cls.robot = urdf.Robot.from_xml_file(
         get_package_share_directory("march_description") + "/urdf/march4.urdf"
     )
     cls.stand_position = StaticEdgePosition(
         (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8)
     )
コード例 #25
0
 def get_package_share_directory_test(package_name, expect_prefix):
     full_share_dir = get_package_share_directory(package_name)
     left_over, dirname = os.path.split(full_share_dir)
     assert dirname == package_name, f"Expected package name '{package_name}'"
     left_over, dirname = os.path.split(left_over)
     assert dirname == 'share', "Expected 'share'"
     left_over, dirname = os.path.split(left_over)
     assert dirname == expect_prefix, f"Expected '{expect_prefix}'"
コード例 #26
0
def set_param_to_file(node, param, package, file):
    path = get_package_share_directory(package)
    with open(path + file, 'r') as file:
        file_content = file.read()
    node.set_parameters([
        rclpy.parameter.Parameter(param, rclpy.Parameter.Type.DOUBLE,
                                  file_content)
    ])
コード例 #27
0
def get_param_file(package_name, file_name):
    """Helper function to get param file"""
    file_path = os.path.join(
        get_package_share_directory(package_name),
        'param',
        file_name)
    return launch.substitutions.LaunchConfiguration(
        'params', default=[file_path])
コード例 #28
0
    def generate(self, package_name, interface_files, include_paths,
                 output_path):
        generated_files = []

        package_share_path = \
            get_package_share_directory('rosidl_typesupport_c')

        templates_path = os.path.join(package_share_path, 'resource')

        # Normalize interface definition format to .idl
        idl_interface_files = []
        non_idl_interface_files = []
        for path in interface_files:
            if not path.endswith('.idl'):
                non_idl_interface_files.append(path)
            else:
                idl_interface_files.append(path)
        if non_idl_interface_files:
            idl_interface_files.extend(
                translate(
                    package_name=package_name,
                    interface_files=non_idl_interface_files,
                    include_paths=include_paths,
                    output_format='idl',
                    output_path=output_path / 'tmp',
                ))

        # Generate visibility control file
        visibility_control_file_template_path = \
            'rosidl_typesupport_c__visibility_control.h.in'
        visibility_control_file_template_path = \
            templates_path / visibility_control_file_template_path
        visibility_control_file_path = \
            'rosidl_typesupport_c__visibility_control.h'
        visibility_control_file_path = \
            output_path / 'msg' / visibility_control_file_path

        generate_visibility_control_file(
            package_name=package_name,
            template_path=visibility_control_file_template_path,
            output_path=visibility_control_file_path)
        generated_files.append(visibility_control_file_path)

        # Generate typesupport code
        typesupport_implementations = list(
            get_resources('rosidl_typesupport_c'))

        with legacy_generator_arguments_file(
                package_name=package_name,
                interface_files=idl_interface_files,
                include_paths=include_paths,
                templates_path=templates_path,
                output_path=output_path) as path_to_arguments_file:
            generated_files.extend(
                generate_c(path_to_arguments_file,
                           typesupport_implementations))

        return generated_files
コード例 #29
0
ファイル: main.py プロジェクト: jiangtaojiang/AutowareAuto
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--destination",
                        required=True,
                        help="Absolute path to new package (without package name)."
                             "e.g., ~/autoware_ws/src")
    parser.add_argument("--pkg-name",
                        required=True,
                        help="Name of the new package")
    parser.add_argument("--maintainer",
                        required=True,
                        help="Name of maintainer (for package.xml)")
    parser.add_argument("--email",
                        required=True,
                        help="Email of the maintainer (for package.xml)")
    parser.add_argument("--description",
                        required=True,
                        help="Description of package (for package.xml)")
    args = parser.parse_args()

    dest = os.path.join(args.destination, args.pkg_name)

    # Copy the template package to the desired location
    template_pkg_dir = os.path.join(
      get_package_share_directory('autoware_auto_create_pkg'), 'template')
    copy(template_pkg_dir, dest)

    # Remove COLCON_IGNORE
    try:
        os.remove(os.path.join(dest, 'COLCON_IGNORE'))
    except FileNotFoundError:
        pass

    # Find and replace all hello_world and HELLO_WORLD with pkg_name and PKG_NAME
    for root, _, files in os.walk(dest):
        for filename in files:
            if filename == 'package.xml':
                find_and_replace(os.path.join(root, filename),
                                 args.pkg_name,
                                 args.email,
                                 description=args.description,
                                 maintainer=args.maintainer)
            else:
                find_and_replace(os.path.join(root, filename), args.pkg_name, args.email)
            if 'hello_world' in filename:
                new_filename = filename.replace('hello_world', args.pkg_name)
                os.rename(os.path.join(root, filename), os.path.join(root, new_filename))

    # Rename directories
    for root, dirs, _ in os.walk(dest):
        for dirname in dirs:
            if 'hello_world' in dirname:
                new_dirname = dirname.replace('hello_world', args.pkg_name)
                os.rename(os.path.join(root, dirname), os.path.join(root, new_dirname))

    print("Package {} has been generated in {}.".format(args.pkg_name, args.destination))

    return 0
コード例 #30
0
ファイル: move_group.py プロジェクト: bit-bots/bitbots_misc
def load_yaml(package_name, file_path):
    package_path = get_package_share_directory(package_name)
    absolute_file_path = os.path.join(package_path, file_path)

    try:
        with open(absolute_file_path, "r") as file:
            return yaml.safe_load(file)
    except EnvironmentError:  # parent of IOError, OSError *and* WindowsError where available
        return None