tango_ros_conversions_helper.h
Go to the documentation of this file.
00001 // Copyright 2017 Intermodalics All Rights Reserved.
00002 //
00003 // Licensed under the Apache License, Version 2.0 (the "License");
00004 // you may not use this file except in compliance with the License.
00005 // You may obtain a copy of the License at
00006 //
00007 //      http://www.apache.org/licenses/LICENSE-2.0
00008 //
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00014 #ifndef TANGO_ROS_CONVERSIONS_HELPER_H_
00015 #define TANGO_ROS_CONVERSIONS_HELPER_H_
00016 #include <tango_3d_reconstruction/tango_3d_reconstruction_api.h>
00017 #include <tango_client_api/tango_client_api.h>
00018 #include <tango_support/tango_support.h>
00019 
00020 #include <geometry_msgs/TransformStamped.h>
00021 #include <nav_msgs/OccupancyGrid.h>
00022 #include <sensor_msgs/CameraInfo.h>
00023 #include <sensor_msgs/LaserScan.h>
00024 #include <sensor_msgs/PointCloud2.h>
00025 #include <sensor_msgs/PointField.h>
00026 #include <tf/LinearMath/Transform.h>
00027 #include <visualization_msgs/MarkerArray.h>
00028 
00029 namespace tango_ros_conversions_helper {
00030 const int NUMBER_OF_FIELDS_IN_POINT_CLOUD = 4;
00031 constexpr int8_t FREE_CELL = 0;
00032 constexpr int8_t OCCUPIED_CELL = 100;
00033 constexpr int8_t UNKNOWN_CELL = -1;
00034 
00035 // Converts a TangoPoseData to a geometry_msgs::TransformStamped.
00036 // @param pose, TangoPoseData to convert.
00037 // @param time_offset, offset in s between pose (tango time) and
00038 //        transform (ros time).
00039 // @param transform, the output TransformStamped.
00040 void toTransformStamped(const TangoPoseData& pose,
00041                         double time_offset,
00042                         const std::string& base_frame_id,
00043                         const std::string& target_frame_id,
00044                         geometry_msgs::TransformStamped* transform);
00045 
00046 // Converts a TangoPointCloud to a sensor_msgs::PointCloud2.
00047 // @param tango_point_cloud, TangoPointCloud to convert.
00048 // @param time_offset, offset in s between tango_point_cloud (tango time) and
00049 //        point_cloud (ros time).
00050 // @param point_cloud, the output PointCloud2.
00051 void toPointCloud2(const TangoPointCloud& tango_point_cloud,
00052                    double time_offset,
00053                    sensor_msgs::PointCloud2* point_cloud);
00054 
00055 // Convert a point to a laser scan range.
00056 // Method taken from the ros package 'pointcloud_to_laserscan':
00057 // http://wiki.ros.org/pointcloud_to_laserscan
00058 // @param x x coordinate of the point in the laser scan frame.
00059 // @param y y coordinate of the point in the laser scan frame.
00060 // @param z z coordinate of the point in the laser scan frame.
00061 // @param min_height minimum height for a point of the point cloud to be
00062 // included in laser scan.
00063 // @param max_height maximum height for a point of the point cloud to be
00064 // included in laser scan.
00065 // @param laser_scan, the output LaserScan containing the range data.
00066 void toLaserScanRange(double x, double y, double z, double min_height,
00067                       double max_height, double min_range, double max_range,
00068                       sensor_msgs::LaserScan* laser_scan);
00069 
00070 // Converts a TangoPointCloud to a sensor_msgs::LaserScan.
00071 // @param tango_point_cloud, TangoPointCloud to convert.
00072 // @param time_offset, offset in s between tango_point_cloud (tango time) and
00073 //        laser_scan (ros time).
00074 // @param min_height minimum height for a point of the point cloud to be
00075 // included in laser scan.
00076 // @param max_height maximum height for a point of the point cloud to be
00077 // included in laser scan.
00078 // @param point_cloud_T_laser transformation from point cloud to
00079 // laser scan frame.
00080 // @param laser_scan, the output LaserScan.
00081 void toLaserScan(const TangoPointCloud& tango_point_cloud,
00082                  double time_offset,
00083                  double min_height,
00084                  double max_height,
00085                  double min_range,
00086                  double max_range,
00087                  const tf::Transform& point_cloud_T_laser,
00088                  sensor_msgs::LaserScan* laser_scan);
00089 
00090 // Converts a TangoCoordinateFrameType to a ros frame ID i.e. a string.
00091 // @param tango_frame_type, TangoCoordinateFrameType to convert.
00092 // @return returns the corresponding frame id.
00093 std::string toFrameId(const TangoCoordinateFrameType& tango_frame_type);
00094 
00095 // Converts TangoCameraIntrinsics to sensor_msgs::CameraInfo.
00096 // See Tango documentation:
00097 // http://developers.google.com/tango/apis/unity/reference/class/tango/tango-camera-intrinsics
00098 // And ROS documentation:
00099 // http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html
00100 // @param camera_intrinsics, TangoCameraIntrinsics to convert.
00101 // @param camera_info, the output CameraInfo.
00102 void toCameraInfo(const TangoCameraIntrinsics& camera_intrinsics,
00103                   sensor_msgs::CameraInfo* camera_info);
00104 
00105 // Converts TangoCameraIntrinsics to Tango3DR_CameraCalibration.
00106 // @param camera_intrinsics, TangoCameraIntrinsics to convert.
00107 // @param t3dr_camera_intrinsics, the output Tango3DR_CameraCalibration.
00108 void toTango3DR_CameraCalibration(
00109     const TangoCameraIntrinsics& camera_intrinsics,
00110     Tango3DR_CameraCalibration* t3dr_camera_intrinsics);
00111 
00112 // Converts TangoPoseData to Tango3DR_Pose.
00113 // @param tango_pose_data, TangoPoseData to convert.
00114 // @param t3dr_pose, the output Tango3DR_Pose.
00115 void toTango3DR_Pose(const TangoPoseData& tango_pose_data, Tango3DR_Pose* t3dr_pose);
00116 
00117 // Converts Tango3DR_Mesh to visualization_msgs::Marker (TRIANGLE_LIST).
00118 // See ROS documentation:
00119 // http://docs.ros.org/api/visualization_msgs/html/msg/Marker.html
00120 // @param grid_index, index of the tango_mesh.
00121 // @param tango_mesh, Tango3DR_Mesh to convert.
00122 // @param mesh_marker, the output visualization_msgs::Marker.
00123 void toMeshMarker(const Tango3DR_GridIndex& grid_index,
00124                   const Tango3DR_Mesh& tango_mesh,
00125                   double time_offset, const std::string& base_frame_id,
00126                   visualization_msgs::Marker* mesh_marker);
00127 
00128 // Converts Tango3DR_ImageBuffer to nav_msgs::OccupancyGrid.
00129 // See ROS documentation:
00130 // http://docs.ros.org/kinetic/api/nav_msgs/html/msg/OccupancyGrid.html
00131 // @param image_grid, Tango3DR_ImageBuffer to convert.
00132 // @param origin, position of the top left pixel in
00134 // @param resolution the grid resolution (m/cell).
00135 // @param threshold Threshold to decide if a pixel value corresponds to a free
00136 // or occupied cell. Should be between 0 and 255.
00137 // Pixel value <= threshold --> cell is free.
00138 // Pixel value > threshold --> cell is occupied.
00139 // @param occupancy_grid, the output nav_msgs::OccupancyGrid.
00140 void toOccupancyGrid(const Tango3DR_ImageBuffer& image_grid,
00141                      const Tango3DR_Vector2& origin, double time_offset,
00142                      const std::string& base_frame_id, double resolution,
00143                      uint8_t threshold, nav_msgs::OccupancyGrid* occupancy_grid);
00144 
00145 // Converts Tango3DR_Vector3 to geometry_msgs::Point.
00146 // @param tango_vector, Tango3DR_Vector3 to convert.
00147 // @param point, the output geometry_msgs::Point.
00148 void toPoint(const Tango3DR_Vector3& tango_vector, geometry_msgs::Point* point);
00149 
00150 // Converts Tango3DR_Color to std_msgs::ColorRGBA.
00151 // @param tango_color, Tango3DR_Color to convert.
00152 // @param color, the output std_msgs::ColorRGBA.
00153 void toColor(const Tango3DR_Color& tango_color, std_msgs::ColorRGBA* color);
00154 } // namespace tango_ros_conversions_helper
00155 #endif  // TANGO_ROS_CONVERSIONS_HELPER_H_


tango_ros_native
Author(s):
autogenerated on Thu Jun 6 2019 19:49:54