process_planning_state.cpp
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 7/5/17.
3 //
4 
5 #include <ros/console.h>
6 #include <QtConcurrent/QtConcurrentRun>
10 #include "choreo_gui/states/select_tasks_state.h" // next if fail
11 #include "choreo_gui/states/select_plan_state.h" // next if success
12 
13 const static std::string PROCESS_PLANNING_ACTION_CLIENT_NAME = "process_planning_action";
14 
15 choreo_gui::ProcessPlanningState::ProcessPlanningState(const int index, const bool use_ladder_graph_record)
16  : process_planning_action_client_(PROCESS_PLANNING_ACTION_CLIENT_NAME, true),
17  selected_path_index_(index),
18  use_ladder_graph_record_(use_ladder_graph_record)
19 {}
20 
22 {
23  gui.setText("Process Planning...\n");
24  gui.setButtonsEnabled(false);
25  gui_ptr_ = &gui;
26  QObject::connect(this, SIGNAL(feedbackReceived(QString)), this, SLOT(setFeedbackText(QString)));
27  QtConcurrent::run(this, &ProcessPlanningState::makeRequest);
28 }
29 
31 
32 // Handlers for the fixed buttons
34 {
36  Q_EMIT newStateAvailable(new SelectPlanState());
37 }
38 
40 {
42  Q_EMIT newStateAvailable(new SelectTasksState());
43 }
44 
46 {
48  Q_EMIT newStateAvailable(new SystemInitState());
49 }
50 
51 // State Specific Functions
53 {
54  choreo_msgs::ProcessPlanningGoal goal;
55  goal.action = choreo_msgs::ProcessPlanningGoal::GENERATE_MOTION_PLAN_AND_PREVIEW;
56  goal.index = selected_path_index_;
57  goal.use_saved_graph = use_ladder_graph_record_;
58 
59  ROS_INFO("Waiting for process planning action server to start.");
62  {
63  ROS_INFO_STREAM("process planning action server connected!");
64  }
65  else
66  {
67  ROS_WARN_STREAM("action process planning server not connected");
68  }
69 
71  goal,
75  ROS_INFO_STREAM("Goal sent from process planning state");
76 }
77 
79 {
80  gui_ptr_->appendText(feedback.toStdString());
81 }
82 
83 // Action Callbacks
86  const choreo_msgs::ProcessPlanningResultConstPtr& result)
87 {
88  if (result->succeeded)
89  {
90 // Q_EMIT newStateAvailable(new SelectPlansState());
92  }
93  else
94  {
95 // Q_EMIT newStateAvailable(new SelectTasksState());
96  }
97 }
98 
100 {
101  ROS_INFO_STREAM("Process Planning Goal is active");
102 }
103 
105  const choreo_msgs::ProcessPlanningFeedbackConstPtr& feedback)
106 {
107  Q_EMIT feedbackReceived(QString::fromStdString((feedback->last_completed).c_str()));
108 }
void setText(const std::string &txt)
virtual void onExit(ChoreoWidget &gui)
The ChoreoWidget class works in states:
Definition: choreo_widget.h:34
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
virtual void onBack(ChoreoWidget &gui)
actionlib::SimpleActionClient< choreo_msgs::ProcessPlanningAction > process_planning_action_client_
virtual void onReset(ChoreoWidget &gui)
#define ROS_INFO(...)
SelectionWidget & selection_widget()
Definition: choreo_widget.h:55
void processPlanningFeedbackCallback(const choreo_msgs::ProcessPlanningFeedbackConstPtr &feedback)
virtual void onNext(ChoreoWidget &gui)
virtual void onStart(ChoreoWidget &gui)
#define ROS_WARN_STREAM(args)
ProcessPlanningState(const int index, const bool use_ladder_graph_record)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
void processPlanningDoneCallback(const actionlib::SimpleClientGoalState &state, const choreo_msgs::ProcessPlanningResultConstPtr &result)
#define ROS_INFO_STREAM(args)
void appendText(const std::string &txt)
void setButtonsEnabled(bool enabled)
static const std::string PROCESS_PLANNING_ACTION_CLIENT_NAME
void newStateAvailable(GuiState *)
void feedbackReceived(QString feedback)


choreo_gui
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:58:56