2016-07-06 20:08:23 -04:00
/*
2016-07-17 22:06:11 -04:00
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
2016-07-06 20:08:23 -04:00
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Universite de Sherbrooke nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
2023-02-19 18:55:24 -08:00
#include <rtabmap_odom/OdometryROS.h>
2016-07-06 20:08:23 -04:00
2022-12-23 21:49:50 -08:00
#include <pluginlib/class_list_macros.hpp>
2016-07-06 20:08:23 -04:00
#include <nodelet/nodelet.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>
#include <image_geometry/stereo_camera_model.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>
#include <cv_bridge/cv_bridge.h>
2023-02-19 18:55:24 -08:00
#include "rtabmap_conversions/MsgConversion.h"
#include <rtabmap_msgs/RGBDImages.h>
2016-07-06 20:08:23 -04:00
#include <rtabmap/core/util3d.h>
#include <rtabmap/core/util2d.h>
#include <rtabmap/utilite/ULogger.h>
#include <rtabmap/utilite/UConversion.h>
2016-08-07 20:55:59 -04:00
#include <rtabmap/utilite/UStl.h>
2016-07-06 20:08:23 -04:00
using namespace rtabmap ;
2023-02-19 18:55:24 -08:00
namespace rtabmap_odom
2016-07-06 20:08:23 -04:00
{
2023-02-19 18:55:24 -08:00
class RGBDOdometry : public OdometryROS
2016-07-06 20:08:23 -04:00
{
public :
RGBDOdometry () :
2016-08-07 20:55:59 -04:00
OdometryROS ( false , true , false ),
2016-07-06 20:08:23 -04:00
approxSync_ ( 0 ),
exactSync_ ( 0 ),
2016-09-26 16:37:31 -04:00
approxSync2_ ( 0 ),
exactSync2_ ( 0 ),
2017-10-30 21:45:49 +01:00
approxSync3_ ( 0 ),
exactSync3_ ( 0 ),
approxSync4_ ( 0 ),
exactSync4_ ( 0 ),
2021-07-08 16:14:15 +02:00
approxSync5_ ( 0 ),
exactSync5_ ( 0 ),
2020-11-05 16:38:08 -05:00
queueSize_ ( 5 ),
keepColor_ ( false )
2016-07-06 20:08:23 -04:00
{
}
virtual ~ RGBDOdometry ()
{
2016-09-30 16:21:06 -04:00
rgbdSub_ . shutdown ();
2022-03-06 15:43:48 -05:00
rgbdxSub_ . shutdown ();
2016-07-06 20:08:23 -04:00
if ( approxSync_ )
{
delete approxSync_ ;
}
if ( exactSync_ )
{
delete exactSync_ ;
}
2016-09-26 16:37:31 -04:00
if ( approxSync2_ )
2016-07-06 20:08:23 -04:00
{
2016-09-26 16:37:31 -04:00
delete approxSync2_ ;
}
if ( exactSync2_ )
{
delete exactSync2_ ;
2016-07-06 20:08:23 -04:00
}
2017-10-30 21:45:49 +01:00
if ( approxSync3_ )
{
delete approxSync3_ ;
}
if ( exactSync3_ )
{
delete exactSync3_ ;
}
if ( approxSync4_ )
{
delete approxSync4_ ;
}
if ( exactSync4_ )
{
delete exactSync4_ ;
}
2022-07-11 16:34:40 -04:00
if ( approxSync5_ )
{
delete approxSync5_ ;
}
if ( exactSync5_ )
{
delete exactSync5_ ;
}
2016-07-06 20:08:23 -04:00
}
private :
virtual void onOdomInit ()
{
ros :: NodeHandle & nh = getNodeHandle ();
ros :: NodeHandle & pnh = getPrivateNodeHandle ();
2016-09-26 16:37:31 -04:00
int rgbdCameras = 1 ;
2016-07-06 20:08:23 -04:00
bool approxSync = true ;
2016-09-30 16:21:06 -04:00
bool subscribeRGBD = false ;
2022-03-04 18:01:20 -05:00
double approxSyncMaxInterval = 0.0 ;
2016-07-06 20:08:23 -04:00
pnh . param ( "approx_sync" , approxSync , approxSync );
2022-03-04 18:01:20 -05:00
pnh . param ( "approx_sync_max_interval" , approxSyncMaxInterval , approxSyncMaxInterval );
2016-07-06 20:08:23 -04:00
pnh . param ( "queue_size" , queueSize_ , queueSize_ );
2016-09-30 16:21:06 -04:00
pnh . param ( "subscribe_rgbd" , subscribeRGBD , subscribeRGBD );
2016-09-26 16:37:31 -04:00
if ( pnh . hasParam ( "depth_cameras" ))
2016-07-06 20:08:23 -04:00
{
2016-09-30 16:21:06 -04:00
ROS_ERROR ( " \" depth_cameras \" parameter doesn't exist anymore. It is replaced by \" rgbd_cameras \" with the \" rgbd_image \" input topics. \" subscribe_rgbd \" should be also set to true." );
2016-07-06 20:08:23 -04:00
}
2016-09-26 16:37:31 -04:00
pnh . param ( "rgbd_cameras" , rgbdCameras , rgbdCameras );
2022-03-06 15:43:48 -05:00
if ( rgbdCameras < 0 )
2016-09-26 16:37:31 -04:00
{
2022-03-06 15:43:48 -05:00
rgbdCameras = 0 ;
2016-09-26 16:37:31 -04:00
}
2021-07-08 16:14:15 +02:00
if ( rgbdCameras > 5 )
2016-07-06 20:08:23 -04:00
{
2022-03-06 15:43:48 -05:00
NODELET_FATAL ( "Only 5 cameras maximum supported yet. Set 0 to use rgbd_images input (for which rgbdx_sync node can sync up to 8 cameras)." );
2016-07-06 20:08:23 -04:00
}
2020-11-05 16:38:08 -05:00
pnh . param ( "keep_color" , keepColor_ , keepColor_ );
2016-07-06 20:08:23 -04:00
2017-09-19 14:27:41 -04:00
NODELET_INFO ( "RGBDOdometry: approx_sync = %s" , approxSync ? "true" : "false" );
2022-03-04 18:01:20 -05:00
if ( approxSync )
NODELET_INFO ( "RGBDOdometry: approx_sync_max_interval = %f" , approxSyncMaxInterval );
2017-09-19 14:27:41 -04:00
NODELET_INFO ( "RGBDOdometry: queue_size = %d" , queueSize_ );
NODELET_INFO ( "RGBDOdometry: subscribe_rgbd = %s" , subscribeRGBD ? "true" : "false" );
NODELET_INFO ( "RGBDOdometry: rgbd_cameras = %d" , rgbdCameras );
2020-11-05 16:38:08 -05:00
NODELET_INFO ( "RGBDOdometry: keep_color = %s" , keepColor_ ? "true" : "false" );
2017-09-19 14:27:41 -04:00
2023-08-27 15:30:53 -04:00
std :: string subscribedTopic ;
2016-09-28 12:08:11 -04:00
std :: string subscribedTopicsMsg ;
2016-09-30 16:21:06 -04:00
if ( subscribeRGBD )
2016-07-06 20:08:23 -04:00
{
2017-10-30 21:45:49 +01:00
if ( rgbdCameras >= 2 )
2016-09-26 16:37:31 -04:00
{
2016-09-30 16:21:06 -04:00
rgbd_image1_sub_ . subscribe ( nh , "rgbd_image0" , 1 );
rgbd_image2_sub_ . subscribe ( nh , "rgbd_image1" , 1 );
2017-10-30 21:45:49 +01:00
if ( rgbdCameras >= 3 )
{
rgbd_image3_sub_ . subscribe ( nh , "rgbd_image2" , 1 );
}
if ( rgbdCameras >= 4 )
{
rgbd_image4_sub_ . subscribe ( nh , "rgbd_image3" , 1 );
}
2021-07-08 17:01:44 +02:00
if ( rgbdCameras >= 5 )
{
rgbd_image5_sub_ . subscribe ( nh , "rgbd_image4" , 1 );
}
2016-09-30 16:21:06 -04:00
2017-10-30 21:45:49 +01:00
if ( rgbdCameras == 2 )
2016-09-30 16:21:06 -04:00
{
2017-10-30 21:45:49 +01:00
if ( approxSync )
{
approxSync2_ = new message_filters :: Synchronizer < MyApproxSync2Policy > (
MyApproxSync2Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ );
2022-03-04 18:01:20 -05:00
if ( approxSyncMaxInterval > 0.0 )
approxSync2_ -> setMaxIntervalDuration ( ros :: Duration ( approxSyncMaxInterval ));
2022-05-09 08:51:05 -07:00
approxSync2_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD2 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 ));
2017-10-30 21:45:49 +01:00
}
else
{
exactSync2_ = new message_filters :: Synchronizer < MyExactSync2Policy > (
MyExactSync2Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ );
2022-05-09 08:51:05 -07:00
exactSync2_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD2 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 ));
2017-10-30 21:45:49 +01:00
}
2022-03-04 18:01:20 -05:00
subscribedTopicsMsg = uFormat ( " \n %s subscribed to (%s sync%s): \n %s \\\n %s" ,
2017-10-30 21:45:49 +01:00
getName (). c_str (),
approxSync ? "approx" : "exact" ,
2022-03-04 18:01:20 -05:00
approxSync && approxSyncMaxInterval != 0.0 ? uFormat ( ", max interval=%fs" , approxSyncMaxInterval ). c_str () : "" ,
2017-10-30 21:45:49 +01:00
rgbd_image1_sub_ . getTopic (). c_str (),
rgbd_image2_sub_ . getTopic (). c_str ());
2016-09-30 16:21:06 -04:00
}
2017-10-30 21:45:49 +01:00
else if ( rgbdCameras == 3 )
2016-09-30 16:21:06 -04:00
{
2017-10-30 21:45:49 +01:00
if ( approxSync )
{
approxSync3_ = new message_filters :: Synchronizer < MyApproxSync3Policy > (
MyApproxSync3Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ );
2022-03-04 18:01:20 -05:00
if ( approxSyncMaxInterval > 0.0 )
approxSync3_ -> setMaxIntervalDuration ( ros :: Duration ( approxSyncMaxInterval ));
2022-05-09 08:51:05 -07:00
approxSync3_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD3 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2017-10-30 21:45:49 +01:00
}
else
{
exactSync3_ = new message_filters :: Synchronizer < MyExactSync3Policy > (
MyExactSync3Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ );
2022-05-09 08:51:05 -07:00
exactSync3_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD3 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2017-10-30 21:45:49 +01:00
}
2022-03-04 18:01:20 -05:00
subscribedTopicsMsg = uFormat ( " \n %s subscribed to (%s sync%s): \n %s \\\n %s \\\n %s" ,
2017-10-30 21:45:49 +01:00
getName (). c_str (),
approxSync ? "approx" : "exact" ,
2022-03-04 18:01:20 -05:00
approxSync && approxSyncMaxInterval != 0.0 ? uFormat ( ", max interval=%fs" , approxSyncMaxInterval ). c_str () : "" ,
2017-10-30 21:45:49 +01:00
rgbd_image1_sub_ . getTopic (). c_str (),
rgbd_image2_sub_ . getTopic (). c_str (),
rgbd_image3_sub_ . getTopic (). c_str ());
}
else if ( rgbdCameras == 4 )
{
if ( approxSync )
{
approxSync4_ = new message_filters :: Synchronizer < MyApproxSync4Policy > (
MyApproxSync4Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ );
2022-03-04 18:01:20 -05:00
if ( approxSyncMaxInterval > 0.0 )
approxSync4_ -> setMaxIntervalDuration ( ros :: Duration ( approxSyncMaxInterval ));
2022-05-09 08:51:05 -07:00
approxSync4_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD4 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 ));
2017-10-30 21:45:49 +01:00
}
else
{
exactSync4_ = new message_filters :: Synchronizer < MyExactSync4Policy > (
MyExactSync4Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ );
2022-05-09 08:51:05 -07:00
exactSync4_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD4 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 ));
2017-10-30 21:45:49 +01:00
}
2022-03-04 18:01:20 -05:00
subscribedTopicsMsg = uFormat ( " \n %s subscribed to (%s sync%s): \n %s \\\n %s \\\n %s \\\n %s" ,
2017-10-30 21:45:49 +01:00
getName (). c_str (),
approxSync ? "approx" : "exact" ,
2022-03-04 18:01:20 -05:00
approxSync && approxSyncMaxInterval != 0.0 ? uFormat ( ", max interval=%fs" , approxSyncMaxInterval ). c_str () : "" ,
2017-10-30 21:45:49 +01:00
rgbd_image1_sub_ . getTopic (). c_str (),
rgbd_image2_sub_ . getTopic (). c_str (),
rgbd_image3_sub_ . getTopic (). c_str (),
rgbd_image4_sub_ . getTopic (). c_str ());
2016-09-30 16:21:06 -04:00
}
2021-07-08 16:14:15 +02:00
else if ( rgbdCameras == 5 )
{
if ( approxSync )
{
approxSync5_ = new message_filters :: Synchronizer < MyApproxSync5Policy > (
MyApproxSync5Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ ,
2022-03-04 18:01:20 -05:00
rgbd_image5_sub_ );
if ( approxSyncMaxInterval > 0.0 )
approxSync5_ -> setMaxIntervalDuration ( ros :: Duration ( approxSyncMaxInterval ));
2022-05-09 08:51:05 -07:00
approxSync5_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD5 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 , boost :: placeholders :: _5 ));
2021-07-08 16:14:15 +02:00
}
else
{
exactSync5_ = new message_filters :: Synchronizer < MyExactSync5Policy > (
MyExactSync5Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ ,
2022-03-04 18:01:20 -05:00
rgbd_image5_sub_ );
2022-05-09 08:51:05 -07:00
exactSync5_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD5 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 , boost :: placeholders :: _5 ));
2021-07-08 16:14:15 +02:00
}
2022-03-04 18:01:20 -05:00
subscribedTopicsMsg = uFormat ( " \n %s subscribed to (%s sync%s): \n %s \\\n %s \\\n %s \\\n %s \\\n %s" ,
2021-07-08 16:14:15 +02:00
getName (). c_str (),
approxSync ? "approx" : "exact" ,
2022-03-04 18:01:20 -05:00
approxSync && approxSyncMaxInterval != 0.0 ? uFormat ( ", max interval=%fs" , approxSyncMaxInterval ). c_str () : "" ,
2021-07-08 16:14:15 +02:00
rgbd_image1_sub_ . getTopic (). c_str (),
rgbd_image2_sub_ . getTopic (). c_str (),
rgbd_image3_sub_ . getTopic (). c_str (),
2021-07-08 17:01:44 +02:00
rgbd_image4_sub_ . getTopic (). c_str (),
rgbd_image5_sub_ . getTopic (). c_str ());
2021-07-08 16:14:15 +02:00
}
2016-09-26 16:37:31 -04:00
}
2022-03-06 15:43:48 -05:00
else if ( rgbdCameras == 0 )
{
rgbdxSub_ = nh . subscribe ( "rgbd_images" , 1 , & RGBDOdometry :: callbackRGBDX , this );
subscribedTopicsMsg =
uFormat ( " \n %s subscribed to: \n %s" ,
getName (). c_str (),
rgbdxSub_ . getTopic (). c_str ());
}
2016-09-26 16:37:31 -04:00
else
{
2017-12-21 10:29:26 -05:00
rgbdSub_ = nh . subscribe ( "rgbd_image" , 1 , & RGBDOdometry :: callbackRGBD , this );
2016-09-30 16:21:06 -04:00
subscribedTopicsMsg =
uFormat ( " \n %s subscribed to: \n %s" ,
2016-10-18 11:49:56 -04:00
getName (). c_str (),
2016-09-30 16:21:06 -04:00
rgbdSub_ . getTopic (). c_str ());
2016-09-26 16:37:31 -04:00
}
2016-07-06 20:08:23 -04:00
}
else
{
ros :: NodeHandle rgb_nh ( nh , "rgb" );
ros :: NodeHandle depth_nh ( nh , "depth" );
ros :: NodeHandle rgb_pnh ( pnh , "rgb" );
ros :: NodeHandle depth_pnh ( pnh , "depth" );
image_transport :: ImageTransport rgb_it ( rgb_nh );
image_transport :: ImageTransport depth_it ( depth_nh );
image_transport :: TransportHints hintsRgb ( "raw" , ros :: TransportHints (), rgb_pnh );
image_transport :: TransportHints hintsDepth ( "raw" , ros :: TransportHints (), depth_pnh );
image_mono_sub_ . subscribe ( rgb_it , rgb_nh . resolveName ( "image" ), 1 , hintsRgb );
image_depth_sub_ . subscribe ( depth_it , depth_nh . resolveName ( "image" ), 1 , hintsDepth );
info_sub_ . subscribe ( rgb_nh , "camera_info" , 1 );
if ( approxSync )
{
approxSync_ = new message_filters :: Synchronizer < MyApproxSyncPolicy > ( MyApproxSyncPolicy ( queueSize_ ), image_mono_sub_ , image_depth_sub_ , info_sub_ );
2022-03-04 18:01:20 -05:00
if ( approxSyncMaxInterval > 0.0 )
approxSync_ -> setMaxIntervalDuration ( ros :: Duration ( approxSyncMaxInterval ));
2022-05-09 08:51:05 -07:00
approxSync_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callback , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2016-07-06 20:08:23 -04:00
}
else
{
exactSync_ = new message_filters :: Synchronizer < MyExactSyncPolicy > ( MyExactSyncPolicy ( queueSize_ ), image_mono_sub_ , image_depth_sub_ , info_sub_ );
2022-05-09 08:51:05 -07:00
exactSync_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callback , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2016-07-06 20:08:23 -04:00
}
2023-08-27 15:30:53 -04:00
subscribedTopic = rgb_nh . resolveName ( "image" );
2022-03-04 18:01:20 -05:00
subscribedTopicsMsg = uFormat ( " \n %s subscribed to (%s sync%s): \n %s \\\n %s \\\n %s" ,
2016-10-18 11:49:56 -04:00
getName (). c_str (),
2016-07-06 20:08:23 -04:00
approxSync ? "approx" : "exact" ,
2022-03-04 18:01:20 -05:00
approxSync && approxSyncMaxInterval != 0.0 ? uFormat ( ", max interval=%fs" , approxSyncMaxInterval ). c_str () : "" ,
2016-07-06 20:08:23 -04:00
image_mono_sub_ . getTopic (). c_str (),
image_depth_sub_ . getTopic (). c_str (),
info_sub_ . getTopic (). c_str ());
}
2023-08-27 15:30:53 -04:00
initDiagnosticMsg ( subscribedTopicsMsg , approxSync , subscribedTopic );
2016-07-06 20:08:23 -04:00
}
2016-08-07 20:55:59 -04:00
virtual void updateParameters ( ParametersMap & parameters )
{
//make sure we are using Reg/Strategy=0
ParametersMap :: iterator iter = parameters . find ( Parameters :: kRegStrategy ());
if ( iter != parameters . end () && iter -> second . compare ( "0" ) != 0 )
{
ROS_WARN ( "RGBD odometry works only with \" Reg/Strategy \" =0. Ignoring value %s." , iter -> second . c_str ());
}
uInsert ( parameters , ParametersPair ( Parameters :: kRegStrategy (), "0" ));
2017-08-16 14:44:06 -04:00
int estimationType = Parameters :: defaultVisEstimationType ();
Parameters :: parse ( parameters , Parameters :: kVisEstimationType (), estimationType );
ros :: NodeHandle & pnh = getPrivateNodeHandle ();
int rgbdCameras = 1 ;
bool subscribeRGBD = false ;
pnh . param ( "subscribe_rgbd" , subscribeRGBD , subscribeRGBD );
pnh . param ( "rgbd_cameras" , rgbdCameras , rgbdCameras );
2016-08-07 20:55:59 -04:00
}
2016-09-26 16:37:31 -04:00
void commonCallback (
const std :: vector < cv_bridge :: CvImageConstPtr > & rgbImages ,
const std :: vector < cv_bridge :: CvImageConstPtr > & depthImages ,
const std :: vector < sensor_msgs :: CameraInfo >& cameraInfos )
{
ROS_ASSERT ( rgbImages . size () > 0 && rgbImages . size () == depthImages . size () && rgbImages . size () == cameraInfos . size ());
ros :: Time higherStamp ;
int imageWidth = rgbImages [ 0 ] -> image . cols ;
int imageHeight = rgbImages [ 0 ] -> image . rows ;
2017-05-09 12:12:04 +02:00
int depthWidth = depthImages [ 0 ] -> image . cols ;
int depthHeight = depthImages [ 0 ] -> image . rows ;
UASSERT_MSG (
imageWidth / depthWidth == imageHeight / depthHeight ,
uFormat ( "rgb=%dx%d depth=%dx%d" , imageWidth , imageHeight , depthWidth , depthHeight ). c_str ());
2016-09-26 16:37:31 -04:00
int cameraCount = rgbImages . size ();
cv :: Mat rgb ;
cv :: Mat depth ;
2022-07-07 13:44:19 -04:00
std :: vector < rtabmap :: CameraModel > cameraModels ;
2016-09-26 16:37:31 -04:00
for ( unsigned int i = 0 ; i < rgbImages . size (); ++ i )
{
if ( ! ( rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: TYPE_8UC1 ) == 0 ||
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: MONO8 ) == 0 ||
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: MONO16 ) == 0 ||
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: BGR8 ) == 0 ||
2017-05-09 12:12:04 +02:00
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: RGB8 ) == 0 ||
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: BGRA8 ) == 0 ||
2017-06-19 10:13:24 -04:00
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: RGBA8 ) == 0 ||
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: BAYER_GRBG8 ) == 0 ) ||
2016-09-26 16:37:31 -04:00
! ( depthImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: TYPE_16UC1 ) == 0 ||
depthImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: TYPE_32FC1 ) == 0 ||
depthImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: MONO16 ) == 0 ))
2022-03-04 18:01:20 -05:00
{
2017-05-09 12:12:04 +02:00
NODELET_ERROR ( "Input type must be image=mono8,mono16,rgb8,bgr8,bgra8,rgba8 and "
"image_depth=32FC1,16UC1,mono16. Current rgb=%s and depth=%s" ,
rgbImages [ i ] -> encoding . c_str (),
depthImages [ i ] -> encoding . c_str ());
return ;
2022-03-04 18:01:20 -05:00
}
2016-09-26 16:37:31 -04:00
UASSERT_MSG ( rgbImages [ i ] -> image . cols == imageWidth && rgbImages [ i ] -> image . rows == imageHeight ,
uFormat ( "imageWidth=%d vs %d imageHeight=%d vs %d" ,
imageWidth ,
rgbImages [ i ] -> image . cols ,
imageHeight ,
rgbImages [ i ] -> image . rows ). c_str ());
2017-05-09 12:12:04 +02:00
UASSERT_MSG ( depthImages [ i ] -> image . cols == depthWidth && depthImages [ i ] -> image . rows == depthHeight ,
uFormat ( "depthWidth=%d vs %d depthHeight=%d vs %d" ,
depthWidth ,
2016-09-26 16:37:31 -04:00
depthImages [ i ] -> image . cols ,
2017-05-09 12:12:04 +02:00
depthHeight ,
2016-09-26 16:37:31 -04:00
depthImages [ i ] -> image . rows ). c_str ());
ros :: Time stamp = rgbImages [ i ] -> header . stamp > depthImages [ i ] -> header . stamp ? rgbImages [ i ] -> header . stamp : depthImages [ i ] -> header . stamp ;
if ( i == 0 )
{
higherStamp = stamp ;
}
else if ( stamp > higherStamp )
{
higherStamp = stamp ;
}
2023-02-19 18:55:24 -08:00
Transform localTransform = rtabmap_conversions :: getTransform ( this -> frameId (), rgbImages [ i ] -> header . frame_id , stamp , this -> tfListener (), this -> waitForTransformDuration ());
2016-09-26 16:37:31 -04:00
if ( localTransform . isNull ())
{
return ;
}
2022-03-04 18:01:20 -05:00
if ( i > 0 )
{
double stampDiff = fabs ( rgbImages [ i ] -> header . stamp . toSec () - rgbImages [ i - 1 ] -> header . stamp . toSec ());
if ( stampDiff > 1.0 / 60.0 )
{
static bool warningShown = false ;
if ( ! warningShown )
{
NODELET_WARN ( "The time difference between cameras %d and %d is "
"high (diff=%fs, cam%d=%fs, cam%d=%fs). You may want "
"to set approx_sync_max_interval to reject bad synchronizations or use "
"approx_sync=false if streams have all the exact same timestamp. This "
"message is only printed once." ,
i - 1 , i ,
stampDiff ,
i - 1 , rgbImages [ i - 1 ] -> header . stamp . toSec (),
i , rgbImages [ i ] -> header . stamp . toSec ());
warningShown = true ;
}
}
}
2016-09-26 16:37:31 -04:00
cv_bridge :: CvImageConstPtr ptrImage = rgbImages [ i ];
if ( rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: TYPE_8UC1 ) != 0 &&
rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: MONO8 ) != 0 )
{
2020-11-05 16:38:08 -05:00
if ( keepColor_ && rgbImages [ i ] -> encoding . compare ( sensor_msgs :: image_encodings :: MONO16 ) != 0 )
{
ptrImage = cv_bridge :: cvtColor ( rgbImages [ i ], "bgr8" );
}
else
{
ptrImage = cv_bridge :: cvtColor ( rgbImages [ i ], "mono8" );
}
2016-09-26 16:37:31 -04:00
}
cv_bridge :: CvImageConstPtr ptrDepth = depthImages [ i ];
// initialize
if ( rgb . empty ())
{
rgb = cv :: Mat ( imageHeight , imageWidth * cameraCount , ptrImage -> image . type ());
}
if ( depth . empty ())
{
2022-07-11 16:34:40 -04:00
depth = cv :: Mat ( depthHeight , depthWidth * cameraCount , ptrDepth -> image . type ());
2016-09-26 16:37:31 -04:00
}
if ( ptrImage -> image . type () == rgb . type ())
{
ptrImage -> image . copyTo ( cv :: Mat ( rgb , cv :: Rect ( i * imageWidth , 0 , imageWidth , imageHeight )));
}
else
{
2022-07-11 16:34:40 -04:00
NODELET_ERROR ( "Some RGB images are not the same type! %d vs %d" , ptrImage -> image . type (), rgb . type ());
2016-09-26 16:37:31 -04:00
return ;
}
2022-07-11 16:34:40 -04:00
if ( ptrDepth -> image . type () == depth . type ())
2016-09-26 16:37:31 -04:00
{
2022-07-11 16:34:40 -04:00
ptrDepth -> image . copyTo ( cv :: Mat ( depth , cv :: Rect ( i * depthWidth , 0 , depthWidth , depthHeight )));
2016-09-26 16:37:31 -04:00
}
else
{
2022-07-11 16:34:40 -04:00
NODELET_ERROR ( "Some Depth images are not the same type! %d vs %d" , ptrDepth -> image . type (), depth . type ());
2016-09-26 16:37:31 -04:00
return ;
}
2023-02-19 18:55:24 -08:00
cameraModels . push_back ( rtabmap_conversions :: cameraModelFromROS ( cameraInfos [ i ], localTransform ));
2016-09-26 16:37:31 -04:00
}
rtabmap :: SensorData data (
rgb ,
depth ,
cameraModels ,
0 ,
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: timestampFromROS ( higherStamp ));
2016-09-26 16:37:31 -04:00
2021-03-20 19:59:38 -04:00
std_msgs :: Header header ;
header . stamp = higherStamp ;
header . frame_id = rgbImages . size () == 1 ? rgbImages [ 0 ] -> header . frame_id : "" ;
this -> processData ( data , header );
2016-09-26 16:37:31 -04:00
}
2016-07-06 20:08:23 -04:00
void callback (
const sensor_msgs :: ImageConstPtr & image ,
const sensor_msgs :: ImageConstPtr & depth ,
const sensor_msgs :: CameraInfoConstPtr & cameraInfo )
{
if ( ! this -> isPaused ())
{
2016-09-26 16:37:31 -04:00
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 1 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 1 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
imageMsgs [ 0 ] = cv_bridge :: toCvShare ( image );
depthMsgs [ 0 ] = cv_bridge :: toCvShare ( depth );
infoMsgs . push_back ( * cameraInfo );
2016-07-06 20:08:23 -04:00
2022-03-04 18:01:20 -05:00
double stampDiff = fabs ( image -> header . stamp . toSec () - depth -> header . stamp . toSec ());
2022-11-20 19:41:55 -08:00
if ( stampDiff > 0.020 )
2022-03-04 18:01:20 -05:00
{
NODELET_WARN ( "The time difference between rgb and depth frames is "
"high (diff=%fs, rgb=%fs, depth=%fs). You may want "
2022-11-20 19:41:55 -08:00
"to set approx_sync_max_interval lower than 0.02s to reject spurious bad synchronizations or use "
2022-03-04 18:01:20 -05:00
"approx_sync=false if streams have all the exact same timestamp." ,
stampDiff ,
image -> header . stamp . toSec (),
depth -> header . stamp . toSec ());
}
2016-09-26 16:37:31 -04:00
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
2016-07-06 20:08:23 -04:00
}
}
2016-09-30 16:21:06 -04:00
void callbackRGBD (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImageConstPtr & image )
2016-09-30 16:21:06 -04:00
{
if ( ! this -> isPaused ())
{
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 1 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 1 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( image , imageMsgs [ 0 ], depthMsgs [ 0 ]);
2020-05-03 22:42:01 -04:00
infoMsgs . push_back ( image -> rgb_camera_info );
2016-09-30 16:21:06 -04:00
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
}
}
2022-03-06 15:43:48 -05:00
void callbackRGBDX (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImagesConstPtr & images )
2022-03-06 15:43:48 -05:00
{
if ( ! this -> isPaused ())
{
if ( images -> rgbd_images . empty ())
{
NODELET_ERROR ( "Input topic \" %s \" doesn't contain any image(s)!" , rgbdxSub_ . getTopic (). c_str ());
return ;
}
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( images -> rgbd_images . size ());
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( images -> rgbd_images . size ());
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
for ( size_t i = 0 ; i < images -> rgbd_images . size (); ++ i )
{
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( images -> rgbd_images [ i ], images , imageMsgs [ i ], depthMsgs [ i ]);
2022-03-06 15:43:48 -05:00
infoMsgs . push_back ( images -> rgbd_images [ i ]. rgb_camera_info );
}
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
}
}
2016-09-30 16:21:06 -04:00
void callbackRGBD2 (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImageConstPtr & image ,
const rtabmap_msgs :: RGBDImageConstPtr & image2 )
2016-07-06 20:08:23 -04:00
{
if ( ! this -> isPaused ())
{
2016-09-26 16:37:31 -04:00
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 2 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 2 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( image , imageMsgs [ 0 ], depthMsgs [ 0 ]);
rtabmap_conversions :: toCvShare ( image2 , imageMsgs [ 1 ], depthMsgs [ 1 ]);
2020-05-03 22:42:01 -04:00
infoMsgs . push_back ( image -> rgb_camera_info );
infoMsgs . push_back ( image2 -> rgb_camera_info );
2016-07-06 20:08:23 -04:00
2016-09-26 16:37:31 -04:00
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
2016-07-06 20:08:23 -04:00
}
}
2017-10-30 21:45:49 +01:00
void callbackRGBD3 (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImageConstPtr & image ,
const rtabmap_msgs :: RGBDImageConstPtr & image2 ,
const rtabmap_msgs :: RGBDImageConstPtr & image3 )
2017-10-30 21:45:49 +01:00
{
if ( ! this -> isPaused ())
{
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 3 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 3 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( image , imageMsgs [ 0 ], depthMsgs [ 0 ]);
rtabmap_conversions :: toCvShare ( image2 , imageMsgs [ 1 ], depthMsgs [ 1 ]);
rtabmap_conversions :: toCvShare ( image3 , imageMsgs [ 2 ], depthMsgs [ 2 ]);
2020-05-03 22:42:01 -04:00
infoMsgs . push_back ( image -> rgb_camera_info );
infoMsgs . push_back ( image2 -> rgb_camera_info );
infoMsgs . push_back ( image3 -> rgb_camera_info );
2017-10-30 21:45:49 +01:00
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
}
}
void callbackRGBD4 (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImageConstPtr & image ,
const rtabmap_msgs :: RGBDImageConstPtr & image2 ,
const rtabmap_msgs :: RGBDImageConstPtr & image3 ,
const rtabmap_msgs :: RGBDImageConstPtr & image4 )
2017-10-30 21:45:49 +01:00
{
if ( ! this -> isPaused ())
{
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 4 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 4 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( image , imageMsgs [ 0 ], depthMsgs [ 0 ]);
rtabmap_conversions :: toCvShare ( image2 , imageMsgs [ 1 ], depthMsgs [ 1 ]);
rtabmap_conversions :: toCvShare ( image3 , imageMsgs [ 2 ], depthMsgs [ 2 ]);
rtabmap_conversions :: toCvShare ( image4 , imageMsgs [ 3 ], depthMsgs [ 3 ]);
2020-05-03 22:42:01 -04:00
infoMsgs . push_back ( image -> rgb_camera_info );
infoMsgs . push_back ( image2 -> rgb_camera_info );
infoMsgs . push_back ( image3 -> rgb_camera_info );
infoMsgs . push_back ( image4 -> rgb_camera_info );
2017-10-30 21:45:49 +01:00
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
}
}
2021-07-08 16:14:15 +02:00
void callbackRGBD5 (
2023-02-19 18:55:24 -08:00
const rtabmap_msgs :: RGBDImageConstPtr & image ,
const rtabmap_msgs :: RGBDImageConstPtr & image2 ,
const rtabmap_msgs :: RGBDImageConstPtr & image3 ,
const rtabmap_msgs :: RGBDImageConstPtr & image4 ,
const rtabmap_msgs :: RGBDImageConstPtr & image5 )
2021-07-08 16:14:15 +02:00
{
if ( ! this -> isPaused ())
{
std :: vector < cv_bridge :: CvImageConstPtr > imageMsgs ( 5 );
std :: vector < cv_bridge :: CvImageConstPtr > depthMsgs ( 5 );
std :: vector < sensor_msgs :: CameraInfo > infoMsgs ;
2023-02-19 18:55:24 -08:00
rtabmap_conversions :: toCvShare ( image , imageMsgs [ 0 ], depthMsgs [ 0 ]);
rtabmap_conversions :: toCvShare ( image2 , imageMsgs [ 1 ], depthMsgs [ 1 ]);
rtabmap_conversions :: toCvShare ( image3 , imageMsgs [ 2 ], depthMsgs [ 2 ]);
rtabmap_conversions :: toCvShare ( image4 , imageMsgs [ 3 ], depthMsgs [ 3 ]);
rtabmap_conversions :: toCvShare ( image5 , imageMsgs [ 4 ], depthMsgs [ 4 ]);
2021-07-08 16:14:15 +02:00
infoMsgs . push_back ( image -> rgb_camera_info );
infoMsgs . push_back ( image2 -> rgb_camera_info );
infoMsgs . push_back ( image3 -> rgb_camera_info );
infoMsgs . push_back ( image4 -> rgb_camera_info );
infoMsgs . push_back ( image5 -> rgb_camera_info );
this -> commonCallback ( imageMsgs , depthMsgs , infoMsgs );
}
}
2016-07-06 20:08:23 -04:00
protected :
virtual void flushCallbacks ()
{
// flush callbacks
if ( approxSync_ )
{
delete approxSync_ ;
approxSync_ = new message_filters :: Synchronizer < MyApproxSyncPolicy > ( MyApproxSyncPolicy ( queueSize_ ), image_mono_sub_ , image_depth_sub_ , info_sub_ );
2022-05-09 08:51:05 -07:00
approxSync_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callback , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2016-07-06 20:08:23 -04:00
}
if ( exactSync_ )
{
delete exactSync_ ;
exactSync_ = new message_filters :: Synchronizer < MyExactSyncPolicy > ( MyExactSyncPolicy ( queueSize_ ), image_mono_sub_ , image_depth_sub_ , info_sub_ );
2022-05-09 08:51:05 -07:00
exactSync_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callback , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2016-07-06 20:08:23 -04:00
}
2016-09-26 16:37:31 -04:00
if ( approxSync2_ )
2016-07-06 20:08:23 -04:00
{
2016-09-26 16:37:31 -04:00
delete approxSync2_ ;
approxSync2_ = new message_filters :: Synchronizer < MyApproxSync2Policy > (
MyApproxSync2Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ );
2022-05-09 08:51:05 -07:00
approxSync2_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD2 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 ));
2016-09-26 16:37:31 -04:00
}
if ( exactSync2_ )
{
delete exactSync2_ ;
exactSync2_ = new message_filters :: Synchronizer < MyExactSync2Policy > (
MyExactSync2Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ );
2022-05-09 08:51:05 -07:00
exactSync2_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD2 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 ));
2016-07-06 20:08:23 -04:00
}
2017-10-30 21:45:49 +01:00
if ( approxSync3_ )
{
delete approxSync3_ ;
approxSync3_ = new message_filters :: Synchronizer < MyApproxSync3Policy > (
MyApproxSync3Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ );
2022-05-09 08:51:05 -07:00
approxSync3_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD3 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2017-10-30 21:45:49 +01:00
}
if ( exactSync3_ )
{
delete exactSync3_ ;
exactSync3_ = new message_filters :: Synchronizer < MyExactSync3Policy > (
MyExactSync3Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ );
2022-05-09 08:51:05 -07:00
exactSync3_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD3 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 ));
2017-10-30 21:45:49 +01:00
}
if ( approxSync4_ )
{
delete approxSync4_ ;
approxSync4_ = new message_filters :: Synchronizer < MyApproxSync4Policy > (
MyApproxSync4Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ );
2022-05-09 08:51:05 -07:00
approxSync4_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD4 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 ));
2017-10-30 21:45:49 +01:00
}
if ( exactSync4_ )
{
delete exactSync4_ ;
exactSync4_ = new message_filters :: Synchronizer < MyExactSync4Policy > (
MyExactSync4Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ );
2022-05-09 08:51:05 -07:00
exactSync4_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD4 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 ));
2017-10-30 21:45:49 +01:00
}
2021-07-08 16:14:15 +02:00
if ( approxSync5_ )
{
delete approxSync5_ ;
approxSync5_ = new message_filters :: Synchronizer < MyApproxSync5Policy > (
MyApproxSync5Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ ,
rgbd_image5_sub_ );
2022-05-09 08:51:05 -07:00
approxSync5_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD5 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 , boost :: placeholders :: _5 ));
2021-07-08 16:14:15 +02:00
}
if ( exactSync5_ )
{
delete exactSync5_ ;
exactSync5_ = new message_filters :: Synchronizer < MyExactSync5Policy > (
MyExactSync5Policy ( queueSize_ ),
rgbd_image1_sub_ ,
rgbd_image2_sub_ ,
rgbd_image3_sub_ ,
rgbd_image4_sub_ ,
rgbd_image5_sub_ );
2022-05-09 08:51:05 -07:00
exactSync5_ -> registerCallback ( boost :: bind ( & RGBDOdometry :: callbackRGBD5 , this , boost :: placeholders :: _1 , boost :: placeholders :: _2 , boost :: placeholders :: _3 , boost :: placeholders :: _4 , boost :: placeholders :: _5 ));
2021-07-08 16:14:15 +02:00
}
2016-07-06 20:08:23 -04:00
}
private :
image_transport :: SubscriberFilter image_mono_sub_ ;
image_transport :: SubscriberFilter image_depth_sub_ ;
message_filters :: Subscriber < sensor_msgs :: CameraInfo > info_sub_ ;
2016-09-26 16:37:31 -04:00
2016-09-30 16:21:06 -04:00
ros :: Subscriber rgbdSub_ ;
2022-03-06 15:43:48 -05:00
ros :: Subscriber rgbdxSub_ ;
2023-02-19 18:55:24 -08:00
message_filters :: Subscriber < rtabmap_msgs :: RGBDImage > rgbd_image1_sub_ ;
message_filters :: Subscriber < rtabmap_msgs :: RGBDImage > rgbd_image2_sub_ ;
message_filters :: Subscriber < rtabmap_msgs :: RGBDImage > rgbd_image3_sub_ ;
message_filters :: Subscriber < rtabmap_msgs :: RGBDImage > rgbd_image4_sub_ ;
message_filters :: Subscriber < rtabmap_msgs :: RGBDImage > rgbd_image5_sub_ ;
2016-09-26 16:37:31 -04:00
2016-07-06 20:08:23 -04:00
typedef message_filters :: sync_policies :: ApproximateTime < sensor_msgs :: Image , sensor_msgs :: Image , sensor_msgs :: CameraInfo > MyApproxSyncPolicy ;
message_filters :: Synchronizer < MyApproxSyncPolicy > * approxSync_ ;
2016-09-26 16:37:31 -04:00
typedef message_filters :: sync_policies :: ExactTime < sensor_msgs :: Image , sensor_msgs :: Image , sensor_msgs :: CameraInfo > MyExactSyncPolicy ;
2016-07-06 20:08:23 -04:00
message_filters :: Synchronizer < MyExactSyncPolicy > * exactSync_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ApproximateTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyApproxSync2Policy ;
2016-09-26 16:37:31 -04:00
message_filters :: Synchronizer < MyApproxSync2Policy > * approxSync2_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ExactTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyExactSync2Policy ;
2016-09-26 16:37:31 -04:00
message_filters :: Synchronizer < MyExactSync2Policy > * exactSync2_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ApproximateTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyApproxSync3Policy ;
2017-10-30 21:45:49 +01:00
message_filters :: Synchronizer < MyApproxSync3Policy > * approxSync3_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ExactTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyExactSync3Policy ;
2017-10-30 21:45:49 +01:00
message_filters :: Synchronizer < MyExactSync3Policy > * exactSync3_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ApproximateTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyApproxSync4Policy ;
2017-10-30 21:45:49 +01:00
message_filters :: Synchronizer < MyApproxSync4Policy > * approxSync4_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ExactTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyExactSync4Policy ;
2017-10-30 21:45:49 +01:00
message_filters :: Synchronizer < MyExactSync4Policy > * exactSync4_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ApproximateTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyApproxSync5Policy ;
2021-07-08 16:14:15 +02:00
message_filters :: Synchronizer < MyApproxSync5Policy > * approxSync5_ ;
2023-02-19 18:55:24 -08:00
typedef message_filters :: sync_policies :: ExactTime < rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage , rtabmap_msgs :: RGBDImage > MyExactSync5Policy ;
2021-07-08 16:14:15 +02:00
message_filters :: Synchronizer < MyExactSync5Policy > * exactSync5_ ;
2016-07-06 20:08:23 -04:00
int queueSize_ ;
2020-11-05 16:38:08 -05:00
bool keepColor_ ;
2016-07-06 20:08:23 -04:00
};
2023-02-19 18:55:24 -08:00
PLUGINLIB_EXPORT_CLASS ( rtabmap_odom :: RGBDOdometry , nodelet :: Nodelet );
2016-07-06 20:08:23 -04:00
}