/
my_doosan_gazebo_controller.launch.py
71 lines (45 loc) · 2.24 KB
/
my_doosan_gazebo_controller.launch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'''
Author: David Valencia
Date: 15 / 10 /2021
Describer:
This scrip spawn the robot in gazebo and LOAD and START a basic joint_trajectory_controller
The info and configuration of the controller can be found in the config folder:
/src/my_doosan_pkg/config/simple_controller.yaml
Just for testing purposes inside this packages only
- Robot model m1013 color white
- Robot model a0912 color blue
'''
import os
from launch_ros.actions import Node
from launch import LaunchDescription
from launch.substitutions import Command
from launch.actions import ExecuteProcess
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
robot_model = 'a0912'
#robot_model = 'm1013'
xacro_file = get_package_share_directory('my_doosan_pkg') + '/description'+'/xacro/'+ robot_model +'.urdf.xacro'
# Robot State Publisher
robot_state_publisher = Node(package ='robot_state_publisher',
executable ='robot_state_publisher',
name ='robot_state_publisher',
output ='both',
parameters =[{'robot_description': Command(['xacro', ' ', xacro_file])
}])
# Spawn the robot in Gazebo
spawn_entity_robot = Node(package ='gazebo_ros',
executable ='spawn_entity.py',
arguments = ['-entity', 'my_doosan_robot', '-topic', 'robot_description'],
output ='screen')
# Gazebo
world_file_name = 'my_empty_world.world'
world = os.path.join(get_package_share_directory('my_doosan_pkg'), 'worlds', world_file_name)
gazebo_node = ExecuteProcess(cmd=['gazebo', '--verbose', world,'-s', 'libgazebo_ros_factory.so'], output='screen')
# load and START the controllers in launch file
load_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'start','joint_state_broadcaster'],
output='screen')
load_joint_trajectory_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'joint_trajectory_controller'],
output='screen')
return LaunchDescription([robot_state_publisher, spawn_entity_robot, gazebo_node, load_joint_state_broadcaster, load_joint_trajectory_controller ])