31 #include <QApplication>
39 QApplication::closeAllWindows();
43 QCoreApplication::quit();
49 struct sigaction sigIntHandler;
58 sigemptyset(&sigIntHandler.sa_mask);
59 sigIntHandler.sa_flags = 0;
60 sigaction(SIGINT, &sigIntHandler, NULL);
67 rclcpp::Node(
"find_object_2d"),
72 std::string objectsPath;
73 std::string sessionPath;
74 std::string
settingsPath = QDir::homePath().append(
"/.ros/find_object_2d.ini").toStdString();
75 bool subscribeDepth =
false;
77 gui_ = this->declare_parameter(
"gui",
gui_);
78 objectsPath = this->declare_parameter(
"objects_path", objectsPath);
79 sessionPath = this->declare_parameter(
"session_path", sessionPath);
81 subscribeDepth = this->declare_parameter(
"subscribe_depth", subscribeDepth);
83 RCLCPP_INFO(this->get_logger(),
"gui=%d",
gui_?1:0);
84 RCLCPP_INFO(this->get_logger(),
"objects_path=%s", objectsPath.c_str());
85 RCLCPP_INFO(this->get_logger(),
"session_path=%s", sessionPath.c_str());
86 RCLCPP_INFO(this->get_logger(),
"settings_path=%s",
settingsPath.c_str());
87 RCLCPP_INFO(this->get_logger(),
"subscribe_depth = %s", subscribeDepth?
"true":
"false");
91 settingsPath = QDir::homePath().append(
"/.ros/find_object_2d.ini").toStdString();
95 if(!sessionPath.empty())
97 RCLCPP_WARN(this->get_logger(),
"\"settings_path\" parameter is ignored when \"session_path\" is set.");
101 if(path.contains(
'~'))
103 path.replace(
'~', QDir::homePath());
112 if(!sessionPath.empty())
114 if(!objectsPath.empty())
116 RCLCPP_WARN(this->get_logger(),
"\"objects_path\" parameter is ignored when \"session_path\" is set.");
120 RCLCPP_ERROR(this->get_logger(),
"Failed to load session \"%s\"", sessionPath.c_str());
123 else if(!objectsPath.empty())
125 QString path = objectsPath.c_str();
126 if(path.contains(
'~'))
128 path.replace(
'~', QDir::homePath());
132 RCLCPP_ERROR(this->get_logger(),
"No objects loaded from path \"%s\"", path.toStdString().c_str());
141 void exec(
int argc,
char ** argv, std::shared_ptr<rclcpp::Node> node)
146 QApplication
app(argc, argv);
156 if(topics.size() == 1)
159 "<qt>Find-Object subscribed to <b>%1</b> topic.<br/>"
160 "You can remap the topic when starting the node: <br/>\"rosrun find_object_2d find_object_2d image:=your/image/topic\".<br/>"
161 "</qt>").arg(topics.first()));
163 else if(topics.size() == 3)
166 "<qt>Find-Object subscribed to : <br/> <b>%1</b> <br/> <b>%2</b> <br/> <b>%3</b><br/>"
167 "</qt>").arg(topics.at(0)).arg(topics.at(1)).arg(topics.at(2)));
170 app.connect( &
app, SIGNAL( lastWindowClosed() ), &
app, SLOT( quit() ) );
183 QCoreApplication
app(argc, argv);
211 int main(
int argc,
char** argv)
213 rclcpp::init(argc, argv);
214 auto node = std::make_shared<FindObjectNode>();
215 node->exec(argc, argv, node);