6 rviz::Panel(parent), _gui(new Ui::rsm_controls()) {
22 "startStopExploration");
24 "setExplorationMode");
27 "startStopWaypointFollowing");
31 rsm_msgs::SetWaypointFollowingMode>(
"setWaypointFollowingMode");
51 rsm_msgs::GetWaypointRoutines>(
"getWaypointRoutines");
61 connect(
_gui->reset_waypoints_button, SIGNAL(clicked(
bool)),
this, SLOT(
resetWaypoints()));
63 connect(
_gui->set_waypoint_button, SIGNAL(clicked(
bool)),
this, SLOT(
addWaypoint()));
67 connect(
_gui->emergency_stop_button, SIGNAL(clicked(
bool)),
this, SLOT(
emergencyStop()));
68 connect(
_gui->stopped_radio_button, SIGNAL(clicked(
bool)),
this, SLOT(
stopOperation()));
70 connect(
_gui->teleoperation_radio_button, SIGNAL(clicked(
bool)),
this, SLOT(
setTeleoperation()));
72 connect(
_gui->stop_2d_nav_goal_button, SIGNAL(clicked(
bool)),
this, SLOT(
stop2dNavGoal()));
76 std_srvs::SetBool srv;
78 srv.request.data =
false;
80 srv.request.data =
true;
84 if (srv.response.success) {
86 _gui->start_exploration_button->setText(
"Start");
88 _gui->exploration_info_text->setText(
"Exploration stopped");
89 _gui->exploration_mode_box->setEnabled(
true);
91 _gui->start_exploration_button->setText(
"Stop");
93 _gui->exploration_info_text->setText(
"Exploration running");
95 _gui->exploration_mode_box->setEnabled(
false);
98 QString text = QString(
"Call unsuccessful: %1").arg(
99 srv.response.message.c_str());
100 _gui->exploration_info_text->setText(text);
103 ROS_ERROR(
"Failed to call service Start/Stop Exploration");
104 _gui->exploration_info_text->setText(
"Exploration service not available");
109 std_srvs::SetBool srv;
111 srv.request.data =
false;
113 srv.request.data =
true;
117 if (srv.response.success) {
119 _gui->start_waypoint_following_button->setText(
"Start");
121 _gui->waypoint_following_info_text->setText(
122 "Waypoint following stopped");
123 _gui->reset_waypoints_button->setEnabled(
true);
124 _gui->mode_box->setEnabled(
true);
126 _gui->start_waypoint_following_button->setText(
"Stop");
128 _gui->waypoint_following_info_text->setText(
"Waypoint running");
129 _gui->reset_waypoints_button->setEnabled(
false);
130 _gui->mode_box->setEnabled(
false);
134 QString text = QString(
"Call unsuccessful: %1").arg(
135 srv.response.message.c_str());
136 _gui->waypoint_following_info_text->setText(text);
139 ROS_ERROR(
"Failed to call service Start/Stop Waypoint Following");
140 _gui->waypoint_following_info_text->setText(
141 "Waypoint Following service not available");
146 std_srvs::Trigger srv;
149 if (srv.response.success) {
150 _gui->waypoint_following_info_text->setText(
"Waypoints reset");
152 QString text = QString(
"Reset unsuccessful: %1").arg(
153 srv.response.message.c_str());
154 _gui->waypoint_following_info_text->setText(text);
157 ROS_ERROR(
"Failed to call service Reset Waypoints");
158 _gui->waypoint_following_info_text->setText(
159 "Reset Waypoints service not available");
164 rsm_msgs::GetRobotPose srv;
166 ROS_ERROR(
"Failed to call Get Robot Pose service");
167 _gui->waypoint_following_info_text->setText(
168 "Get Robot Pose service not available");
170 rsm_msgs::AddWaypoint srv2;
171 rsm_msgs::Waypoint waypoint;
172 waypoint.pose = srv.response.pose;
173 if (
_gui->routine_combo_box->currentIndex() == 0) {
174 waypoint.routine =
"";
177 _gui->routine_combo_box->currentText().toUtf8().constData();
179 srv2.request.waypoint = waypoint;
180 srv2.request.position = -1;
182 ROS_ERROR(
"Failed to call Add Waypoint service");
183 _gui->waypoint_following_info_text->setText(
184 "Add Waypoint service not available");
190 std_srvs::SetBool srv;
193 if (srv.response.success) {
197 _gui->movement_label->setText(
"Control: Failed to change reverse mode");
200 ROS_ERROR(
"Failed to call Set Reverse Mode service");
201 _gui->movement_label->setText(
202 "Control: Set Reverse Mode service not available");
234 std_srvs::Trigger srv;
236 ROS_ERROR(
"Failed to call Stop 2D Nav Goal service");
237 _gui->movement_label->setText(
238 "Control: Stop 2D Nav Goal service not available");
243 rsm_msgs::SetOperationMode srv;
250 ROS_ERROR(
"Failed to call service Set Operation Mode");
251 _gui->control_label->setText(
252 "Control: Set Operation Mode service not available");
257 ROS_INFO(
"set waypoint following mode");
258 rsm_msgs::SetWaypointFollowingMode srv;
259 srv.request.mode =
_gui->mode_box->currentIndex();
261 if (!srv.response.success) {
263 QString(
"Set Waypoint Following Mode unsuccessful: %1").arg(
264 srv.response.message.c_str());
265 _gui->waypoint_following_info_text->setText(text);
269 ROS_ERROR(
"Failed to call service Set Waypoint Following Mode");
270 _gui->waypoint_following_info_text->setText(
271 "Set Waypoint Following Mode service not available");
276 std_srvs::SetBool srv;
277 srv.request.data =
_gui->exploration_mode_box->currentIndex();
279 ROS_ERROR(
"Failed to call service Set Operation Mode");
280 _gui->exploration_info_text->setText(
281 "Set Exploration Mode service not available");
286 const std_msgs::String::ConstPtr& state_info) {
287 QString text = QString(
"Current state: %1").arg(state_info->data.c_str());
288 _gui->current_state_text->setText(text);
289 if (state_info->data.rfind(
"E:") == 0) {
291 _gui->start_exploration_button->setText(
"Stop");
293 _gui->exploration_info_text->setText(
"Exploration running");
294 _gui->exploration_mode_box->setEnabled(
false);
296 }
else if (state_info->data.rfind(
"W:") == 0) {
298 _gui->start_waypoint_following_button->setText(
"Stop");
300 _gui->waypoint_following_info_text->setText(
301 "Waypoint Following running");
304 _gui->start_exploration_button->setText(
"Start");
306 _gui->exploration_info_text->setText(
"");
307 _gui->exploration_mode_box->setEnabled(
true);
308 _gui->start_waypoint_following_button->setText(
"Start");
309 _gui->reset_waypoints_button->setEnabled(
true);
310 _gui->mode_box->setEnabled(
true);
312 _gui->waypoint_following_info_text->setText(
"");
317 const std_msgs::Bool::ConstPtr& reverse_mode) {
323 const rsm_msgs::OperationMode::ConstPtr& operation_mode) {
336 rsm_msgs::GetWaypointRoutines srv;
340 list.append(it.c_str());
343 ROS_ERROR(
"Failed to call Get Waypoint Routines service");
345 _gui->routine_combo_box->addItems(list);
349 std_srvs::Trigger srv;
351 QString text = QString(
"Current state: %1").arg(
352 srv.response.message.c_str());
353 _gui->current_state_text->setText(text);
355 ROS_ERROR(
"Failed to call State Info service");
364 _gui->emergency_stop_button->setStyleSheet(
365 "background-color: rgba(150,75,75,1);color: rgba(0,0,0,1);");
366 _gui->autonomy_radio_button->setEnabled(
false);
367 _gui->teleoperation_radio_button->setEnabled(
false);
369 _gui->emergency_stop_button->setStyleSheet(
370 "background-color: rgba(150,0,0,1);color: rgba(255,255,255,1);");
371 _gui->autonomy_radio_button->setEnabled(
true);
372 _gui->teleoperation_radio_button->setEnabled(
true);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::ServiceClient _set_waypoint_following_mode_client
ros::ServiceClient _state_info_client
void setExplorationMode()
ros::ServiceClient _start_stop_waypoint_following_client
ros::ServiceClient _waypoint_reset_client
ros::ServiceClient _set_reverse_mode_client
void updateOperationModeGUI()
void reverseModeCallback(const std_msgs::Bool::ConstPtr &reverse_mode)
ros::ServiceClient _add_waypoint_client
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void startStopWaypointFollowing()
ros::Subscriber _state_info_subscriber
bool call(MReq &req, MRes &res)
bool _exploration_running
Is the exploration currently running.
ros::ServiceClient _set_operation_mode_client
ros::Subscriber _reverse_mode_subscriber
void startStopExploration()
void setWaypointFollowingMode()
void stateInfoCallback(const std_msgs::String::ConstPtr &state_info)
ros::ServiceClient _set_exploration_mode_client
virtual void load(const rviz::Config &config)
Saves configuration data from this panel to the Config object.
void setAutonomyOperation()
ros::ServiceClient _get_robot_pose_client
bool _operation_mode_button_pushed
Was an operation mode button just pushed.
void initRoutineComboBox()
void callSetOperationMode()
ros::Subscriber _operation_mode_subcriber
bool _waypoint_following_running
Is waypoint following currently running.
ros::ServiceClient _stop_2d_nav_goal_client
bool _emergency_stop_active
virtual void save(Config config) const
virtual void load(const Config &config)
void operationModeCallback(const rsm_msgs::OperationMode::ConstPtr &operation_mode)
std::vector< std::string > _waypoint_routines
ros::ServiceClient _start_stop_exploration_client
void initCommunications()
ros::ServiceClient _get_waypoint_routines_client
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
Panel plugin for RViz which adds buttons to interface the RSM.
RSMControlPanel(QWidget *parent=0)
Constructor.
virtual void save(rviz::Config config) const
Load configuration data for this panel from Config object.