In a rotate_recovery behavior called by move_base, the following code is telling me that getRobotFootprint() has an impossibly big size, and I get a segmentation fault when accessing the first point. Why could it be?

const std::vector<geometry_msgs::Point>& f = local_costmap_->getRobotFootprint();
ROS_ERROR("Size of vector f: %zu", f.size());
for (size_t i = 0; i < f.size(); ++i) {
    const auto& point = f[i];
    ROS_WARN("  x: %.2f, y: %.2f, z: %.2f", point.x, point.y, point.z);

Long story:

I am trying to write my own rotate recovery behavior (https://github.com/ros-planning/navigation/tree/noetic-devel/rotate_recovery).

So to start I am trying to create a plugin that does exactly the same as the above but call it rotate_recovery2.

I literally copied the rotate_recovery folder, changed the name of all rotate_recovery files and folders to rotate_recovery2, change all instances of rotate_recovery to rotate_recovery2 in the CMakeLists and package and rotate_plugin files, and in the rotate_recovery2.cpp and rotate_recovery2.h files, I simply changed the namespace to rotate_recovery2, and in the case of the .cpp file I replaced the import (#include <rotate_recovery2/rotate_recovery2.h>), and the export class (PLUGINLIB_EXPORT_CLASS(rotate_recovery2::RotateRecovery, nav_core::RecoveryBehavior) ).

The code is therefore the same. I have created a new workspace, copied the package inside the src folder, built the package (catkin_make), sourced it.

But if I load the following rosparams:

  - name: 'costmap_reset_far'
    type: 'clear_costmap_recovery/ClearCostmapRecovery'
  - name: 'costmap_reset_close'
    type: 'clear_costmap_recovery/ClearCostmapRecovery'
  - name: 'rotate_recovery2'
    type: 'rotate_recovery2/RotateRecovery'

  reset_distance: 3.0
  layer_names: ["obstacle_laser_layer"]

  reset_distance: 1.5
  layer_names: ["obstacle_laser_layer"]

  sim_granularity: 0.017
  frequency: 20.0
  yaw_goal_tolerance: 0.01
  max_rotational_vel: 0.25
  min_in_place_rotational_vel: 0.1

If I run move_base: rosrun move_base move_base odom:=mobile_base_controller/odom cmd_vel:=nav_vel __name:=move_base.

When the robot gets lost I get a Segmentation Fault.

After some debugging, it happens in this line:

double footprint_cost = world_model_->footprintCost(x, y, theta, local_costmap_->getRobotFootprint(), 0.0, 0.0);

I don't know much cpp, but I have been playing with it, and the following:

const std::vector<geometry_msgs::Point>& f = local_costmap_->getRobotFootprint();
ROS_ERROR("Size of vector f: %zu", f.size());

Prints Size of vector f: 18254858764495155175, which has to be wrong, and when I try to access any element in the footprint, it gives me the segmentation fault.

Why is this happening? How to fix it? I am completely lost, I think the problem is in local_costmap, which is passed by move_base, but I am probably not understanding something.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.