Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import launch
- from launch.substitutions import Command, LaunchConfiguration
- import launch_ros
- import os
- import sys
- from ament_index_python.packages import get_package_share_directory
- def generate_launch_description():
- pkg_share = launch_ros.substitutions.FindPackageShare(package='aroc_truck_description').find('aroc_truck_description')
- default_model_path = os.path.join(pkg_share, 'src/description/aroc_truck_description.urdf')
- default_rviz_config_path = os.path.join(pkg_share, 'rviz/urdf_config.rviz')
- #world_file_name = 'winding_valley.sdf' #Fix wheel displacemente at rough terrains first...
- world_file_name = 'turtlebot.world' #'test_world.sdf'
- world = os.path.join(pkg_share, 'world', world_file_name)
- #world = os.path.join('/home/autoware-auto-ros1/nav2_ws/src/aroc_truck_description/aroc_truck_description/world', world_file_name)
- robot_state_publisher_node = launch_ros.actions.Node(
- package='robot_state_publisher',
- executable='robot_state_publisher',
- parameters=[{'robot_description': Command(['xacro ', LaunchConfiguration('model')])}]
- )
- joint_state_publisher_node = launch_ros.actions.Node(
- package='joint_state_publisher',
- executable='joint_state_publisher',
- name='joint_state_publisher',
- parameters=[{
- 'source_list': ['joint_states']
- }],
- condition=launch.conditions.UnlessCondition(LaunchConfiguration('gui'))
- )
- joint_state_publisher_gui_node = launch_ros.actions.Node(
- package='joint_state_publisher_gui',
- executable='joint_state_publisher_gui',
- name='joint_state_publisher_gui',
- parameters=[{'rate': 30.0}], # Set the update rate of the GUI node (in Hz)
- condition=launch.conditions.IfCondition(LaunchConfiguration('gui'))
- )
- # I have added a custom publisher for the truck's intermediate wheels, since the Ackermann plugin don't include more than frontal and rear wheels (or modify this plugin later to optimize)
- #Or I need to set the joints of these wheels as static otherwise joint_states won't recognize them. Or must have the joint_state_publisher_gui active to publishe these joints values. However
- #if let it active it is going to overhead CPU and the transform from Odom to base_link will be delayed "Old TF transform"
- intermediate_joint_state_publisher_node = launch_ros.actions.Node(
- package='aroc_truck_description',
- executable=sys.executable,
- arguments=[os.path.join(get_package_share_directory('aroc_truck_description'), 'aroc_truck_python', 'intermediate_joint_state_publisher.py')],
- name='intermediate_joint_state_publisher',
- remappings=[('joint_states', 'joint_states')],
- parameters=[{
- 'joint_names': ['middle_left_wheel_joint', 'middle_right_wheel_joint',
- 'middle_rear_left_wheel_joint', 'middle_rear_right_wheel_joint',],
- 'publish_rate': 30
- }]
- )
- rviz_node = launch_ros.actions.Node(
- package='rviz2',
- executable='rviz2',
- name='rviz2',
- output='screen',
- arguments=['-d', LaunchConfiguration('rvizconfig')],
- )
- spawn_entity = launch_ros.actions.Node(
- package='gazebo_ros',
- executable='spawn_entity.py',
- arguments=['-entity', 'aroc_truck', '-topic', 'robot_description',
- ],
- output='screen'
- )
- # robot_localization_node = launch_ros.actions.Node(
- # package='robot_localization',
- # executable='ekf_node',
- # name='ekf_filter_node',
- # output='screen',
- # parameters=[os.path.join(pkg_share, 'config/ekf.yaml'), {'use_sim_time': LaunchConfiguration('use_sim_time')}]
- # )
- return launch.LaunchDescription([
- launch.actions.DeclareLaunchArgument(name='gui', default_value='True',
- description='Flag to enable joint_state_publisher_gui'),
- launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
- description='Absolute path to robot urdf file'),
- launch.actions.DeclareLaunchArgument(name='rvizconfig', default_value=default_rviz_config_path,
- description='Absolute path to rviz config file'),
- launch.actions.DeclareLaunchArgument(name='use_sim_time', default_value='True',
- description='Flag to enable use_sim_time'),
- launch.actions.ExecuteProcess(cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world], output='screen'),
- joint_state_publisher_node,
- intermediate_joint_state_publisher_node,
- joint_state_publisher_gui_node,
- robot_state_publisher_node,
- spawn_entity,
- #robot_localization_node,
- rviz_node
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement