|
1 | 1 | <?xml version="1.0"?> |
2 | 2 | <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> |
3 | 3 |
|
4 | | -<xacro:macro name="gpu_laser" params="prefix parent_link sensor_prop "> |
| 4 | + |
| 5 | +<xacro:macro name="laser" params="prefix parent_link sensor_prop enable_gpu:=true"> |
5 | 6 |
|
6 | 7 | <xacro:property name="mesh" |
7 | | - value="${sensor_prop['gpu_laser']['mesh']}"/> |
| 8 | + value="${sensor_prop['laser']['mesh']}"/> |
| 9 | + |
| 10 | + <xacro:if value="${enable_gpu}"> |
| 11 | + <xacro:property name="plugin_name" value="libgazebo_ros_gpu_laser.so"/> |
| 12 | + <xacro:property name="laser_type" value="gpu_ray"/> |
| 13 | + </xacro:if> |
| 14 | + <xacro:if value="${not enable_gpu}"> |
| 15 | + <xacro:property name="plugin_name" value="libgazebo_ros_laser.so"/> |
| 16 | + <xacro:property name="laser_type" value="ray"/> |
| 17 | + </xacro:if> |
8 | 18 |
|
9 | | - <link name="${prefix}_gpu_laser_link"> |
| 19 | + <link name="${prefix}_laser_link"> |
10 | 20 | <xacro:if value="${mesh != '' }" > |
11 | 21 | <visual> |
12 | | - <origin xyz="0 0 0" rpy="0 0 0"/> |
| 22 | + <origin xyz="0 0 0" rpy="0 0 ${pi}"/> |
13 | 23 | <geometry> |
14 | 24 | <mesh filename="package://${package_name}/meshes/sensors/${mesh}" /> |
15 | 25 | </geometry> |
|
20 | 30 | <visual> |
21 | 31 | <origin xyz="0 0 0" rpy="0 0 0"/> |
22 | 32 | <geometry> |
23 | | - <cylinder radius="${sensor_prop['gpu_laser']['radius']}" length="${sensor_prop['gpu_laser']['length']}"/> |
| 33 | + <cylinder radius="${sensor_prop['laser']['radius']}" length="${sensor_prop['laser']['length']}"/> |
24 | 34 | </geometry> |
25 | 35 | <material name="red"/> |
26 | 36 | </visual> |
27 | 37 | </xacro:if> |
28 | 38 | <collision> |
29 | 39 | <origin xyz="0 0 0" rpy="0 0 0"/> |
30 | 40 | <geometry> |
31 | | - <cylinder radius="${sensor_prop['gpu_laser']['radius']}" length="${sensor_prop['gpu_laser']['length']}"/> |
| 41 | + <cylinder radius="${sensor_prop['laser']['radius']}" length="${sensor_prop['laser']['length']}"/> |
32 | 42 | </geometry> |
33 | 43 | </collision> |
34 | | - <xacro:cylinder_inertia m="${sensor_prop['gpu_laser']['mass']}" |
35 | | - r="${sensor_prop['gpu_laser']['radius']}" |
36 | | - l="${sensor_prop['gpu_laser']['length']}" |
| 44 | + <xacro:cylinder_inertia m="${sensor_prop['laser']['mass']}" |
| 45 | + r="${sensor_prop['laser']['radius']}" |
| 46 | + l="${sensor_prop['laser']['length']}" |
37 | 47 | o_xyz="0 0 0" |
38 | 48 | o_rpy="0 0 0" /> |
39 | 49 | </link> |
40 | 50 | <gazebo reference="${prefix}_laser_link"> |
41 | | - <material>Gazebo/Grey</material> |
| 51 | + <material>${sensor_prop['laser']['color']}</material> |
42 | 52 | </gazebo> |
43 | 53 |
|
44 | | - <joint name="${prefix}_gpu_laser_joint" type="fixed"> |
| 54 | + <joint name="${prefix}_laser_joint" type="fixed"> |
45 | 55 | <parent link="${parent_link}"/> |
46 | | - <child link="${prefix}_gpu_laser_link"/> |
47 | | - <origin xyz="${sensor_prop['gpu_laser']['dx']} ${sensor_prop['gpu_laser']['dy']} ${sensor_prop['gpu_laser']['dz']}" rpy="0 0 0"/> |
| 56 | + <child link="${prefix}_laser_link"/> |
| 57 | + <origin xyz="${sensor_prop['laser']['dx']} ${sensor_prop['laser']['dy']} ${sensor_prop['laser']['dz']}" rpy="0 0 ${pi}"/> |
48 | 58 | <axis xyz="0 1 0" /> |
49 | 59 | </joint> |
50 | 60 |
|
51 | 61 | <!-- hokuyo gazebo references --> |
52 | | - <gazebo reference="${prefix}_gpu_laser_link"> |
53 | | - <sensor type="gpu_ray" name="head_hokuyo_sensor"> |
| 62 | + <gazebo reference="${prefix}_laser_link"> |
| 63 | + <!-- type is either gpu_laser or laser --> |
| 64 | + <sensor type="${laser_type}" name="head_hokuyo_sensor"> |
54 | 65 | <pose>0 0 0 0 0 0</pose> |
55 | 66 | <visualize>true</visualize> |
56 | | - <update_rate>40</update_rate> |
| 67 | + <update_rate>12</update_rate> |
57 | 68 | <ray> |
58 | 69 | <scan> |
59 | 70 | <horizontal> |
60 | | - <samples>720</samples> |
| 71 | + <samples>360</samples> |
61 | 72 | <resolution>1</resolution> |
62 | | - <min_angle>${sensor_prop['gpu_laser']['angular_range']['min']}</min_angle> |
63 | | - <max_angle>${sensor_prop['gpu_laser']['angular_range']['max']}</max_angle> |
| 73 | + <min_angle>${sensor_prop['laser']['angular_range']['min']}</min_angle> |
| 74 | + <max_angle>${sensor_prop['laser']['angular_range']['max']}</max_angle> |
64 | 75 | </horizontal> |
65 | 76 | </scan> |
66 | 77 | <range> |
|
78 | 89 | <stddev>0.01</stddev> |
79 | 90 | </noise> |
80 | 91 | </ray> |
81 | | - <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so"> |
82 | | - <topicName>/${robot_name}/scan</topicName> |
83 | | - <frameName>${prefix}_gpu_laser_link</frameName> |
| 92 | + <!-- plugin_name is either libgazebo_ros_laser.so or libgazebo_ros_gpu_laser.so--> |
| 93 | + <plugin name="gazebo_ros_head_hokuyo_controller" filename="${plugin_name}"> |
| 94 | + <topicName>/diffbot/scan</topicName> |
| 95 | + <frameName>${prefix}_laser_link</frameName> |
84 | 96 | </plugin> |
85 | 97 | </sensor> |
86 | 98 | </gazebo> |
|
0 commit comments