selection_widget.h
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 6/27/17.
3 //
4 
5 #ifndef CHOREO_GUI_SELECTION_WIDGET_H
6 #define CHOREO_GUI_SELECTION_WIDGET_H
7 
8 #include <QString>
9 #include <QWidget>
10 
11 #include <ros/ros.h>
12 
14 
15 namespace Ui
16 {
17 class SelectionWidgetWindow;
18 }
19 
20 namespace choreo_gui
21 {
22 
23 class SelectionWidget : public QWidget
24 {
25  public:
26  enum MODE
27  {
29  ZOOM_IN_SELECTION, // TODO: DEPRECATED, should be merged with PATH SELECTION
30  PLAN_SELECTION
31  };
32 
34  {
36  PICKNPLACE
37  };
38 
40  {
43  CHOSEN
44  };
45 
46  Q_OBJECT
47  public:
48  SelectionWidget(QWidget* parent = 0);
49 
50  // CORE NODE COMMUNICATOR
51  //
52  // service request on required parameters
53  // will trigger orderValueChanged to update visualization
54  void loadParameters();
55 
56  // update display according to current print order
57  // this function call core service to update visualization of assembly sequence
58  // and is called whenever value changed in the selection widget ui panel
59  // (slider, button, checkbox, etc., as long as it relates to visualization info)
60  void orderValueChanged();
61 
62  // send srv to clean up visualization markers
63  void cleanUpVisual();
64  // CORE NODE COMMUNICATOR END
65  //
66 
67  // STATE CHANGE RESPONSER
68  //
69  // mode-dependent all sub-widget switch
70  void setInputEnabled(bool enabled);
71 
72  // switch for end effector visualization toggle
73  void setInputEndEffectorVisualEnabled(bool);
74 
75  // switch for grasp selection related widget
76  void setInputGraspEnabled(bool);
77 
78  // switch for IK selection related widget
79  void setInputIKSolutionEnabled(bool);
80 
81  // TODO: not fully implemented
82  void simSpeedChanged();
83  // STATE CHANGE RESPONSER END
84  //
85 
86  // GET FUNCTIONS
87  //
88  int getSelectedValueForPlanning() const { return selected_value_; }
89  double getSimSpeed() const { return sim_speed_; }
90  bool getUseSavedResult() const { return use_saved_result_; }
91 
92  std::vector<int> getSelectedIdsForSimulation() { return selected_ids_for_sim_; }
93  std::vector<int> getChosenIds() { return chosen_ids_for_sim_; }
94  SIMULATE_TYPE getSimulateType() { return sim_type_; }
95  //
96  // GET FUNCTIONS END
97 
98  // INTERNAL DATA SET / GET FUNCTIONS
99  //
100  // set max value, update slider & lineedit
101  void setMaxValue(int m);
102 
103  void setMaxGraspNum(int max_g);
104 
105  void setStatusBar(std::string string, bool state);
106 
107  // computed plan fetch / set / sort
108  void addFetchedPlans(const std::vector<std::string> &plan_names);
109  void getChosenPlans();
110 
111  // set path or plan selection mode
112  void setMode(const MODE& _mode) { mode_ = _mode; }
113  void setModelFileName(const std::string& m) { model_file_name_ = m; }
114 
115  void setAssemblyType(const std::string& at);
116  //
117  // INTERNAL DATA SET / GET FUNCTIONS
118 
119  void showTaskSequenceRecomputePopUp(bool found_task_plan);
120 
121  protected:
122  virtual void showEvent(QShowEvent *ev);
123  virtual void closeEvent(QCloseEvent *ev);
124 
125  Q_SIGNALS:
126  // this signal is for "pre-graph construction", after select plan id, enable zoom-in mode
127 // void selectForPlan();
128 
129  void simulateOn(SIMULATE_TYPE sim_type);
130 // void outputProcessOn(OUTPUT_TYPE output_type);
131  void setOutputSaveDirOn();
132 
133  // to notify state in gui to start simulation
134  void flushSimulation();
135  void flushOutputProcess();
136 
137  void closeWidgetAndContinue();
138  void enterSelectionWidget();
139  void exitSelectionWidget();
140  void recomputeTaskSequenceChosen();
141  void enableChoreoWidgetButtons();
142 
143  protected Q_SLOTS:
144  // different source that changes order_value
145  void buttonForwardUpdateOrderValue();
146  void buttonBackwardUpdateOrderValue();
147  void buttonSelectAll();
148 
149  void buttonSimulateSingle();
150  void buttonSimulateUntil();
151  void buttonSimulateChosen();
152  void buttonSimulate(SIMULATE_TYPE sim_type);
153 
154  void buttonOutputChosen();
155 
156  void buttonClearSelection();
157 
158  void buttonCloseWidget();
159 
160  // slot function for qt pushbutton select for plan
161  // change tab_widget to ZOOM_IN_SELECTION mode (tab 0)
162  // call core node to query saved ladder graph
163  // ask user to choose (1) use saved ladder graph and skip CLT-RRT*
164  // or (2) recompute ladder graph
165  void buttonSelectForPlan();
166 
167  // slot function for assembly order id update
168  void sliderUpdateOrderValue(int value);
169  void lineeditUpdateOrderValue();
170 
171  // slot function for grasp visual
172  void checkboxEEVisualUpdateValue();
173 
174  // slot function for grasp visualization selection id update
175  void sliderUpdateSelectedGraspValue(int value);
176  void lineeditUpdateSelectedGraspValue();
177 
178  // slot function for sim speed update
179  // TODO: not fully implemented
180  void sliderUpdateSimSpeed(int value);
181 
182  // recompute popup selection slot function
183  void recomputeChosen();
184  void useSavedResultChosen();
185  void useSavedTaskSequenceResultChosen();
186  void popUpWindowClosed();
187 
188  private:
190 
193 
194  Ui::SelectionWidgetWindow* ui_;
197 
198  // fetched id for slider and lineedit (depending on path or plan selection)
200 
201  // selected value for visualization
202  // used to synchronize selected seq id's slider and linedit
204 
205  // toggle for visualizing end effector
207 
208  // fetched grasp value for currect selection
209  // Note: should be single value if in plan_selection mode
210  std::vector<int> grasp_nums_;
212 
213  // selected value for grasp id for chosen assembly
214  // used to synchronize selected grasp id's slider and lineedit
216 
217  // TODO: should have max_ik_num & slected_ik_id_
218  // To be implemented
219 
220  std::vector<int> selected_ids_for_sim_;
221  std::vector<int> chosen_ids_for_sim_;
222  std::vector<int> fetched_plan_ids_;
223 
224  // recompute or use saved result toggle
225  // for (1) task sequence and (2) ladder graph
227 
228  // simulation speed for trajectory visualization
229  // belongs to (0, 1.0]
230  // TODO: not supported yet
231  double sim_speed_;
232 
233  std::string model_file_name_;
234 
238 };
239 }
240 
241 #endif //CHOREO_GUI_SELECTION_WIDGET_H
void setMode(const MODE &_mode)
ros::ServiceClient visualize_client_
Ui::SelectionWidgetWindow * ui_
std::vector< int > grasp_nums_
void setModelFileName(const std::string &m)
std::vector< int > fetched_plan_ids_
std::vector< int > getChosenIds()
std::vector< int > getSelectedIdsForSimulation()
SelectForPlanPopUpWidget * task_seq_recompute_pop_up_
int getSelectedValueForPlanning() const
std::vector< int > chosen_ids_for_sim_
SelectForPlanPopUpWidget * select_for_plan_pop_up_
std::vector< int > selected_ids_for_sim_
ros::ServiceClient query_computation_record_client_


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