RangeSensorLayer::updateBounds Segmentation fault maxbotix

asked 2018-11-12 08:34:44 -0500

blackwhite46 gravatar image

updated 2018-11-12 08:51:38 -0500

Hi All,

I like to integrate ultrasonic sensors into costmap bu getting following error when I run the move_base.

Thread 11 "move_base" received signal  SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffcb7fe700 (LWP 9665)] 0x00007fffe4069067 in range_sensor_layer::RangeSensorLayer::updateBounds(double,double, double, double*, double*, double*, double*) ()    from /opt/ros/kinetic/lib//librange_sensor_layer.so

local costmap:

local_costmap:
  global_frame: /map
  robot_base_frame: base_link
  update_frequency: 2.0
  publish_frequency: 1.0
  static_map: false
  rolling_window: true
  width: 1.0
  height: 1.0
  resolution: 0.05
  transform_tolerance: 0.5

  plugins:
   - {name: range_sensor_layer,  type: "range_sensor_layer::RangeSensorLayer"}
   - {name: static_layer,        type: "costmap_2d::StaticLayer"}
   - {name: obstacle_layer,      type: "costmap_2d::ObstacleLayer"}

  # - {name: inflation_layer,     type: "costmap_2d::InflationLayer"}

global costmap:

global_costmap:
  global_frame: /map
  robot_base_frame: base_link
  update_frequency: 2.0
  publish_frequency: 1.0
  rolling_window: false
  static_map: true
  width: 3
  height: 3

  transform_tolerance: 0.5
  plugins:

    #- {name: range_sensor_layer,  type: "range_sensor_layer::RangeSensorLayer"}
    - {name: static_layer,            type: "costmap_2d::StaticLayer"}
    - {name: obstacle_layer,          type: "costmap_2d::ObstacleLayer"}
    #- {name: inflation_layer,         type: "costmap_2d::InflationLayer"}
       #- {name: inflation_layer,     type: "costmap_2d::InflationLayer"}

common costmap:

footprint: [ [-0.05,-0.05], [0.05,-0.05], [0.05,0.05], [-0.05,0.05] ]


transform_tolerance: 0.2
map_type: costmap


obstacle_layer:
 enabled: true
 obstacle_range: 3.0
 raytrace_range: 3.5
 inflation_radius: 0.1
 track_unknown_space: false
 combination_method: 1

 observation_sources: laser_scan_sensor
 laser_scan_sensor: {data_type: LaserScan, topic: scan, marking: true, clearing: true}

range_sensor_layer:
    topics: ["/ultrasound", "/ultrasound1"]
    no_readings_timeout: 0.0
    clear_threshold: 0.46
    mark_threshold: 0.98



static_layer:
  enabled:              true
  map_topic:            "/map"


inflation_layer:
  enabled:              true
  cost_scaling_factor:  5.0  # exponential rate at which the obstacle cost drops off (default: 10)
  inflation_radius:     0.1  # max. distance from an obstacle at which costs are incurred for planning paths.

reading from arduino:

#include <ros.h>
#include <ros/time.h>
#include <sensor_msgs/Range.h>

ros::NodeHandle  nh;

sensor_msgs::Range range_msg;
sensor_msgs::Range range_msg1;
ros::Publisher pub_range( "/ultrasound", &range_msg);
ros::Publisher pub_range1("/ultrasound1", &range_msg1);


char frameid[] = "/ultrasound";
char frameid1[] = "/ultrasound1";

float getRange_Ultrasound(int pin_num){
  int val = 0;
  val=analogRead(pin_num);

  float range =  val;
  return range/81;   // (0.0124023437 /4) ; //cvt to meters
}

void setup()
{
  nh.initNode();
  nh.advertise(pub_range);
  nh.advertise(pub_range1);


  range_msg.radiation_type = sensor_msgs::Range::ULTRASOUND;
  range_msg.header.frame_id =  frameid;
  range_msg.field_of_view = 0.1;  // fake
  range_msg.min_range = 0.0;
  range_msg.max_range = 6.47;

  range_msg1.radiation_type = sensor_msgs::Range::ULTRASOUND;
  range_msg1.header.frame_id =  frameid1;
  range_msg1.field_of_view = 0.1;  // fake
  range_msg1.min_range = 0.0;
  range_msg1.max_range = 6.47;

  pinMode(8,OUTPUT);
  digitalWrite(8, LOW);
}


long range_time;

void loop()
{

  //publish the adc value every 50 milliseconds
  //since it takes that long for the sensor to stablize
  if ( millis() >= range_time ){
    int r =0;

    range_msg.range = getRange_Ultrasound(0);
    range_msg.header.stamp = nh.now();
    pub_range.publish(&range_msg);

    range_msg1.range = getRange_Ultrasound(1);
    range_msg1.header.stamp = nh.now();
    pub_range1.publish(&range_msg1);

    range_time =  millis() + 50;
  }

  nh.spinOnce();
}

I could not found the reason for the problem. Is there anyone can suggest a solution to that problem?

Thanks

edit retag flag offensive close merge delete

Comments

Does it segfault without the range layer enabled?

David Lu gravatar image David Lu  ( 2018-11-12 13:47:47 -0500 )edit

Hi David,

No. It only gives error when range layer is enabled.

blackwhite46 gravatar image blackwhite46  ( 2018-11-12 13:54:54 -0500 )edit

Can you record a bag with your tf and range data and post it?

David Lu gravatar image David Lu  ( 2018-11-12 15:28:19 -0500 )edit

Here it is.

blackwhite46 gravatar image blackwhite46  ( 2018-11-13 03:11:19 -0500 )edit

Apologies for the delay in responding, but I finally got around to testing your bag and could not replicate the error. Are you still having trouble?

David Lu gravatar image David Lu  ( 2019-02-25 14:35:15 -0500 )edit

Hi David,

I could not exactly found a solution for my PC but it is working fine on my SBC. It is only not working with my current PC.

blackwhite46 gravatar image blackwhite46  ( 2019-02-26 02:52:49 -0500 )edit

What are the specs on your PC in terms of distro/buildtool?

David Lu gravatar image David Lu  ( 2019-02-26 07:45:45 -0500 )edit