rviz的界面
fixed frame 没错,LaserScan 中的Topic也没错。这两个我是确定的。显示收到的messages received 一直在增加,这也说明接收到了信息了吧,但显示界面中啥也没有。
所以,最大可能是发过来的数据有问题,也就是发布端有问题。
发布端我是用的vreq中最开始的一个教程。
小车上的激光用的SICK_Tim310_fast,按照例程走完之后,激光模块上有个警告。
警告文字如下:
Object ‘Laser_link’ is not dynamically enabled and may not perform as expected.
(This might however be the intended purpose in certain situations or model configurations)
照着个意思,是有可能不行,有可能行。因为是教程嘛,没太在意这,也不确定是不是这里的问题。
教程是在激光传感器SICK_Tim310_fast中修改发布的消息:需要修改的代码如下
if (sim.getInt32Parameter(sim.intparam_program_version)<30004) then
sim.displayDialog("ERROR","This version of the SICK sensor is only supported from V-REP V3.0.4 and upwards.&&nMake sure to update your V-REP.",sim.dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})
end
--下面两行是添加的 “--”后面代表注释了的
-- enable an laserscan publisher
pub = simROS.advertise('/scan', 'sensor_msgs/LaserScan')
notFirstHere=true
--下面的是添加的。
--public the laserscan message(fa bu ji guang xiao xi)
local frame_stamp1 = sim.getSystemTime()
scan = {}
scan['header'] = {seq=0,stamp=frame_stamp1, frame_id="base_link"}
scan['angle_min'] = angle_min
scan['angle_max'] = angle_max
scan['angle_increment'] = angle_increment
scan['time_increment'] = time_increment
scan['scan_time'] = frame_stamp1 --return the current ros time i.e. the time returned by ros::Time::now()
scan['range_min'] = range_min
scan['range_max'] = range_max
scan['ranges'] = distanceData
scan['intensities'] = {}
simROS.publish(pub, scan)
代码我是检查了多次的。
我能猜的也就是那个警告代表确实不行,或者代码有问题。
vreq我已经按照教程测试过 ROS 发到 vrep , vrep 发到 ROS上,都可以实现。
本人小白,刚接触1周左右,很多地方可能描述的不够清楚,随时可以补充。
请教大佬啊!非常感谢。
第二天
排查问题
用一个测试代码确定rviz中的Laserscan没问题。
用rostpoic info echo等相关代码,确定vrep确实发送了数据,切数据能对应代码。
所以,问题出在源头:1.vrep安装或者配置的有问题 2.代码写的有问题
先解决的1,重现安装3.6.2 vrep版本,效果一样,再上网查找安装和配置教程,确定没出问题。
那样看来,代码出问题的几率很大,再去网上找对应所选激光传感器的相关代码,发现我所用教程里面的代码确实有问题,或者说是我用的vrep是3.5(3.6)之类的,而教程里面用的是3.4.0版本。没办法,vrep官网上没找到再早的版本了。问题找到了,但也耽误进度了。确实,自己的锅,毕竟版本不一样,一些地方很容易对应不起来的。
有大佬有vrep3.4.0版本的包之类的,可以分享下吗。我也在去网上找下。