[mrpt-ros1bridge]
Conversion between MRPT and ROS 1 types.
Library mrpt-ros1bridge
This C++ library is part of MRPT and can be installed in Debian-based systems with:
sudo apt install libmrpt-ros1bridge-dev
Read also how to import MRPT into your CMake scripts.
Library contents
// namespaces namespace mrpt::ros1bridge; // classes class mrpt::ros1bridge::MapHdl; // global functions bool mrpt::ros1bridge::fromROS(const nav_msgs::OccupancyGrid& src, mrpt::maps::COccupancyGridMap2D& des); bool mrpt::ros1bridge::toROS(const mrpt::maps::COccupancyGridMap2D& src, nav_msgs::OccupancyGrid& msg, const std_msgs::Header& header); bool mrpt::ros1bridge::toROS(const mrpt::maps::COccupancyGridMap2D& src, nav_msgs::OccupancyGrid& msg); bool mrpt::ros1bridge::fromROS(const sensor_msgs::PointCloud& msg, mrpt::maps::CSimplePointsMap& obj); bool mrpt::ros1bridge::toROS( const mrpt::maps::CSimplePointsMap& obj, const std_msgs::Header& msg_header, sensor_msgs::PointCloud& msg ); bool mrpt::ros1bridge::fromROS(const sensor_msgs::PointCloud2& msg, mrpt::maps::CSimplePointsMap& obj); bool mrpt::ros1bridge::fromROS( const sensor_msgs::PointCloud2& msg, mrpt::maps::CPointsMapXYZI& obj ); bool mrpt::ros1bridge::fromROS( const sensor_msgs::PointCloud2& m, mrpt::obs::CObservationRotatingScan& o, const mrpt::poses::CPose3D& sensorPoseOnRobot, unsigned int num_azimuth_divisions = 360 ); std::set<std::string> mrpt::ros1bridge::extractFields(const sensor_msgs::PointCloud2& msg); bool mrpt::ros1bridge::toROS( const mrpt::maps::CSimplePointsMap& obj, const std_msgs::Header& msg_header, sensor_msgs::PointCloud2& msg ); bool mrpt::ros1bridge::fromROS(const sensor_msgs::NavSatFix& msg, mrpt::obs::CObservationGPS& obj); bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservationGPS& obj, const std_msgs::Header& msg_header, sensor_msgs::NavSatFix& msg ); mrpt::img::CImage mrpt::ros1bridge::fromROS(const sensor_msgs::Image& i); sensor_msgs::Image mrpt::ros1bridge::toROS(const mrpt::img::CImage& i, const std_msgs::Header& msg_header); bool mrpt::ros1bridge::fromROS(const sensor_msgs::Imu& msg, mrpt::obs::CObservationIMU& obj); bool mrpt::ros1bridge::toROS(const mrpt::obs::CObservationIMU& obj, const std_msgs::Header& msg_header, sensor_msgs::Imu& msg); bool mrpt::ros1bridge::fromROS(const sensor_msgs::LaserScan& msg, const mrpt::poses::CPose3D& pose, mrpt::obs::CObservation2DRangeScan& obj); bool mrpt::ros1bridge::toROS(const mrpt::obs::CObservation2DRangeScan& obj, sensor_msgs::LaserScan& msg); bool mrpt::ros1bridge::toROS(const mrpt::obs::CObservation2DRangeScan& obj, sensor_msgs::LaserScan& msg, geometry_msgs::Pose& pose); tf2::Matrix3x3 mrpt::ros1bridge::toROS(const mrpt::math::CMatrixDouble33& src); tf2::Transform mrpt::ros1bridge::toROS_tfTransform(const mrpt::poses::CPose2D& src); geometry_msgs::Pose mrpt::ros1bridge::toROS_Pose(const mrpt::poses::CPose2D& src); tf2::Transform mrpt::ros1bridge::toROS_tfTransform(const mrpt::math::TPose2D& src); geometry_msgs::Pose mrpt::ros1bridge::toROS_Pose(const mrpt::math::TPose2D& src); tf2::Transform mrpt::ros1bridge::toROS_tfTransform(const mrpt::poses::CPose3D& src); geometry_msgs::Pose mrpt::ros1bridge::toROS_Pose(const mrpt::poses::CPose3D& src); tf2::Transform mrpt::ros1bridge::toROS_tfTransform(const mrpt::math::TPose3D& src); geometry_msgs::Pose mrpt::ros1bridge::toROS_Pose(const mrpt::math::TPose3D& src); geometry_msgs::PoseWithCovariance mrpt::ros1bridge::toROS_Pose(const mrpt::poses::CPose3DPDFGaussian& src); geometry_msgs::PoseWithCovariance mrpt::ros1bridge::toROS(const mrpt::poses::CPose3DPDFGaussianInf& src); geometry_msgs::PoseWithCovariance mrpt::ros1bridge::toROS(const mrpt::poses::CPosePDFGaussian& src); geometry_msgs::PoseWithCovariance mrpt::ros1bridge::toROS(const mrpt::poses::CPosePDFGaussianInf& src); geometry_msgs::Quaternion mrpt::ros1bridge::toROS(const mrpt::math::CQuaternionDouble& src); mrpt::poses::CPose3D mrpt::ros1bridge::fromROS(const tf2::Transform& src); mrpt::math::CMatrixDouble33 mrpt::ros1bridge::fromROS(const tf2::Matrix3x3& src); mrpt::poses::CPose3D mrpt::ros1bridge::fromROS(const geometry_msgs::Pose& src); mrpt::poses::CPose3DPDFGaussian mrpt::ros1bridge::fromROS(const geometry_msgs::PoseWithCovariance& src); mrpt::math::CQuaternionDouble mrpt::ros1bridge::fromROS(const geometry_msgs::Quaternion& src); bool mrpt::ros1bridge::fromROS(const sensor_msgs::Range& msg, mrpt::obs::CObservationRange& obj); bool mrpt::ros1bridge::toROS(const mrpt::obs::CObservationRange& obj, const std_msgs::Header& msg_header, sensor_msgs::Range* msg); bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservationStereoImages& obj, const std_msgs::Header& msg_header, sensor_msgs::Image& left, sensor_msgs::Image& right, stereo_msgs::DisparityImage& disparity ); mrpt::system::TTimeStamp mrpt::ros1bridge::fromROS(const ros::Time& src); ros::Time mrpt::ros1bridge::toROS(const mrpt::system::TTimeStamp& src);
Global Functions
bool mrpt::ros1bridge::fromROS(const nav_msgs::OccupancyGrid& src, mrpt::maps::COccupancyGridMap2D& des)
converts ros msg to mrpt object
Parameters:
src |
|
des |
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::toROS( const mrpt::maps::COccupancyGridMap2D& src, nav_msgs::OccupancyGrid& msg, const std_msgs::Header& header )
converts mrpt object to ros msg and updates the msg header
Parameters:
src |
|
header |
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::toROS(const mrpt::maps::COccupancyGridMap2D& src, nav_msgs::OccupancyGrid& msg)
converts mrpt object to ros msg
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::fromROS(const sensor_msgs::PointCloud& msg, mrpt::maps::CSimplePointsMap& obj)
Convert sensor_msgs/PointCloud -> mrpt::maps::CSimplePointsMap CSimplePointsMap only contains (x,y,z) data, so sensor_msgs::PointCloud::channels are ignored.
Returns:
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::toROS( const mrpt::maps::CSimplePointsMap& obj, const std_msgs::Header& msg_header, sensor_msgs::PointCloud& msg )
Convert mrpt::maps::CSimplePointsMap -> sensor_msgs/PointCloud The user must supply the “msg_header” field to be copied into the output message object, since that part does not appear in MRPT classes.
Since CSimplePointsMap only contains (x,y,z) data, sensor_msgs::PointCloud::channels will be empty.
Returns:
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::fromROS(const sensor_msgs::PointCloud2& msg, mrpt::maps::CSimplePointsMap& obj)
Convert sensor_msgs/PointCloud2 -> mrpt::slam::CSimplePointsMap Only (x,y,z) data is converted.
Convert sensor_msgs/PointCloud2 -> mrpt::slam::CSimplePointsMap.
To use the intensity channel, see the alternative signature for CPointsMapXYZI. Requires point cloud fields: x,y,z.
Returns:
true on sucessful conversion, false on any error.
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::fromROS( const sensor_msgs::PointCloud2& m, mrpt::obs::CObservationRotatingScan& o, const mrpt::poses::CPose3D& sensorPoseOnRobot, unsigned int num_azimuth_divisions = 360 )
Convert sensor_msgs/PointCloud2 -> mrpt::obs::CObservationRotatingScan.
Requires point cloud fields: x,y,z,intensity,ring
std::set<std::string> mrpt::ros1bridge::extractFields(const sensor_msgs::PointCloud2& msg)
Extract a list of fields found in the point cloud.
Typically: {“x”,”y”,”z”,”intensity”}
bool mrpt::ros1bridge::toROS( const mrpt::maps::CSimplePointsMap& obj, const std_msgs::Header& msg_header, sensor_msgs::PointCloud2& msg )
Convert mrpt::slam::CSimplePointsMap -> sensor_msgs/PointCloud2 The user must supply the “msg_header” field to be copied into the output message object, since that part does not appear in MRPT classes.
Since CSimplePointsMap only contains (x,y,z) data, sensor_msgs::PointCloud2::channels will be empty. Since CSimplePointsMap only contains (x,y,z) data, sensor_msgs::PointCloud2::channels will be empty.
Returns:
true on sucessful conversion, false on any error.
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::fromROS(const sensor_msgs::NavSatFix& msg, mrpt::obs::CObservationGPS& obj)
Convert sensor_msgs/NavSatFix -> mrpt::obs::CObservationGPS.
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservationGPS& obj, const std_msgs::Header& msg_header, sensor_msgs::NavSatFix& msg )
Convert mrpt::obs::CObservationGPS -> sensor_msgs/NavSatFix The user must supply the “msg_header” field to be copied into the output message object, since that part does not appear in MRPT classes.
Since COnservationGPS does not contain “position_covariance” and “position_covariance_type” sensor_msgs::NavSatFix::position_covariance_type and sensor_msgs::NavSatFix::position_covariance will be empty.
Returns:
true on sucessful conversion, false on any error.
mrpt::img::CImage mrpt::ros1bridge::fromROS(const sensor_msgs::Image& i)
Makes a deep copy of the image data.
sensor_msgs::Image mrpt::ros1bridge::toROS( const mrpt::img::CImage& i, const std_msgs::Header& msg_header )
Makes a deep copy of the image data.
bool mrpt::ros1bridge::fromROS(const sensor_msgs::Imu& msg, mrpt::obs::CObservationIMU& obj)
Convert sensor_msgs/Imu -> mrpt::obs::CObservationIMU // STILL NEED TO WRITE CODE FOR COVARIANCE.
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservationIMU& obj, const std_msgs::Header& msg_header, sensor_msgs::Imu& msg )
Convert mrpt::obs::CObservationIMU -> sensor_msgs/Imu The user must supply the “msg_header” field to be copied into the output message object, since that part does not appear in MRPT classes.
Since COnservationIMU does not contain covariance terms NEED TO fix those.
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::fromROS( const sensor_msgs::LaserScan& msg, const mrpt::poses::CPose3D& pose, mrpt::obs::CObservation2DRangeScan& obj )
ROS->MRPT: Takes a sensor_msgs::LaserScan and the relative pose of the laser wrt base_link and builds a CObservation2DRangeScan.
Returns:
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::toROS(const mrpt::obs::CObservation2DRangeScan& obj, sensor_msgs::LaserScan& msg)
MRPT->ROS: Takes a CObservation2DRangeScan and outputs range data in sensor_msgs::LaserScan.
Returns:
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservation2DRangeScan& obj, sensor_msgs::LaserScan& msg, geometry_msgs::Pose& pose )
MRPT->ROS: Takes a CObservation2DRangeScan and outputs range data in sensor_msgs::LaserScan + the relative pose of the laser wrt base_link.
Returns:
true on sucessful conversion, false on any error.
See also:
bool mrpt::ros1bridge::fromROS(const sensor_msgs::Range& msg, mrpt::obs::CObservationRange& obj)
Convert sensor_msgs/Range -> mrpt::obs::CObservationRange.
Returns:
true on sucessful conversion, false on any error.
bool mrpt::ros1bridge::toROS( const mrpt::obs::CObservationRange& obj, const std_msgs::Header& msg_header, sensor_msgs::Range* msg )
Convert mrpt::obs::CObservationRange -> sensor_msgs/Range The user must supply the “msg_header” field to be copied into the output message object, since that part does not appear in MRPT classes.
Since COnservation does not contain “radiation_type”, sensor_msgs::Range::radiation_type will be empty.
Returns:
true on sucessful conversion, false on any error.
mrpt::system::TTimeStamp mrpt::ros1bridge::fromROS(const ros::Time& src)
converts ros time to mrpt time
Parameters:
src |
ros time |
des |
mrpt time |
ros::Time mrpt::ros1bridge::toROS(const mrpt::system::TTimeStamp& src)
converts mrpt time to ros time
Parameters:
src |
ros time |
des |
mrpt time |