22 #include <QMessageBox> 24 #include "../include/rh_p12_rn_gui/main_window.hpp" 44 QObject::connect(
ui.actionAbout_Qt, SIGNAL(triggered(
bool)), qApp, SLOT(aboutQt()));
45 QObject::connect(&
qnode, SIGNAL(refreshValue(
int,
int)),
this, SLOT(
valueChanged(
int,
int)));
47 QPixmap pix(
":/images/RH-P12-RN.png");
48 ui.label_pic->setPixmap(pix);
50 setWindowIcon(QIcon(
":/images/icon.png"));
51 QObject::connect(&
qnode, SIGNAL(rosShutdown()),
this, SLOT(close()));
65 ui.position_mode_radio->click();
68 ui.goal_current_slider->setValue(30);
85 ROS_INFO(
"Current-based Positon Control Mode On");
86 robotis_controller_msgs::SyncWriteItem _torque_msg;
87 _torque_msg.item_name =
"torque_enable";
88 _torque_msg.joint_name.push_back(
"gripper");
89 _torque_msg.value.push_back(0);
91 if (
ui.torque_onoff_check->checkState() == Checked)
96 robotis_controller_msgs::SyncWriteItem _mode_msg;
97 _mode_msg.item_name =
"operating_mode";
98 _mode_msg.joint_name.push_back(
"gripper");
99 _mode_msg.value.push_back(5);
105 if (
ui.torque_onoff_check->checkState() == Checked)
107 _torque_msg.value.clear();
108 _torque_msg.value.push_back(1);
114 int goal_curr_value =
ui.goal_current_spin->value();
115 if (goal_curr_value < 0)
116 goal_curr_value = (-1) * goal_curr_value;
117 ui.goal_current_spin->setValue(goal_curr_value);
119 ui.label_goal_velocity->setEnabled(
true);
120 ui.label_goal_acc->setEnabled(
true);
121 ui.label_goal_position->setEnabled(
true);
122 ui.goal_vel_slider->setEnabled(
true);
123 ui.goal_accel_slider->setEnabled(
true);
124 ui.goal_position_slider->setEnabled(
true);
125 ui.goal_vel_spin->setEnabled(
true);
126 ui.goal_accel_spin->setEnabled(
true);
127 ui.goal_position_spin->setEnabled(
true);
128 ui.label_max_goal_velocity->setEnabled(
true);
129 ui.label_max_goal_acc->setEnabled(
true);
130 ui.label_max_goal_position->setEnabled(
true);
132 ui.min_position_button->setText(
"Min (Open)\nPosition");
133 ui.max_position_button->setText(
"Max (Close)\nPosition");
134 ui.goal_position_button->setEnabled(
true);
136 ui.go_goal_psoition_check->setEnabled(
true);
138 ui.goal_current_slider->setMinimum(0);
139 ui.goal_current_spin->setMinimum(0);
149 ROS_INFO(
"Current Control Mode On");
150 robotis_controller_msgs::SyncWriteItem _torque_msg;
151 _torque_msg.item_name =
"torque_enable";
152 _torque_msg.joint_name.push_back(
"gripper");
153 _torque_msg.value.push_back(0);
155 if(
ui.torque_onoff_check->checkState() == Checked)
162 robotis_controller_msgs::SyncWriteItem _mode_msg;
163 _mode_msg.item_name =
"operating_mode";
164 _mode_msg.joint_name.push_back(
"gripper");
165 _mode_msg.value.push_back(0);
170 if(
ui.torque_onoff_check->checkState() == Checked)
172 _torque_msg.value.clear();
173 _torque_msg.value.push_back(1);
177 ui.label_goal_velocity->setEnabled(
false);
178 ui.label_goal_acc->setEnabled(
false);
179 ui.label_goal_position->setEnabled(
false);
180 ui.goal_vel_slider->setEnabled(
false);
181 ui.goal_accel_slider->setEnabled(
false);
182 ui.goal_position_slider->setEnabled(
false);
183 ui.goal_vel_spin->setEnabled(
false);
184 ui.goal_accel_spin->setEnabled(
false);
185 ui.goal_position_spin->setEnabled(
false);
186 ui.label_max_goal_velocity->setEnabled(
false);
187 ui.label_max_goal_acc->setEnabled(
false);
188 ui.label_max_goal_position->setEnabled(
false);
190 ui.min_position_button->setText(
"OPEN");
191 ui.max_position_button->setText(
"CLOSE");
192 ui.goal_position_button->setEnabled(
false);
194 ui.go_goal_psoition_check->setEnabled(
false);
196 ui.goal_current_slider->setMinimum(-820);
197 ui.goal_current_spin->setMinimum(-820);
205 robotis_controller_msgs::SyncWriteItem _torque_msg;
206 _torque_msg.item_name =
"torque_enable";
207 _torque_msg.joint_name.push_back(
"gripper");
212 _torque_msg.value.push_back(1);
217 _torque_msg.value.push_back(0);
225 robotis_controller_msgs::SyncWriteItem _goal_current_msg;
226 _goal_current_msg.item_name =
"goal_current";
227 _goal_current_msg.joint_name.push_back(
"gripper");
228 _goal_current_msg.value.push_back(value);
235 robotis_controller_msgs::SyncWriteItem _goal_vel_msg;
236 _goal_vel_msg.item_name =
"goal_velocity";
237 _goal_vel_msg.joint_name.push_back(
"gripper");
238 _goal_vel_msg.value.push_back(value);
244 ROS_WARN(
"goal accel. : %d", value);
245 robotis_controller_msgs::SyncWriteItem _goal_accel_msg;
246 _goal_accel_msg.item_name =
"goal_acceleration";
247 _goal_accel_msg.joint_name.push_back(
"gripper");
248 _goal_accel_msg.value.push_back(value);
254 if(
ui.go_goal_psoition_check->checkState() != Checked)
257 ROS_WARN(
"goal position : %d", value);
258 robotis_controller_msgs::SyncWriteItem _goal_position_msg;
259 _goal_position_msg.item_name =
"goal_position";
260 _goal_position_msg.joint_name.push_back(
"gripper");
261 _goal_position_msg.value.push_back(value);
269 if(
ui.torque_onoff_check->checkState() == Unchecked)
271 ui.torque_onoff_check->click();
275 if(
ui.position_mode_radio->isChecked() ==
true)
277 robotis_controller_msgs::SyncWriteItem _goal_position_msg;
278 _goal_position_msg.item_name =
"goal_position";
279 _goal_position_msg.joint_name.push_back(
"gripper");
280 _goal_position_msg.value.push_back(0);
283 ui.go_goal_psoition_check->setChecked(
false);
285 else if(
ui.current_mode_radio->isChecked() ==
true)
287 robotis_controller_msgs::SyncWriteItem _goal_current_msg;
288 _goal_current_msg.item_name =
"goal_current";
289 _goal_current_msg.joint_name.push_back(
"gripper");
290 if(
ui.goal_current_spin->value() > 0)
291 _goal_current_msg.value.push_back(-
ui.goal_current_spin->value());
293 _goal_current_msg.value.push_back(
ui.goal_current_spin->value());
297 ui.auto_repeat_check->setChecked(
false);
304 if(
ui.torque_onoff_check->checkState() == Unchecked)
306 ui.torque_onoff_check->click();
310 if(
ui.position_mode_radio->isChecked() ==
true)
312 robotis_controller_msgs::SyncWriteItem _goal_position_msg;
313 _goal_position_msg.item_name =
"goal_position";
314 _goal_position_msg.joint_name.push_back(
"gripper");
315 _goal_position_msg.value.push_back(740);
318 ui.go_goal_psoition_check->setChecked(
false);
320 else if(
ui.current_mode_radio->isChecked() ==
true)
322 robotis_controller_msgs::SyncWriteItem _goal_current_msg;
323 _goal_current_msg.item_name =
"goal_current";
324 _goal_current_msg.joint_name.push_back(
"gripper");
325 if(
ui.goal_current_spin->value() < 0)
326 _goal_current_msg.value.push_back(-
ui.goal_current_spin->value());
328 _goal_current_msg.value.push_back(
ui.goal_current_spin->value());
332 ui.auto_repeat_check->setChecked(
false);
338 if(
ui.position_mode_radio->isChecked() ==
true)
340 robotis_controller_msgs::SyncWriteItem _goal_position_msg;
341 _goal_position_msg.item_name =
"goal_position";
342 _goal_position_msg.joint_name.push_back(
"gripper");
343 _goal_position_msg.value.push_back(
ui.goal_position_spin->value());
347 ui.auto_repeat_check->setChecked(
false);
352 const int _max_stop_cnt = 7;
357 while(_main->
ui.auto_repeat_check->checkState() == Checked)
363 else if(++_stop_cnt > _max_stop_cnt)
365 robotis_controller_msgs::SyncWriteItem _msg;
366 _msg.joint_name.push_back(
"gripper");
367 if(_main->
ui.position_mode_radio->isChecked() ==
true)
369 _msg.item_name =
"goal_position";
370 _msg.value.push_back( (_dir)? 0:740 );
373 else if(_main->
ui.current_mode_radio->isChecked() ==
true)
375 _msg.item_name =
"goal_current";
376 _msg.value.push_back( (_dir)? _main->
ui.goal_current_spin->value():(-1)*(_main->
ui.goal_current_spin->value()) );
394 ui.go_goal_psoition_check->setChecked(
false);
395 if(
ui.torque_onoff_check->checkState() == Unchecked)
396 ui.torque_onoff_check->click();
407 if(
ui.torque_onoff_check->checkState() == Unchecked)
409 ui.torque_onoff_check->click();
416 robotis_controller_msgs::SyncWriteItem _goal_position_msg;
417 _goal_position_msg.item_name =
"goal_position";
418 _goal_position_msg.joint_name.push_back(
"gripper");
419 _goal_position_msg.value.push_back(
ui.goal_position_spin->value());
422 ui.auto_repeat_check->setChecked(
false);
435 ui.label_present_position->setText(QString::number(pos));
436 ui.label_present_current->setText(QString::number(curr));
449 robotis_controller_msgs::SyncWriteItem _torque_msg;
450 _torque_msg.item_name =
"torque_enable";
451 _torque_msg.joint_name.push_back(
"gripper");
452 _torque_msg.value.push_back(0);
455 QMainWindow::closeEvent(event);
void on_go_goal_psoition_check_clicked(bool check)
void on_goal_accel_slider_valueChanged(int value)
void on_auto_repeat_check_clicked(bool check)
void on_torque_onoff_check_clicked(bool check)
void on_goal_position_slider_valueChanged(int value)
void setPosition(const robotis_controller_msgs::SyncWriteItem &msg)
void on_goal_position_button_clicked(bool check)
void on_goal_current_slider_valueChanged(int value)
static void * autoRepeatFunc(void *main_window)
MainWindow(int argc, char **argv, QWidget *parent=0)
void on_min_position_button_clicked(bool check)
Qt central, all operations relating to the view part here.
void on_position_mode_radio_clicked(bool check)
uint32_t getItemValue(std::string item_name)
void on_max_position_button_clicked(bool check)
void valueChanged(int pos, int curr)
void on_current_mode_radio_clicked(bool check)
void closeEvent(QCloseEvent *event)
void setCtrlItem(const robotis_controller_msgs::SyncWriteItem &msg)
void on_goal_vel_slider_valueChanged(int value)