larics / cartographer_superbuild

Apache License 2.0
79 stars 35 forks source link

Doen't work in Clion #1

Closed xuqingwenkk closed 6 years ago

xuqingwenkk commented 7 years ago

Hello, Thank you very much for providing the cmake support of cartographer. I have compiled them and run it in terminal successfully. However, cartographer node didn't subscribe sensor data when I run it in clion.

For the code boost::function<void(const sensor_msgs::LaserScan::ConstPtr&)>( [this, trajectory_id, topic](const sensor_msgs::LaserScan::ConstPtr& msg) { map_builder_bridge_.sensor_bridge(trajectory_id) ->HandleLaserScanMessage(topic, msg); }))); there is an error says, Class 'boost::function<void(const sensor_msgs::LaserScan_<std::allocator<void>>::ConstPtr &)>' doesn't have a constructor 'function(void (*)(const sensor_msgs::LaserScan_<std::allocator<void>>::ConstPtr &))'

Other sensor callback meet the same error. However, I can pass the build but when I run the program, the cartographer node is always waiting, receive no data. /home/xuqw/CLionProjects/carto/cartographer_superbuild/cmake-build-relwithdebinfo/devel/lib/cartographer_ros/cartographer_node -configuration_directory /home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer_ros/cartographer_ros/configuration_files -configuration_basename backpack_2d.lua [ INFO] [1501243771.055225301]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer_ros/cartographer_ros/configuration_files/backpack_2d.lua' for 'backpack_2d.lua'. [ INFO] [1501243771.055693767]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'. [ INFO] [1501243771.055759021]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'. [ INFO] [1501243771.055855055]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/sparse_pose_graph.lua' for 'sparse_pose_graph.lua'. [ INFO] [1501243771.055914091]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/sparse_pose_graph.lua' for 'sparse_pose_graph.lua'. [ INFO] [1501243771.056145692]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'. [ INFO] [1501243771.056202782]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'. [ INFO] [1501243771.056289882]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'. [ INFO] [1501243771.056343157]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'. [ INFO] [1501243771.056490949]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'. [ INFO] [1501243771.056554242]: I0728 20:09:31.000000 757 configuration_file_resolver.cc:40] Found '/home/xuqw/CLionProjects/carto/cartographer_superbuild/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'. [ INFO] [1501243771.073532229]: I0728 20:09:31.000000 757 submaps.cc:188] Added submap 1 [ INFO] [1501243771.073686230]: I0728 20:09:31.000000 757 map_builder_bridge.cc:58] Added trajectory with ID '0'.

I have no idea on it. Could you give a hand? I will be very appreciated.

ojura commented 7 years ago

Which operating system are you using? Have you tried deleting and redownloading (recloning) everything?

I don't understand how you are able to run the program if it throws an error when compiling (this is only in CLion?). Have you double checked if you have specified topic remappings correctly? I don't see any in your command line.

Can you prepare an exact list of steps to reproduce it (e.g. make a directory, clone repozitory X, clone repozitory Y, open CLion, open project, set build type to RelWithDebInfo, compile, run roscore, run rosbag play, etc.)

xuqingwenkk commented 7 years ago

I am using ubuntu 16.04 LTS + ros kinetic.

Actually, it didn't throw an error in CLion but there is red line below the code. When I move mouse on the code, the error Class 'boost::function<void(const sensor_msgs::LaserScan_<std::allocator<void>>::ConstPtr &)>' doesn't have a constructor 'function(void (*)(const sensor_msgs::LaserScan_<std::allocator<void>>::ConstPtr &))' occurs. My sensor data is published on topic /scan and /odom so that I didn't do any remappings.

My steps are as follows:

  1. mkdir carto cd carto
  2. git clone https://github.com/ojura/cartographer_superbuild.git cd cartographer_superbuild
  3. git clone https://github.com/googlecartographer/cartographer.git git clone https://github.com/googlecartographer/cartographer_ros.git cd .. I didn't download ceres-solver beacuse I have installed it.
  4. mkdir build cd build cmake .. make - j4 'source devel/setup.bash'
  5. 'roslaunch cartographer_ros demo_backup_2d.launch bag_filename:=/home/xuqw/Downloads/b2.bag' Everything works from the terminal command. Then I began to run it from CLion
  6. Open Clion via icon(CLion is configured to import environment variables)
  7. Import project from source, open the folder cartographer_superbuild
  8. Set CMake build type to RelWithDebInfo
  9. Open Run -> Edit Configurations -> cartographer_node, set Target and Executable to be cartographer_node
  10. Set program parameter be -configuration_directory /home/xuqw/carto/cartographer_superbuild/cartographer_ros/cartographer_ros/configuration_files -configuration_basename backup_2d.lua
  11. Open roscore in terminal
  12. Click the Run button in CLion
  13. rosbag play b2.bag in terminal
  14. Then the program always waiting in CLion. I run rostopic info /scan but found no subscriber for /scan topic. That's all what I did.
xuqingwenkk commented 7 years ago

It seems that I have solved this issue. I didn't set use_sim_time be true and I didn't remapping topics. Thank you very much for your help.

ojura commented 7 years ago

Don't forget to publish clock from the bag as well when playing (--clock). Also, check out the Cartographer offline node, it processes the bag at the maximum speed, so you don't have to play it.

xuqingwenkk commented 7 years ago

Does it mean that the Cartographer offline node doesn't need the time stamp?