qiayuanl / legged_perceptive

64 stars 20 forks source link

Erro: Position is out of range #7

Open nanbwrn opened 7 months ago

nanbwrn commented 7 months ago

When I was simulating in Gazebo, the robot suddenly fell after covering some distance, and the following error message appeared in the terminal. Could you please advise on how to fix it?

GridMap: atPosition(...): Position is out of range.

The following is a simulation video:

动画3

YifuYuan commented 7 months ago

Hi @nanbwrn, I'm not exactly sure but I guess you can bring up Rviz and see what the elevation mapping and plane segmentation actually look like. For me, it looks like the elevation mapping is not moving with the robot but stays at the origin instead.

hgaren commented 7 months ago

"GridMap: atPosition(...): Position is out of range" The reason of this error is attempting to obtain a position outside the grid map size in the grid map search. Perhaps you could consider implementing the following changes in PerceptiveLeggedReferenceManager.cpp:

 // Base Orientation
    scalar_t step = 0.3;
    grid_map::Vector3 normalVector;
    bool not_in_map = false;

    if(grid_map::checkIfPositionWithinMap( pos + grid_map::Position(-step, 0),map.getLength(),map.getPosition()) )
      not_in_map = true;
    else if(grid_map::checkIfPositionWithinMap( pos + grid_map::Position(step, 0),map.getLength(),map.getPosition()) )
      not_in_map = true;
    else if(grid_map::checkIfPositionWithinMap( pos +grid_map::Position(0, -step),map.getLength(),map.getPosition()) )
      not_in_map = true;
    else if(grid_map::checkIfPositionWithinMap( pos + grid_map::Position(0, -step),map.getLength(),map.getPosition()) )
      not_in_map = true;

    if(not_in_map){
      normalVector(0) = 0.0;
      normalVector(1) = 0.0;
      normalVector(2) = 1;

    }else{
      normalVector(0) = (map.atPosition("smooth_planar", pos + grid_map::Position(-step, 0)) -
                        map.atPosition("smooth_planar", pos + grid_map::Position(step, 0))) /
                        (2 * step);
      normalVector(1) = (map.atPosition("smooth_planar", pos + grid_map::Position(0, -step)) -
                        map.atPosition("smooth_planar", pos + grid_map::Position(0, step))) /
                        (2 * step);
      normalVector(2) = 1;
    }
nanbwrn commented 7 months ago

hi,@YifuYuan ,@hgaren

Thank you so much for your timely reply!

After making modifications according to your method, the robot still falls during simulation, and the same error as before appears in the terminal. When I launch RViz, the polygons around the robot do not move along with the robot.

动画4

tony-hj commented 3 months ago

Hi @nanbwrn I have face the same error like you.Have you slove this problem?