Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <QtGui>
00017 #include <QPixmap>
00018 #include <QFont>
00019 #include <QIcon>
00020 #include <QKeySequence>
00021 #include "ros_service_ui.h"
00022 #include <limits>
00023 #include "ros/ros.h"
00024
00025 RosUi::RosUi(const char* service_namespace) : filename("quicksave.pcd"), record_on(false)
00026 {
00027 createActions(service_namespace);
00028 this->pause_on = ParameterServer::instance()->get<bool>("start_paused");
00029 }
00030
00031 void RosUi::resetCmd() {
00032 ROS_INFO("Graph Reset");
00033 Q_EMIT reset();
00034 ROS_INFO("A fresh new graph is waiting");
00035 }
00036
00037 void RosUi::quickSaveAll() {
00038 Q_EMIT saveAllClouds(filename);
00039 ROS_INFO("Saving Whole Model to %s", qPrintable(filename));
00040 }
00041
00042 void RosUi::saveFeatures() {
00043 Q_EMIT saveAllFeatures(QString("feature_database.yml"));
00044 ROS_INFO("Saving Whole Model to %s", qPrintable(filename));
00045 }
00046
00047 void RosUi::saveAll() {
00048 Q_EMIT saveAllClouds(filename);
00049 ROS_INFO("Saving Whole Model to %s", qPrintable(filename));
00050 }
00051
00052 void RosUi::saveIndividual() {
00053 QString tmpfilename(filename);
00054 tmpfilename.remove(".pcd", Qt::CaseInsensitive);
00055 tmpfilename.remove(".ply", Qt::CaseInsensitive);
00056 Q_EMIT saveIndividualClouds(filename);
00057 ROS_INFO("Saving Model Node-Wise");
00058 }
00059
00060 void RosUi::sendAll() {
00061 Q_EMIT sendAllClouds();
00062 ROS_INFO("Sending Whole Model");
00063 }
00064
00065 void RosUi::sendFinished() {
00066 ROS_INFO("Finished Sending");
00067 }
00068
00069 void RosUi::getOneFrameCmd() {
00070 Q_EMIT getOneFrame();
00071 ROS_INFO("Getting a single frame");
00072 }
00073
00074 void RosUi::deleteLastFrameCmd() {
00075 Q_EMIT deleteLastFrame();
00076 ROS_INFO("Deleting the last node from the graph");
00077 }
00078
00079 void RosUi::bagRecording(bool _record_on) {
00080 if(this->record_on == _record_on){
00081 return;
00082 }
00083 this->record_on = _record_on;
00084 Q_EMIT toggleBagRecording();
00085 if(_record_on) {
00086 ROS_INFO("Recording Bagfile.");
00087 } else {
00088 ROS_INFO("Stopped Recording.");
00089 }
00090 }
00091
00092 void RosUi::pause(bool _pause_on) {
00093 if(this->pause_on == _pause_on){
00094 return;
00095 }
00096 this->pause_on = _pause_on;
00097 Q_EMIT togglePause();
00098 if(!_pause_on) {
00099 ROS_INFO("Processing.");
00100 } else {
00101 ROS_INFO("Stopped processing.");
00102 }
00103 }
00104
00105 void RosUi::setMax(float val){
00106 Q_EMIT setMaxDepth(val/100.0);
00107 }
00108
00109 void RosUi::createActions(const char* service_namespace) {
00110
00111 ros::NodeHandle n(service_namespace);
00112 server = n.advertiseService("ros_ui", &RosUi::services, this);
00113 server_b = n.advertiseService("ros_ui_b", &RosUi::services_b, this);
00114 server_f = n.advertiseService("ros_ui_f", &RosUi::services_f, this);
00115 }
00116
00117 bool RosUi::services(rgbdslam::rgbdslam_ros_ui::Request &req,
00118 rgbdslam::rgbdslam_ros_ui::Response &res )
00119 {
00120 if (req.comand == "reset" ){ resetCmd(); }
00121 else if(req.comand == "quick_save" ){ quickSaveAll(); }
00122 else if(req.comand == "save_cloud" ){ saveAll(); }
00123 else if(req.comand == "save_features" ){ saveFeatures(); }
00124 else if(req.comand == "save_trajectory"){ Q_EMIT saveTrajectory("trajectory"); }
00125 else if(req.comand == "save_individual"){ saveIndividual(); }
00126 else if(req.comand == "send_all" ){ sendAll(); }
00127 else if(req.comand == "frame" ){ getOneFrame(); }
00128 else if(req.comand == "delete_frame" ){ deleteLastFrame(); }
00129 else if(req.comand == "delete_frame" ){ Q_EMIT optimizeGraph(); }
00130 else{
00131 ROS_ERROR("Valid commands are: {reset, quick_save, save_all, save_individual, send_all, delete_frame}");
00132 return false;
00133 }
00134 return true;
00135 }
00136
00137 bool RosUi::services_b(rgbdslam::rgbdslam_ros_ui_b::Request &req,
00138 rgbdslam::rgbdslam_ros_ui_b::Response &res )
00139 {
00140 if (req.comand == "pause" ){ pause(req.value); }
00141 else if(req.comand == "record"){ bagRecording(req.value); }
00142 else if(req.comand == "mapping"){ Q_EMIT toggleMapping(req.value); }
00143 else if(req.comand == "store_pointclouds"){ toggleCloudStorage(req.value); }
00144 else{
00145 ROS_ERROR("Valid commands are: {pause, record}");
00146 return false;
00147 }
00148 return true;
00149 }
00150
00151 bool RosUi::services_f(rgbdslam::rgbdslam_ros_ui_f::Request &req,
00152 rgbdslam::rgbdslam_ros_ui_f::Response &res )
00153 {
00154 if(req.comand == "set_max"){
00155 setMax(req.value);
00156 return true;
00157 }
00158 else{
00159 ROS_ERROR("Command is set_max");
00160 return false;
00161 }
00162 }
00163
00164 void RosUi::toggleCloudStorage(bool storage) {
00165 ParameterServer::instance()->set("store_pointclouds", storage);
00166 ROS_INFO_COND(storage, "Point clouds will be stored");
00167 ROS_INFO_COND(!storage, "Point clouds will not be stored");
00168 }