ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to implement bumper pointcloud on a custom robot?

asked 2020-07-07 13:25:18 -0500

parzival gravatar image

I want to use the bumper information of my robot to add obstacles in the map. I have a custom robot and not a turtlebot so I can't simply use kobuki_bumper2pc. I tried reading the program and understanding their program, but I couldn't understand much.

I am getting the bumper pressed and released information for the two bumpers that I have on my robot. How do I use that to add obstacles in the costmap? I read about sensor_msgs/Pointcloud2 and I think I should convert my bumper messages to a pointcloud and add the pointcloud2 plugin in the costmap. But how to convert the bumper data to get the bumper pointcloud?

Lastly, since I want to use bumper data in mapping along with my laserscan, can I use this bumper pointcloud in gmapping as well? My other option is to use odometric navigation and store the global costmap, but it doesn't seem to be as accurate as gmapping obviously, Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-07-08 09:03:18 -0500

jordan gravatar image

Take a look at this implementation of a "virtual bumper" that does essentially what you want, but by using comparison of the odometry and pose data to detect collisions (no bump sensors needed!).

The key part of the code that populates the pointcloud is:

  // place obstacle into point cloud 0.25 meters in front of robot
  float val = 0.25;
  memcpy(&pointcloud_.data[0 * pointcloud_.point_step + pointcloud_.fields[0].offset], &val, sizeof(float));
  val = 0.0;
  memcpy(&pointcloud_.data[0 * pointcloud_.point_step + pointcloud_.fields[1].offset], &val, sizeof(float));

  pointcloud_.header.stamp = ros::Time::now();
  pointcloud_pub_.publish(pointcloud_);

  collision_pub_.publish(true);

In the above, an obstacle is placed 0.25 meters in front of the robot (when a collision occurs), and with a Y translation of zero. Note: if you have left and right bumpers, you would add +/-Y numbers for that instead of zero.

To get it to work with gmapping, you could try converting the pointcloud into a laserscan and then publish that (on the same topic as the regular scan). There are tools for this conversion such as http://wiki.ros.org/pointcloud_to_laserscan

Here's the full implementation of the virtual bumper. It's a working standalone node that you could run without modification. It assumes you have pose and odometry data from somewhere. This was tested with the navigation stack and worked fine when used to populate the costmap obstacle layer.

/*********************************************************************
*
* Software License Agreement (BSD License)
*
*  Copyright (c) 2019, Rhoeby Dynamics LLC
*  All rights reserved.
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*   * Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*   * Redistributions in binary form must reproduce the above
*     copyright notice, this list of conditions and the following
*     disclaimer in the documentation and/or other materials provided
*     with the distribution.
*   * Neither the name of the Rhoeby Dynamics nor the names of its
*     contributors may be used to endorse or promote products derived
*     from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*  POSSIBILITY OF SUCH DAMAGE.
*
*********************************************************************/

#include "ros/ros.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Twist.h"
#include "geometry_msgs/PoseWithCovarianceStamped.h"
#include "tf/tf.h"
#include "std_msgs/Bool.h"
#include "sensor_msgs/PointCloud2.h"

class VirtualBumper
{
  public:
    VirtualBumper();
    virtual ~VirtualBumper() {};

  protected:
    void odomCallback ...
(more)
edit flag offensive delete link more

Comments

Thanks for your answer! I'm however facing an issue with this. The pointcloud gets overwritten everytime there's a 'bump' event, which leads to oscillation in navigation when I add it to costmap obstacle layer. I instead want it to append the pointcloud, so it has all the bump events in account. How do I do that?

parzival gravatar image parzival  ( 2020-12-15 07:43:01 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-07 13:25:18 -0500

Seen: 391 times

Last updated: Jul 08 '20