tango_ros_conversions_helper.h
Go to the documentation of this file.
1 // Copyright 2017 Intermodalics All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef TANGO_ROS_CONVERSIONS_HELPER_H_
15 #define TANGO_ROS_CONVERSIONS_HELPER_H_
19 
20 #include <geometry_msgs/TransformStamped.h>
21 #include <nav_msgs/OccupancyGrid.h>
22 #include <sensor_msgs/CameraInfo.h>
23 #include <sensor_msgs/LaserScan.h>
24 #include <sensor_msgs/PointCloud2.h>
25 #include <sensor_msgs/PointField.h>
27 #include <visualization_msgs/MarkerArray.h>
28 
31 constexpr int8_t FREE_CELL = 0;
32 constexpr int8_t OCCUPIED_CELL = 100;
33 constexpr int8_t UNKNOWN_CELL = -1;
34 
35 // Converts a TangoPoseData to a geometry_msgs::TransformStamped.
36 // @param pose, TangoPoseData to convert.
37 // @param time_offset, offset in s between pose (tango time) and
38 // transform (ros time).
39 // @param transform, the output TransformStamped.
40 void toTransformStamped(const TangoPoseData& pose,
41  double time_offset,
42  const std::string& base_frame_id,
43  const std::string& target_frame_id,
44  geometry_msgs::TransformStamped* transform);
45 
46 // Converts a TangoPointCloud to a sensor_msgs::PointCloud2.
47 // @param tango_point_cloud, TangoPointCloud to convert.
48 // @param time_offset, offset in s between tango_point_cloud (tango time) and
49 // point_cloud (ros time).
50 // @param point_cloud, the output PointCloud2.
51 void toPointCloud2(const TangoPointCloud& tango_point_cloud,
52  double time_offset,
53  sensor_msgs::PointCloud2* point_cloud);
54 
55 // Convert a point to a laser scan range.
56 // Method taken from the ros package 'pointcloud_to_laserscan':
57 // http://wiki.ros.org/pointcloud_to_laserscan
58 // @param x x coordinate of the point in the laser scan frame.
59 // @param y y coordinate of the point in the laser scan frame.
60 // @param z z coordinate of the point in the laser scan frame.
61 // @param min_height minimum height for a point of the point cloud to be
62 // included in laser scan.
63 // @param max_height maximum height for a point of the point cloud to be
64 // included in laser scan.
65 // @param laser_scan, the output LaserScan containing the range data.
66 void toLaserScanRange(double x, double y, double z, double min_height,
67  double max_height, double min_range, double max_range,
68  sensor_msgs::LaserScan* laser_scan);
69 
70 // Converts a TangoPointCloud to a sensor_msgs::LaserScan.
71 // @param tango_point_cloud, TangoPointCloud to convert.
72 // @param time_offset, offset in s between tango_point_cloud (tango time) and
73 // laser_scan (ros time).
74 // @param min_height minimum height for a point of the point cloud to be
75 // included in laser scan.
76 // @param max_height maximum height for a point of the point cloud to be
77 // included in laser scan.
78 // @param point_cloud_T_laser transformation from point cloud to
79 // laser scan frame.
80 // @param laser_scan, the output LaserScan.
81 void toLaserScan(const TangoPointCloud& tango_point_cloud,
82  double time_offset,
83  double min_height,
84  double max_height,
85  double min_range,
86  double max_range,
87  const tf::Transform& point_cloud_T_laser,
88  sensor_msgs::LaserScan* laser_scan);
89 
90 // Converts a TangoCoordinateFrameType to a ros frame ID i.e. a string.
91 // @param tango_frame_type, TangoCoordinateFrameType to convert.
92 // @return returns the corresponding frame id.
93 std::string toFrameId(const TangoCoordinateFrameType& tango_frame_type);
94 
95 // Converts TangoCameraIntrinsics to sensor_msgs::CameraInfo.
96 // See Tango documentation:
97 // http://developers.google.com/tango/apis/unity/reference/class/tango/tango-camera-intrinsics
98 // And ROS documentation:
99 // http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html
100 // @param camera_intrinsics, TangoCameraIntrinsics to convert.
101 // @param camera_info, the output CameraInfo.
102 void toCameraInfo(const TangoCameraIntrinsics& camera_intrinsics,
103  sensor_msgs::CameraInfo* camera_info);
104 
105 // Converts TangoCameraIntrinsics to Tango3DR_CameraCalibration.
106 // @param camera_intrinsics, TangoCameraIntrinsics to convert.
107 // @param t3dr_camera_intrinsics, the output Tango3DR_CameraCalibration.
109  const TangoCameraIntrinsics& camera_intrinsics,
110  Tango3DR_CameraCalibration* t3dr_camera_intrinsics);
111 
112 // Converts TangoPoseData to Tango3DR_Pose.
113 // @param tango_pose_data, TangoPoseData to convert.
114 // @param t3dr_pose, the output Tango3DR_Pose.
115 void toTango3DR_Pose(const TangoPoseData& tango_pose_data, Tango3DR_Pose* t3dr_pose);
116 
117 // Converts Tango3DR_Mesh to visualization_msgs::Marker (TRIANGLE_LIST).
118 // See ROS documentation:
119 // http://docs.ros.org/api/visualization_msgs/html/msg/Marker.html
120 // @param grid_index, index of the tango_mesh.
121 // @param tango_mesh, Tango3DR_Mesh to convert.
122 // @param mesh_marker, the output visualization_msgs::Marker.
123 void toMeshMarker(const Tango3DR_GridIndex& grid_index,
124  const Tango3DR_Mesh& tango_mesh,
125  double time_offset, const std::string& base_frame_id,
126  visualization_msgs::Marker* mesh_marker);
127 
128 // Converts Tango3DR_ImageBuffer to nav_msgs::OccupancyGrid.
129 // See ROS documentation:
130 // http://docs.ros.org/kinetic/api/nav_msgs/html/msg/OccupancyGrid.html
131 // @param image_grid, Tango3DR_ImageBuffer to convert.
132 // @param origin, position of the top left pixel in
134 // @param resolution the grid resolution (m/cell).
135 // @param threshold Threshold to decide if a pixel value corresponds to a free
136 // or occupied cell. Should be between 0 and 255.
137 // Pixel value <= threshold --> cell is free.
138 // Pixel value > threshold --> cell is occupied.
139 // @param occupancy_grid, the output nav_msgs::OccupancyGrid.
140 void toOccupancyGrid(const Tango3DR_ImageBuffer& image_grid,
141  const Tango3DR_Vector2& origin, double time_offset,
142  const std::string& base_frame_id, double resolution,
143  uint8_t threshold, nav_msgs::OccupancyGrid* occupancy_grid);
144 
145 // Converts Tango3DR_Vector3 to geometry_msgs::Point.
146 // @param tango_vector, Tango3DR_Vector3 to convert.
147 // @param point, the output geometry_msgs::Point.
148 void toPoint(const Tango3DR_Vector3& tango_vector, geometry_msgs::Point* point);
149 
150 // Converts Tango3DR_Color to std_msgs::ColorRGBA.
151 // @param tango_color, Tango3DR_Color to convert.
152 // @param color, the output std_msgs::ColorRGBA.
153 void toColor(const Tango3DR_Color& tango_color, std_msgs::ColorRGBA* color);
154 } // namespace tango_ros_conversions_helper
155 #endif // TANGO_ROS_CONVERSIONS_HELPER_H_
TangoCoordinateFrameType
void toPointCloud2(const TangoPointCloud &tango_point_cloud, double time_offset, sensor_msgs::PointCloud2 *point_cloud)
void toTango3DR_Pose(const TangoPoseData &tango_pose_data, Tango3DR_Pose *t3dr_pose)
void toLaserScan(const TangoPointCloud &tango_point_cloud, double time_offset, double min_height, double max_height, double min_range, double max_range, const tf::Transform &point_cloud_T_laser, sensor_msgs::LaserScan *laser_scan)
float Tango3DR_Vector2[2]
void toColor(const Tango3DR_Color &tango_color, std_msgs::ColorRGBA *color)
void toTransformStamped(const TangoPoseData &pose, double time_offset, const std::string &base_frame_id, const std::string &target_frame_id, geometry_msgs::TransformStamped *transform)
std::string toFrameId(const TangoCoordinateFrameType &tango_frame_type)
void toCameraInfo(const TangoCameraIntrinsics &camera_intrinsics, sensor_msgs::CameraInfo *camera_info)
void toTango3DR_CameraCalibration(const TangoCameraIntrinsics &camera_intrinsics, Tango3DR_CameraCalibration *t3dr_camera_intrinsics)
void toLaserScanRange(double x, double y, double z, double min_height, double max_height, double min_range, double max_range, sensor_msgs::LaserScan *laser_scan)
float Tango3DR_Vector3[3]
void toPoint(const Tango3DR_Vector3 &tango_vector, geometry_msgs::Point *point)
void toOccupancyGrid(const Tango3DR_ImageBuffer &image_grid, const Tango3DR_Vector2 &origin, double time_offset, const std::string &base_frame_id, double resolution, uint8_t threshold, nav_msgs::OccupancyGrid *occupancy_grid)
world coordinates (x: right, y: up).
void toMeshMarker(const Tango3DR_GridIndex &grid_index, const Tango3DR_Mesh &tango_mesh, double time_offset, const std::string &base_frame_id, visualization_msgs::Marker *mesh_marker)
int Tango3DR_GridIndex[3]
uint8_t Tango3DR_Color[4]


tango_ros_native
Author(s):
autogenerated on Mon Jun 10 2019 15:37:51