messages.cpp
Go to the documentation of this file.
2 
3 handle_detector::CylinderArrayMsg Messages::createCylinderArray(const std::vector<CylindricalShell> &list,
4  std::string frame)
5 {
6  handle_detector::CylinderArrayMsg msg;
7  msg.header.stamp = ros::Time::now();
8  msg.header.frame_id = frame;
9  msg.cylinders.resize(list.size());
10 
11  for (std::size_t i = 0; i < list.size(); i++)
12  {
13  msg.cylinders[i] = createCylinder(list[i], frame);
14  }
15 
16  return msg;
17 }
18 
19 handle_detector::CylinderMsg Messages::createCylinder(const CylindricalShell &shell, std::string frame)
20 {
21  geometry_msgs::Pose pose;
22 
23  // cylinder position
24  pose.position.x = shell.getCentroid()(0);
25  pose.position.y = shell.getCentroid()(1);
26  pose.position.z = shell.getCentroid()(2);
27 
28  // create cylinder orientation from axes
29  geometry_msgs::PoseStamped cylinder_pose_msg;
30  Eigen::Vector3d axis_eigen = shell.getCurvatureAxis();
31  Eigen::Vector3d normal_eigen = shell.getNormal();
32  Eigen::Vector3d perp_eigen = normal_eigen.cross(axis_eigen);
33  tf::Matrix3x3 rotation_matrix(perp_eigen(0), normal_eigen(0), axis_eigen(0), perp_eigen(1), normal_eigen(1),
34  axis_eigen(1), perp_eigen(2), normal_eigen(2), axis_eigen(2));
35  tf::Quaternion quaternion;
36  rotation_matrix.getRotation(quaternion);
37  tf::Stamped<tf::Transform> cylinder_tf_pose(tf::Transform(quaternion), ros::Time::now(), frame);
38  tf::poseStampedTFToMsg(cylinder_tf_pose, cylinder_pose_msg);
39  pose.orientation = cylinder_pose_msg.pose.orientation;
40 
41  // create message
42  handle_detector::CylinderMsg cylinder_msg;
43  cylinder_msg.pose = pose;
44  cylinder_msg.radius = shell.getRadius();
45  cylinder_msg.extent = shell.getExtent();
46  geometry_msgs::Vector3 axis_msg;
47  tf::vectorEigenToMsg(axis_eigen, axis_msg);
48  geometry_msgs::Vector3 normal_msg;
49  tf::vectorEigenToMsg(normal_eigen, normal_msg);
50  cylinder_msg.axis = axis_msg;
51  cylinder_msg.normal = normal_msg;
52  return cylinder_msg;
53 }
54 
55 handle_detector::HandleListMsg Messages::createHandleList(const std::vector<std::vector<CylindricalShell> > &handles,
56  std::string frame)
57 {
58  handle_detector::HandleListMsg msg;
59  msg.header.stamp = ros::Time::now();
60  msg.header.frame_id = frame;
61  msg.handles.resize(handles.size());
62 
63  for (std::size_t i = 0; i < handles.size(); i++)
64  msg.handles[i] = createCylinderArray(handles[i], frame);
65 
66  return msg;
67 }
double getExtent() const
Get the extent of the cylindrical shell.
CylindricalShell represents a cylindrical shell that consists of two colinear cylinders. A shell consists of an inner and an outer cylinder. The portion of the object to be grasped must fit inside the inner cylinder, and the radius of that cylinder must be no larger than the maximum hand aperture. The gap between the inner and outer cylinder must be free of obstacles and wide enough to be able to contain the robot fingers.
static void poseStampedTFToMsg(const Stamped< Pose > &bt, geometry_msgs::PoseStamped &msg)
handle_detector::CylinderArrayMsg createCylinderArray(const std::vector< CylindricalShell > &list, std::string frame)
Create a CylinderArray message from a list of cylindrical shells.
Definition: messages.cpp:3
void getRotation(Quaternion &q) const
handle_detector::HandleListMsg createHandleList(const std::vector< std::vector< CylindricalShell > > &handles, std::string frame)
Create a HandleList message from a list of cylindrical shells.
Definition: messages.cpp:55
Eigen::Vector3d getNormal() const
Get the normal axis of the cylindrical shell.
void vectorEigenToMsg(const Eigen::Vector3d &e, geometry_msgs::Vector3 &m)
handle_detector::CylinderMsg createCylinder(const CylindricalShell &shell, std::string frame)
Create a Cylinder message from a cylindrical shell.
Definition: messages.cpp:19
Eigen::Vector3d getCurvatureAxis() const
Get the curvature axis of the cylindrical shell.
Eigen::Vector3d getCentroid() const
Get the centroid of the cylindrical shell.
static Time now()
double getRadius() const
Get the radius of the cylindrical shell.


handle_detector
Author(s):
autogenerated on Mon Jun 10 2019 13:29:00