robot_finder.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2022 Michael Ferguson
3  * Copyright (C) 2015-2017 Fetch Robotics Inc.
4  * Copyright (C) 2013-2014 Unbounded Robotics Inc.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 // Author: Niharika Arora, Michael Ferguson
20 
21 #include <math.h>
26 
28 
29 namespace robot_calibration
30 {
31 
32 const unsigned X = 0;
33 const unsigned Y = 1;
34 const unsigned Z = 2;
35 
37  PlaneFinder()
38 {
39 }
40 
41 bool RobotFinder::init(const std::string& name,
42  ros::NodeHandle & nh)
43 {
44  if (!PlaneFinder::init(name, nh))
45  return false;
46 
47  // Name of the sensor model that will be used during optimization
48  nh.param<std::string>("robot_sensor_name", robot_sensor_name_, "camera_robot");
49 
50  // Publish the observation as a PointCloud2
51  robot_publisher_ = nh.advertise<sensor_msgs::PointCloud2>(getName() + "_robot_points", 10);
52 
53  // Valid points must lie within this box, in the transform_frame
54  nh.param<double>("min_robot_x", min_robot_x_, -2.0);
55  nh.param<double>("max_robot_x", max_robot_x_, 2.0);
56  nh.param<double>("min_robot_y", min_robot_y_, -2.0);
57  nh.param<double>("max_robot_y", max_robot_y_, 2.0);
58  nh.param<double>("min_robot_z", min_robot_z_, 0.0);
59  nh.param<double>("max_robot_z", max_robot_z_, 2.0);
60 
61  return true;
62 }
63 
64 bool RobotFinder::find(robot_calibration_msgs::CalibrationData * msg)
65 {
66  if (!waitForCloud())
67  {
68  ROS_ERROR("No point cloud data");
69  return false;
70  }
71 
72  // Remove invalid points
74 
75  // Find the ground plane and extract it
76  sensor_msgs::PointCloud2 plane = extractPlane(cloud_);
77 
78  // Remove anything that isn't the robot from the cloud
81 
82  // Pull out both sets of observations
85 
86  // Report success
87  return true;
88 }
89 
90 } // namespace robot_calibration
virtual bool init(const std::string &name, ros::NodeHandle &n)
Initialize the feature finder.
Base class for a feature finder.
virtual void removeInvalidPoints(sensor_msgs::PointCloud2 &cloud, double min_x, double max_x, double min_y, double max_y, double min_z, double max_z)
Remove invalid points from a cloud.
#define ROS_ERROR(...)
virtual bool find(robot_calibration_msgs::CalibrationData *msg)
Once the robot has been moved into the proper position and settled, this function will be called...
virtual sensor_msgs::PointCloud2 extractPlane(sensor_msgs::PointCloud2 &cloud)
Extract a plane from the point cloud.
bool param(const std::string &param_name, T &param_val, const T &default_val) const
sensor_msgs::PointCloud2 cloud_
Definition: plane_finder.h:92
virtual bool waitForCloud()
Wait until a new cloud has arrived.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::string getName()
Get the name of this feature finder.
Calibration code lives under this namespace.
virtual bool init(const std::string &name, ros::NodeHandle &n)
Initialize the feature finder.
virtual void extractObservation(const std::string &sensor_name, const sensor_msgs::PointCloud2 &cloud, robot_calibration_msgs::CalibrationData *msg, ros::Publisher *publisher)
Extract points from a cloud into a calibration message.
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
Finds the largest plane in a point cloud.
Definition: plane_finder.h:34


robot_calibration
Author(s): Michael Ferguson
autogenerated on Wed May 24 2023 02:30:23