使用自己的激光雷达在cartographer导航框架下绘制地图,报错 lua_parameter_dictionary.cc:83] Check failed: status == 0解决方法。

原创,转载请标注。
在这个方面网上有很多资料,我基本上都试了一遍,但是始终会有问题,我不知道相关博主是怎么成功的,同时也发现有很多志同道合的人也和我遇到了同样的问题,下面进入正题吧。
1.安装cartographer,可参考我上一篇博文,也可以参考其他大神博文,都大同小异。
2.你要有自己激光雷达的相关数据包,我是使用的杉川公司的lidar delta 2b 激光雷达,价格便宜,售后和技术是在不敢恭维。
后期上传我的数据包。
3.修改cartographer下的文件,
3.1 修改catkin_ctg/src/cartographer_ros/cartographer_ros/configuration_files/revo_lds.lua,脚本文件。
修改之前:

-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "horizontal_laser_link",
  published_frame = "horizontal_laser_link",
  odom_frame = "odom",
  provide_odom_frame = true,
  publish_frame_projected_to_2d = false,
  use_pose_extrapolator = true,
  use_odometry = false,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
  trajectory_publish_period_sec = 30e-3,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
}

MAP_BUILDER.use_trajectory_builder_2d = true

TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1

POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65

return options

修改

  tracking_frame = "horizontal_laser_link",
  published_frame = "horizontal_laser_link",

里面的"horizontal_laser_link",改成你自己激光雷达的frame_id,我的是laser,一般都是laser。
其余的不要动,我按照其他人的改了之后 报错,其他人修改的程序如下:

include "map_builder.lua"
 
options = {  map_builder = MAP_BUILDER,
 
 map_frame = "map",
 
tracking_frame = "base_link",
 
published_frame = "base_link",
 
odom_frame = "odom",
 
provide_odom_frame = true,
 
use_odometry_data = false,

use_constant_odometry_variance = false,

constant_odometry_translational_variance = 0.,

constant_odometry_rotational_variance = 0.,
 
use_horizontal_laser = true,
 
use_horizontal_multi_echo_laser = false,

  horizontal_laser_min_range = 0.3,
  horizontal_laser_max_range = 8.,
  horizontal_laser_missing_echo_ray_length = 0.,

 
num_lasers_3d = 0,
 
lookup_transform_timeout_sec = 0.2,
 
submap_publish_period_sec = 0.3,
 
pose_publish_period_sec = 5e-3,
 
}
 
MAP_BUILDER.use_trajectory_builder_2d = true
 
TRAJECTORY_BUILDER_2D.use_imu_data = false
 
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
 
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
 
return options

报错如下:

[ INFO] [1551876266.064116311]: I0306 20:44:26.000000  1039 configuration_file_resolver.cc:41] Found '/home/zyh/catkin_ctg/install_isolated/share/cartographer_ros/configuration_files/revo_lds.lua' for 'revo_lds.lua'.
F0306 20:44:26.064491  1039 lua_parameter_dictionary.cc:83] Check failed: status == 0 (3 vs. 0) [string "include "map_builder.lua"..."]:2: unexpected symbol near char(194)
[FATAL] [1551876266.064849343]: F0306 20:44:26.000000  1039 lua_parameter_dictionary.cc:83] Check failed: status == 0 (3 vs. 0) [string "include "map_builder.lua"..."]:2: unexpected symbol near char(194)
*** Check failure stack trace: ***
    @     0x7fa2a70df46d  google::LogMessage::Fail()
    @     0x7fa2a70e1a23  google::LogMessage::SendToLog()
    @     0x7fa2a70deffb  google::LogMessage::Flush()
    @     0x7fa2a70e096e  google::LogMessageFatal::~LogMessageFatal()
    @           0x6215c9  cartographer::common::(anonymous namespace)::CheckForLuaErrors()
    @           0x621dad  cartographer::common::LuaParameterDictionary::LuaParameterDictionary()
    @           0x6220cd  cartographer::common::LuaParameterDictionary::LuaParameterDictionary()
    @           0x5c26d1  cartographer_ros::LoadOptions()
    @           0x59083b  cartographer_ros::(anonymous namespace)::Run()
    @           0x58dfa4  main
    @     0x7fa2a2f96830  __libc_start_main
    @           0x590559  _start
[cartographer_node-2] process has died [pid 1039, exit code -6, cmd /home/zyh/catkin_ctg/install_isolated/lib/cartographer_ros/cartographer_node -configuration_directory /home/zyh/catkin_ctg/install_isolated/share/cartographer_ros/configuration_files -configuration_basename revo_lds.lua scan:=scan __name:=cartographer_node __log:=/home/zyh/.ros/log/91b1ffc0-400d-11e9-9569-00e04c982253/cartographer_node-2.log].
log file: /home/zyh/.ros/log/91b1ffc0-400d-11e9-9569-00e04c982253/cartographer_node-2*.log

根据报错信息可以看出是在lua这个文件里面 map_builder 没有给相关数值定义。
4.修改catkin_ctg/src/cartographer_ros/cartographer_ros/launch/demo_revo_lds.launch文件。
修改代码如下:

<!--
  Copyright 2016 The Cartographer Authors

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<launch>
  <param name="/use_sim_time" value="true" />

  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename revo_lds.lua"
      output="screen">
    <remap from="scan" to="scan" />
  </node>

  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />" 
</launch>

修改完之后,回到catkin_ctg目录下面编译

catkin_make_isolated --install --use-ninja

5.运行
先运行激光雷达节点,当然,先要给端口权限
先查看一下端口

ls -l /dev/ttyUSB*

显示相应端口,如:

crw-rw---- 1 root dialout 188, 0 3月   6 19:22 /dev/ttyUSB0

我这里是USB0,给USB0权限

sudo chmod 666 /dev/ttyUSB0

然后运行激光雷达节点launch文件

roslaunch delta_2b_lidar delta_2b_lidar.launch

运行cartographer框架

roslaunch cartographer_ros demo_revo_lds.launch

正常打开rviz,并且显示正常,如下
在这里插入图片描述
结束!

  • 4
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 21
    评论
FAILED: CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DGFLAGS_IS_A_DLL=0 -I../cartographer -I. -I../ -isystem /usr/include/eigen3 -isystem /usr/include/lua5.2 -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -MF CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o.d -o CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -c ../cartographer/transform/timestamped_transform_test.cc In file included from ../cartographer/transform/timestamped_transform_test.cc:17: ../cartographer/transform/timestamped_transform.h:21:10: fatal error: cartographer/transform/proto/timestamped_transform.pb.h: No such file or directory 21 | #include "cartographer/transform/proto/timestamped_transform.pb.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [44/380] Building CXX object CMakeFiles/cartographer.sensor.internal.voxel_filter_test.dir/cartographer/sensor/internal/voxel_filter_test.cc.o
07-23
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值