Ask Your Question
0

How Extract Obstacle Information ?

asked 2014-04-07 23:51:24 -0600

mrshifo gravatar image

updated 2016-10-24 08:36:48 -0600

ngrennan gravatar image

Hi everybody,

I configured my non static map, but I have not figured out how to read information on obstacles. The type of topic (/move_base_node/local_costmap/obstacles) is nav_msgs::GridCells ?

I could use occupancy grid ?

thanks

#Independent settings for the planner's costmap
global_costmap:
    publish_voxel_map: true
    global_frame: odom
    robot_base_frame: base_footprint
    update_frequency: 2.5
    publish_frequency: 1.0
    static_map: false
    rolling_window: true
    width: 20.0
    height: 20.0
    resolution: 0.05
    origin_x: 0.0
    origin_y: 0.0

#Independent settings for the local costmap
local_costmap:
    publish_voxel_map: true
    global_frame: odom
    robot_base_frame: base_footprint
    update_frequency: 5.0
    publish_frequency: 2.0
    static_map: false
    rolling_window: true
    width: 10.0
    height: 10.0
    resolution: 0.05
    origin_x: 0.0
    origin_y: 0.0
map_type: costmap
transform_tolerance: 0.2
obstacle_range: 2.5
raytrace_range: 3.0
inflation_radius: 0.25

observation_sources: base_scan

#base_scan_marking: {sensor_frame: base_scan_link,
#                    data_type: PointCloud2,
#                    topic: /base_scan/marking,
#                    expected_update_rate: 0.2,
#                    observation_persistence: 0.0,
#                    marking: true,
#                    clearing: false,
#                    min_obstacle_height: 0.06,
#                    max_obstacle_height: 2.0}

base_scan: {sensor_frame: base_laser_front_link,
            data_type: LaserScan,
            topic: /base_scan,
            expected_update_rate: 0.2,
            observation_persistence: 0.0,
            marking: true,
            clearing: true,
            min_obstacle_height: -0.10,
            max_obstacle_height: 2.0}

#change this
footprint: [[0.26, 0.18],
            [0.26, 0.014],
            [0.31, 0.014],
            [0.31, -0.014],
            [0.26, -0.014],
            [0.26, -0.18],
            [-0.27, -0.18],
            [-0.27, 0.18]]

controller_frequency: 10.0
controller_patience: 15.0
clearing_radius: 0.25
footprint_padding: 0.03
edit retag flag offensive close merge delete

Comments

You have a problem with reading topic /move_base_node/local_costmap/obstacles? Is it epty or something else? Did not quite understand the question.

Mike Charikov gravatar image Mike Charikov  ( 2014-04-08 21:04:26 -0600 )edit

This is my code for read where are the obstacles: #include "ros/ros.h" #include "nav_msgs/GridCells.h" void chatterCallback(const nav_msgs::GridCells::ConstPtr& msg) { ROS_INFO("width: [%f]", msg->cell_width); ROS_INFO("height: [%f]", msg->cell_height); ROS_INFO("size: [%f]", msg->cells.size()); ROS_INFO("pos_x: [%f]", msg->cells[0].x); // segmentation fault if there are not obstacle's ROS_INFO("pos_y: [%f]", msg->cells[0].y); ROS_INFO("pos_z: [%f]", msg->cells[0].z); } int main(int argc, char **argv) { ros::init(argc, argv, "listener"); ros::NodeHandle n; ros::Subscriber sub = n.subscribe("/move_base_node/local_costmap/obstacles", 1000, chatterCallback); ros::spin(); return 0; } ---------------------------------------------------------------- The Problem is: if there are not obstacles: - return segmentation fault - width = 0.05 height =0.05 size =0.0000 how can I know the size of the array cells[] ? I would like to know if there are obstacles and where

mrshifo gravatar image mrshifo  ( 2014-04-09 00:24:43 -0600 )edit

msg->cells.size() ? You already have it in your code.

Mike Charikov gravatar image Mike Charikov  ( 2014-04-09 01:04:31 -0600 )edit

Yes but msg->cells.size() don't return the dimension of the array !! So how can I know the last index of the array cells[] ? ( https://www.dropbox.com/s/0e61wd46v4201jg/screen.png )

mrshifo gravatar image mrshifo  ( 2014-04-09 04:31:38 -0600 )edit

msg->cells[] is one-dimensional array, as far as i see. So, if msg->cells.size() == 0, then there are no obstacles. If msg->cells.size()>0, then the last index of array == msg->cells.size()-1. In your code you always read first member in array (cells[0]).

Mike Charikov gravatar image Mike Charikov  ( 2014-04-09 08:33:43 -0600 )edit

Thank you very much, but why ROS_INFO("size: [%f]", msg->cells.size()); return size = 0.05000 when there are obstacles ? the msg->cells.size() should return the number of cells occupied by obstacles but it did not happen.

mrshifo gravatar image mrshifo  ( 2014-04-09 12:58:57 -0600 )edit

Right !! Thank you very much, return the correct value. But I have noticed that sometimes the information remain obstacles in the map. I attach photos and configuration files. I do not understand why. https://www.dropbox.com/s/4bxzlid7e25mwuu/obstacle_remain.pnghttps://www.dropbox.com/s/4bxzlid7e25mwuu/obstacle_remain.pnghttps://www.dropbox.com/s/eu7xq4nzpbdrjeb/base_laser.pnghttps://www.dropbox.com/s/ygvetcp7j2yspuu/config.txt thanks

mrshifo gravatar image mrshifo  ( 2014-04-10 12:12:09 -0600 )edit

It's hard to say why: cannot corellate rviz and sim images on https://www.dropbox.com/s/4bxzlid7e25mwuu/obstacle_remain.png. Can you add laser visualisation in rviz?

Mike Charikov gravatar image Mike Charikov  ( 2014-04-10 23:46:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-04-09 22:05:26 -0600

Mike Charikov gravatar image

updated 2014-04-15 23:14:49 -0600

cells.size() has int type.

Try use ROS_INFO("size: [%d]", msg->cells.size()); Not %f.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2014-04-07 23:51:24 -0600

Seen: 623 times

Last updated: Apr 15 '14