2011-06-20 16:49:22 +00:00
|
|
|
/*
|
2014-08-11 17:03:39 +00:00
|
|
|
Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
|
|
|
|
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.
|
|
|
|
|
*/
|
2011-06-20 16:49:22 +00:00
|
|
|
|
|
|
|
|
#ifndef GUIWRAPPER_H_
|
|
|
|
|
#define GUIWRAPPER_H_
|
|
|
|
|
|
|
|
|
|
#include <ros/ros.h>
|
2014-11-25 17:13:15 -05:00
|
|
|
#include "rtabmap_ros/InfoEx.h"
|
|
|
|
|
#include "rtabmap_ros/MapData.h"
|
2013-04-30 20:25:52 +00:00
|
|
|
#include "rtabmap/utilite/UEventsHandler.h"
|
2013-12-11 00:12:44 +00:00
|
|
|
|
|
|
|
|
#include <tf/transform_listener.h>
|
|
|
|
|
|
2012-06-24 17:19:34 +00:00
|
|
|
#include <geometry_msgs/TwistStamped.h>
|
2013-12-11 00:12:44 +00:00
|
|
|
#include <sensor_msgs/PointCloud2.h>
|
|
|
|
|
#include <sensor_msgs/Image.h>
|
|
|
|
|
#include <sensor_msgs/CameraInfo.h>
|
|
|
|
|
#include <sensor_msgs/LaserScan.h>
|
|
|
|
|
#include <nav_msgs/Odometry.h>
|
|
|
|
|
|
|
|
|
|
#include <message_filters/subscriber.h>
|
|
|
|
|
#include <message_filters/synchronizer.h>
|
|
|
|
|
#include <message_filters/sync_policies/approximate_time.h>
|
2014-07-06 19:58:15 +00:00
|
|
|
#include <message_filters/sync_policies/exact_time.h>
|
2013-12-11 00:12:44 +00:00
|
|
|
|
|
|
|
|
#include <image_transport/image_transport.h>
|
|
|
|
|
#include <image_transport/subscriber_filter.h>
|
2011-06-20 16:49:22 +00:00
|
|
|
|
|
|
|
|
namespace rtabmap
|
|
|
|
|
{
|
|
|
|
|
class MainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class QApplication;
|
|
|
|
|
|
|
|
|
|
class GuiWrapper : public UEventsHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
GuiWrapper(int & argc, char** argv);
|
|
|
|
|
virtual ~GuiWrapper();
|
|
|
|
|
|
|
|
|
|
int exec();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void handleEvent(UEvent * anEvent);
|
|
|
|
|
|
|
|
|
|
private:
|
2014-11-25 17:13:15 -05:00
|
|
|
void infoMapCallback(const rtabmap_ros::InfoExConstPtr & infoMsg, const rtabmap_ros::MapDataConstPtr & mapMsg);
|
2013-12-11 00:12:44 +00:00
|
|
|
|
|
|
|
|
void setupCallbacks(bool subscribeDepth, bool subscribeLaserScan, int queueSize);
|
|
|
|
|
void defaultCallback(const nav_msgs::OdometryConstPtr & odomMsg); // odom
|
|
|
|
|
void depthCallback(const sensor_msgs::ImageConstPtr& imageMsg,
|
|
|
|
|
const nav_msgs::OdometryConstPtr & odomMsg,
|
|
|
|
|
const sensor_msgs::ImageConstPtr& imageDepthMsg,
|
|
|
|
|
const sensor_msgs::CameraInfoConstPtr& camInfoMsg);
|
|
|
|
|
void scanCallback(const sensor_msgs::ImageConstPtr& imageMsg,
|
|
|
|
|
const nav_msgs::OdometryConstPtr & odomMsg,
|
|
|
|
|
const sensor_msgs::LaserScanConstPtr& scanMsg);
|
|
|
|
|
void depthScanCallback(const sensor_msgs::ImageConstPtr& imageMsg,
|
|
|
|
|
const nav_msgs::OdometryConstPtr & odomMsg,
|
|
|
|
|
const sensor_msgs::ImageConstPtr& imageDepthMsg,
|
|
|
|
|
const sensor_msgs::CameraInfoConstPtr& camInfoMsg,
|
|
|
|
|
const sensor_msgs::LaserScanConstPtr& scanMsg);
|
2011-06-20 16:49:22 +00:00
|
|
|
|
2014-11-25 17:13:15 -05:00
|
|
|
void processRequestedMap(const rtabmap_ros::MapData & map);
|
2014-07-06 19:58:15 +00:00
|
|
|
|
2011-06-20 16:49:22 +00:00
|
|
|
private:
|
|
|
|
|
QApplication * app_;
|
|
|
|
|
rtabmap::MainWindow * mainWindow_;
|
2013-12-11 00:12:44 +00:00
|
|
|
std::string cameraNodeName_;
|
2011-06-20 16:49:22 +00:00
|
|
|
|
2013-12-11 00:12:44 +00:00
|
|
|
// odometry subscription stuffs
|
|
|
|
|
std::string frameId_;
|
|
|
|
|
tf::TransformListener tfListener_;
|
2011-06-20 16:49:22 +00:00
|
|
|
|
2014-11-25 17:13:15 -05:00
|
|
|
message_filters::Subscriber<rtabmap_ros::InfoEx> infoExTopic_;
|
|
|
|
|
message_filters::Subscriber<rtabmap_ros::MapData> mapDataTopic_;
|
2014-07-06 19:58:15 +00:00
|
|
|
|
2013-12-11 00:12:44 +00:00
|
|
|
ros::Subscriber defaultSub_; // odometry only
|
|
|
|
|
image_transport::SubscriberFilter imageSub_;
|
|
|
|
|
image_transport::SubscriberFilter imageDepthSub_;
|
|
|
|
|
message_filters::Subscriber<sensor_msgs::CameraInfo> cameraInfoSub_;
|
|
|
|
|
message_filters::Subscriber<nav_msgs::Odometry> odomSub_;
|
|
|
|
|
message_filters::Subscriber<sensor_msgs::LaserScan> scanSub_;
|
|
|
|
|
|
2014-07-06 19:58:15 +00:00
|
|
|
typedef message_filters::sync_policies::ExactTime<
|
2014-11-25 17:13:15 -05:00
|
|
|
rtabmap_ros::InfoEx,
|
|
|
|
|
rtabmap_ros::MapData> MyInfoMapSyncPolicy;
|
2014-07-06 19:58:15 +00:00
|
|
|
message_filters::Synchronizer<MyInfoMapSyncPolicy> * infoMapSync_;
|
|
|
|
|
|
2013-12-11 00:12:44 +00:00
|
|
|
typedef message_filters::sync_policies::ApproximateTime<
|
|
|
|
|
sensor_msgs::Image,
|
|
|
|
|
nav_msgs::Odometry,
|
|
|
|
|
sensor_msgs::Image,
|
|
|
|
|
sensor_msgs::CameraInfo,
|
|
|
|
|
sensor_msgs::LaserScan> MyDepthScanSyncPolicy;
|
|
|
|
|
message_filters::Synchronizer<MyDepthScanSyncPolicy> * depthScanSync_;
|
|
|
|
|
|
|
|
|
|
typedef message_filters::sync_policies::ApproximateTime<
|
|
|
|
|
sensor_msgs::Image,
|
|
|
|
|
nav_msgs::Odometry,
|
|
|
|
|
sensor_msgs::Image,
|
|
|
|
|
sensor_msgs::CameraInfo> MyDepthSyncPolicy;
|
|
|
|
|
message_filters::Synchronizer<MyDepthSyncPolicy> * depthSync_;
|
|
|
|
|
|
|
|
|
|
typedef message_filters::sync_policies::ApproximateTime<
|
|
|
|
|
sensor_msgs::Image,
|
|
|
|
|
nav_msgs::Odometry,
|
|
|
|
|
sensor_msgs::LaserScan> MyScanSyncPolicy;
|
|
|
|
|
message_filters::Synchronizer<MyScanSyncPolicy> * scanSync_;
|
2011-06-20 16:49:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* GUIWRAPPER_H_ */
|