我需要一些帮助来解决我在将超声波传感器添加到已经配备了 RPlidar 的机器人(松散地基于 Linorobot)时遇到的问题。硬件/软件:带有 Ubuntu 16.04.6 LTS、ROS 动力学、Teensy、2 Nano 的 Raspi3B。
机器人仅使用激光雷达就可以正常工作,但我需要能够正确检测玻璃和一些反射表面,所以我添加了超声波传感器。硬件和微控制器(rosserial)部分似乎工作正常,我怀疑这是我的错误,可能与命名空间或转换帧有关......或者我可能错过了一些巨大的东西。我检查并重新检查了在线教程、示例和其他与此类似的问题,但我无法确定罪魁祸首。
执行启动文件后,我收到标准消息(与尝试设置超声波传感器之前相同),另外:
[ INFO] [1631195261.554945536]: global_costmap/sonar_layer: ALL as input_sensor_type given
[ INFO] [1631195261.596176257]: RangeSensorLayer: subscribed to topic /ultrasound_front
我想这很好。不幸的是,从那一刻起,我得到了(当然,数字越来越高):
[ WARN] [1631195265.533631740]: No range readings received for 4.02 seconds, while expected at least every 2.00 seconds.
这是一条传感器消息(来自“rostopic echo /ultrasound_front”):
----
header:
seq: 1124
stamp:
secs: 1631192726
nsecs: 301432058
frame_id: "sonar_front"
radiation_type: 0
field_of_view: 0.259999990463
min_range: 0.0
max_range: 100.0
range: 52.0
----
所以,主题发布了,按摩应该没问题...
我的 costmap_common_params.yaml:
map_type: costmap
transform_tolerance: 1
footprint: [[-0.25, -0.25], [-0.25, 0.25], [0.25, 0.25], [0.25, -0.25]]
inflation_layer:
inflation_radius: 0.28
cost_scaling_factor: 3
obstacle_layer:
obstacle_range: 2.5
raytrace_range: 3.0
observation_sources: scan
observation_persistence: 0.0
scan:
data_type: LaserScan
topic: scan
marking: true
clearing: true
sonar_layer:
frame: sonar_front
topics: ["/ultrasound_front"]
no_readings_timeout: 2.0
clear_on_max_reading: true
clear_threshold: 0.2
mark_threshold: 0.80
我的 global_costmap_params.yaml:
global_costmap:
global_frame: /map
robot_base_frame: /base_footprint
update_frequency: 1
publish_frequency: 0.5
static_map: true
transform_tolerance: 1
plugins:
- {name: static_layer, type: "costmap_2d::StaticLayer"}
- {name: sonar_layer, type: "range_sensor_layer::RangeSensorLayer"}
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
我的 local_costmap_params.yaml:
local_costmap:
global_frame: /odom
robot_base_frame: /base_footprint
update_frequency: 1
publish_frequency: 5.0
static_map: false
rolling_window: true
width: 3
height: 3
resolution: 0.02
transform_tolerance: 1
observation_persistence: 0.0
plugins:
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
- {name: sonar_layer, type: "range_sensor_layer::RangeSensorLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
还有我的准系统 URDF:
<?xml version="1.0"?>
<robot name="linorobot">
<link name="base_link">
<visual>
<geometry>
<box size="0.50 0.33 0.09"/>
</geometry>
<origin rpy="0 0 0" xyz="0.0 0.00 0.085"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
</link>
<link name="perception_deck">
<visual>
<geometry>
<box size="0.18 0.33 0.08"/>
</geometry>
<origin rpy="0 0 0" xyz="0.0 0.0 0.17"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
</link>
<link name="wheel_left_front">
<visual>
<geometry>
<cylinder length="0.03" radius="0.06"/>
</geometry>
<origin rpy="1.57 0 0" xyz="0.163 0.222 0.03"/>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<link name="wheel_right_front">
<visual>
<geometry>
<cylinder length="0.03" radius="0.06"/>
</geometry>
<origin rpy="1.57 0 0" xyz="0.163 -0.222 0.03"/>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<link name="wheel_left_rear">
<visual>
<geometry>
<cylinder length="0.03" radius="0.06"/>
</geometry>
<origin rpy="1.57 0 0" xyz="-0.163 0.222 0.03"/>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<link name="wheel_right_rear">
<visual>
<geometry>
<cylinder length="0.03" radius="0.06"/>
</geometry>
<origin rpy="1.57 0 0" xyz="-0.163 -0.222 0.03"/>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<link name="laser">
<visual>
<geometry>
<cylinder length="0.065" radius="0.035"/>
</geometry>
<origin rpy="0 0 0" xyz="0.0 0.0 0.2825"/>
<material name="black"/>
</visual>
</link>
<link name="chassis">
<visual>
<geometry>
<box size="0.5 0.5 0.8"/>
</geometry>
<origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
<material name="silver">
<color rgba="192 192 192 0.6"/>
</material>
</visual>
</link>
<link name="sonar_front">
<visual>
</geometry>
<origin rpy="1.5708 0.2618 0" xyz="-0.21 0.0 0.235"/>
<material name="silver">
<color rgba="192 192 192 0.6"/>
</material>
</visual>
</link>
<link name="sonar_rear">
<visual>
<geometry>
<box size="0.02 0.025 0.07"/>
</geometry>
<origin rpy="1.5708 0.2618 3.1416" xyz="0.23 0.0 0.235"/>
<material name="silver">
<color rgba="192 192 192 0.6"/>
</material>
</visual>
</link>
<link name="sonar_left">
<visual>
<geometry>
<box size="0.02 0.025 0.07"/>
</geometry>
<origin rpy="1.5708 -0.2618 1.5708" xyz="0.0 0.18 0.235"/>
<material name="silver">
<color rgba="192 192 192 0.6"/>
</material>
</visual>
</link>
<link name="sonar_right">
<visual>
<geometry>
<box size="0.02 0.025 0.07"/>
</geometry>
<origin rpy="1.5708 -0.2618 -1.5708" xyz="0.0 -0.19 0.235"/>
<material name="silver">
<color rgba="192 192 192 0.6"/>
</material>
</visual>
</link>
<joint name="base_to_wheel_left_front" type="fixed">
<parent link="base_link"/>
<child link="wheel_left_front"/>
<origin xyz="0 0 0"/>
</joint>
<joint name="base_to_wheel_right_front" type="fixed">
<parent link="base_link"/>
<child link="wheel_right_front"/>
<origin xyz="0 0 0"/>
</joint>
<joint name="base_to_wheel_left_rear" type="fixed">
<parent link="base_link"/>
<child link="wheel_left_rear"/>
<origin xyz="0 0 0"/>
</joint>
<joint name="base_to_wheel_right_rear" type="fixed">
<parent link="base_link"/>
<child link="wheel_right_rear"/>
<origin xyz="0 0 0"/>
</joint>
<joint name="base_to_laser" type="fixed">
<parent link="base_link"/>
<child link="laser"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_left_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_left"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_right_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_right"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_rear_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_rear"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_front_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_front"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_perception_deck" type="fixed">
<parent link="base_link"/>
<joint name="base_to_laser" type="fixed">
<parent link="base_link"/>
<child link="laser"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_left_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_left"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_right_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_right"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_rear_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_rear"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_front_sonar" type="fixed">
<parent link="base_link"/>
<child link="sonar_front"/>
<origin xyz="0.0 0.0 0.0"/>
</joint>
<joint name="base_to_perception_deck" type="fixed">
<parent link="base_link"/>
<child link="perception_deck"/>
<origin xyz="0 0 0.0"/>
</joint>
<joint name="base_to_chassis" type="fixed">
<parent link="base_link"/>
<child link="chassis"/>
<origin xyz="0 0 0.44"/>
</joint>
</robot>
谢谢!
收到消息后进行编辑
,“rostopic hz /ultrasound_front”给出:
subscribed to [/ultrasound_front]
average rate: 3.494
min: 0.267s max: 0.305s std dev: 0.01919s window: 3
average rate: 3.384
min: 0.250s max: 0.353s std dev: 0.03533s window: 6
average rate: 3.362
min: 0.250s max: 0.353s std dev: 0.02813s window: 9
average rate: 3.352
min: 0.250s max: 0.353s std dev: 0.02625s window: 13
average rate: 3.349
min: 0.250s max: 0.353s std dev: 0.02447s window: 16
average rate: 3.344
min: 0.250s max: 0.353s std dev: 0.02547s window: 20
average rate: 3.341
min: 0.250s max: 0.353s std dev: 0.02368s window: 23
average rate: 3.256
min: 0.250s max: 0.490s std dev: 0.04349s window: 26
average rate: 3.336
min: 0.110s max: 0.490s std dev: 0.05406s window: 30
average rate: 3.335
min: 0.110s max: 0.490s std dev: 0.05176s window: 33
等等。MCU 代码中的发布间隔为 250ms。
“rostopic echo /ultrasound_front”中的“max_range:1.0”已得到纠正(在原始 MCU 代码中是一个错误),行为没有改变。我修改了上面的输出以反映当前版本。
按摩开始后,“rostopic info /ultrasound_front”给出:(谢谢@BTables!)
Type: sensor_msgs/Range
Publishers:
* /rosserial_NANO_sensors (http://192.168.2.54:34525/)
Subscribers:
* /move_base (http://192.168.2.54:40149/)