针对之前修改ROS STAGE源代码后可以运行world文件!
使用STAGE ROS作为模拟平台,输出的时间一直是仿真时间,与laser_scan_matcher包搭配后出现警告
warn: Could not get initial transform from base to laser
skipping scan
问题出现输出的laser scan的时间戳为仿真时间,而非系统时间,无法与其他模块进行配对。
查看源代码stage_ros/src/stageros.cpp做如下修改。
n_.setParam("/use_sim_time", false);
this->sim_time=ros::Time::now();
this->base_last_cmd=ros::Time::now();
一定要将use_sim_time设置为假,否则下面的now()依然返回的是仿真时间!
按照这样将所有的sim_time设置成ros::Time::now() ROS当前时间。
经过后期验证:此方法存在严重缺陷,导致得到的速度数据累计后与实际坐标位置不符,20201228注!!!
源程序位置为https://github.com/rtv/stage_ros.git
然后回到catkin_ws目录下,生成后检查stage_ros路径是否在当前工作目录下!
catkin_make
source devel/setup.bash
rospack find stage_ros
然后运行world文件,打开stageros,检查参数是否正确!
rosrun stage_ros stageros test.world
rosparam get use_sim_time
如果始终为真,考虑将devel和build目录删除后重新生成。
这样生成的所有数据的时间戳都是系统时间。
Laser_scan_matcher的包地址:https://github.com/ccny-ros-pkg/scan_tools,需要放到相同的工作目录下。