19 #include <QMessageBox> 22 #include "../include/dynamixel_workbench_single_manager_gui/main_window.hpp" 32 QObject::connect(
ui_.actionAbout_Qt, SIGNAL(triggered(
bool)), qApp, SLOT(aboutQt()));
33 setWindowIcon(QIcon(
":/images/icon.png"));
35 ui_.tab_manager->setCurrentIndex(0);
36 QObject::connect(&
qnode_, SIGNAL(rosShutdown()),
this, SLOT(close()));
53 msgBox.setText(
"Couldn't find the ros master.");
60 if(
ui_.torque_enable_toggle_button->isChecked())
62 ui_.torque_enable_toggle_button->setText(
"Torque_Disable");
65 ui_.set_id_combo_box->setEnabled(
false);
66 ui_.set_operating_mode_combo_box->setEnabled(
false);
67 ui_.set_baud_rate_combo_box->setEnabled(
false);
69 ui_.set_position_zero_push_button->setVisible(
false);
70 ui_.set_address_value_dial->setEnabled(
false);
74 ui_.torque_enable_toggle_button->setText(
"Torque_Enable");
77 ui_.set_id_combo_box->setEnabled(
true);
78 ui_.set_operating_mode_combo_box->setEnabled(
true);
79 ui_.set_baud_rate_combo_box->setEnabled(
true);
81 ui_.set_position_zero_push_button->setVisible(
false);
82 ui_.set_address_value_dial->setEnabled(
false);
104 ui_.set_id_combo_box->setCurrentIndex(0);
105 ui_.set_baud_rate_combo_box->setCurrentIndex(0);
106 ui_.set_operating_mode_combo_box->setCurrentIndex(0);
108 if (
ui_.torque_enable_toggle_button->isChecked())
109 ui_.torque_enable_toggle_button->setChecked(
false);
124 if (
ui_.set_id_combo_box->currentText().toStdString() !=
"Select ID")
131 ui_.get_id_line_edit->setText(QString::number(
ui_.set_id_combo_box->currentText().toInt()));
138 if (
ui_.set_baud_rate_combo_box->currentText().toStdString() !=
"Select Baudrate")
145 ui_.get_baud_rate_line_edit->setText(QString::number(
ui_.set_baud_rate_combo_box->currentText().toLongLong()));
152 if (
ui_.set_operating_mode_combo_box->currentText().toStdString() !=
"Select Mode")
166 if (
ui_.set_address_name_combo_box->currentText().toStdString() ==
"Torque_Enable")
168 if (
ui_.set_address_value_spin_box->value() ==
true)
169 ui_.torque_enable_toggle_button->setChecked(
true);
170 else if (
ui_.set_address_value_spin_box->value() ==
false)
171 ui_.torque_enable_toggle_button->setChecked(
false);
180 if (index.toStdString() ==
"Goal_Position")
182 ui_.set_position_zero_push_button->setVisible(
true);
183 ui_.set_address_value_dial->setEnabled(
true);
189 ui_.set_position_zero_push_button->setVisible(
false);
190 ui_.set_address_value_dial->setEnabled(
false);
191 ui_.set_address_value_dial->setRange(-2048, 2048);
192 ui_.set_address_value_spin_box->setRange(-2048, 2048);
233 qRegisterMetaType<dynamixel_workbench_msgs::DynamixelInfo>(
"dynamixel_workbench_msgs::DynamixelInfo");
234 QObject::connect(&
qnode_, SIGNAL(updateDynamixelInfo(dynamixel_workbench_msgs::DynamixelInfo)),
this, SLOT(
updateDynamixelInfoLineEdit(dynamixel_workbench_msgs::DynamixelInfo)));
236 QObject::connect(
ui_.set_id_combo_box, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeID()));
237 QObject::connect(
ui_.set_baud_rate_combo_box, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeBaudrate()));
238 QObject::connect(
ui_.set_operating_mode_combo_box, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeOperatingMode()));
240 QObject::connect(
ui_.set_address_value_spin_box, SIGNAL(valueChanged(
int)),
ui_.set_address_value_dial, SLOT(setValue(
int)));
241 QObject::connect(
ui_.set_address_value_dial, SIGNAL(valueChanged(
int)),
ui_.set_address_value_spin_box, SLOT(setValue(
int)));
245 QObject::connect(
ui_.set_address_name_combo_box, SIGNAL(activated(QString)),
this, SLOT(
setEachAddressFunction(QString)));
252 ui_.set_id_combo_box->addItem((QString(
"Select ID")));
254 for (
id = 1;
id < 16;
id++)
256 ui_.set_id_combo_box->addItem(QString::number(
id));
269 ui_.set_baud_rate_combo_box->addItem((QString(
"Select Baudrate")));
273 ui_.set_baud_rate_combo_box->addItem(QString::number(9600));
274 ui_.set_baud_rate_combo_box->addItem(QString::number(19200));
275 ui_.set_baud_rate_combo_box->addItem(QString::number(57600));
276 ui_.set_baud_rate_combo_box->addItem(QString::number(115200));
277 ui_.set_baud_rate_combo_box->addItem(QString::number(200000));
278 ui_.set_baud_rate_combo_box->addItem(QString::number(250000));
279 ui_.set_baud_rate_combo_box->addItem(QString::number(400000));
280 ui_.set_baud_rate_combo_box->addItem(QString::number(500000));
281 ui_.set_baud_rate_combo_box->addItem(QString::number(1000000));
285 ui_.set_baud_rate_combo_box->addItem(QString::number(9600));
286 ui_.set_baud_rate_combo_box->addItem(QString::number(57600));
287 ui_.set_baud_rate_combo_box->addItem(QString::number(115200));
288 ui_.set_baud_rate_combo_box->addItem(QString::number(1000000));
289 ui_.set_baud_rate_combo_box->addItem(QString::number(2000000));
290 ui_.set_baud_rate_combo_box->addItem(QString::number(3000000));
291 ui_.set_baud_rate_combo_box->addItem(QString::number(4000000));
292 ui_.set_baud_rate_combo_box->addItem(QString::number(4500000));
293 ui_.set_baud_rate_combo_box->addItem(QString::number(10500000));
299 ui_.set_operating_mode_combo_box->addItem((QString(
"Select Mode")));
305 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
306 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
315 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
316 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
317 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
321 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
322 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
323 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
324 ui_.set_operating_mode_combo_box->addItem(QString(
"pwm_control"));
329 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
330 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
331 ui_.set_operating_mode_combo_box->addItem(QString(
"current_control"));
332 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
333 ui_.set_operating_mode_combo_box->addItem(QString(
"current_based_position_control"));
334 ui_.set_operating_mode_combo_box->addItem(QString(
"pwm_control"));
341 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
342 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
343 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
344 ui_.set_operating_mode_combo_box->addItem(QString(
"pwm_control"));
348 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
349 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
355 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
356 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
357 ui_.set_operating_mode_combo_box->addItem(QString(
"current_control"));
358 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
359 ui_.set_operating_mode_combo_box->addItem(QString(
"current_based_position_control"));
360 ui_.set_operating_mode_combo_box->addItem(QString(
"pwm_control"));
366 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
367 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
371 ui_.set_operating_mode_combo_box->addItem(QString(
"position_control"));
372 ui_.set_operating_mode_combo_box->addItem(QString(
"velocity_control"));
373 ui_.set_operating_mode_combo_box->addItem(QString(
"torque_control"));
374 ui_.set_operating_mode_combo_box->addItem(QString(
"extended_position_control"));
381 if (
ui_.get_protocol_version_line_edit->text().toFloat() == 2.0)
383 ui_.reboot_push_button->setEnabled(
true);
387 ui_.reboot_push_button->setEnabled(
false);
394 uint8_t index_num =
ui_.set_address_name_combo_box->count();
395 for (uint8_t combo_box_index = 0; combo_box_index < index_num; combo_box_index++)
397 ui_.set_address_name_combo_box->removeItem(0);
400 uint16_t torque_enable_address = 0;
405 if (!strncmp(item_ptr[item_num].item_name,
"Torque_Enable", strlen(
"Torque_Enable")))
407 torque_enable_address = item_num;
416 if (item_num >= torque_enable_address)
417 ui_.set_address_name_combo_box->addItem(QString::fromStdString(item_ptr[item_num].item_name));
421 ui_.set_address_name_combo_box->addItem(QString::fromStdString(item_ptr[item_num].item_name));
434 ui_.set_address_value_spin_box->setRange(-2048, 2048);
435 ui_.set_position_zero_push_button->setVisible(
false);
436 ui_.set_address_value_dial->setEnabled(
false);
441 QMessageBox::about(
this, tr(
"About ..."),tr(
"<h2>Dynamixel workbench 1.0</h2><p>Copyright Robotis</p>"));
446 QMessageBox::about(
this, tr(
"Error ..."),tr(
"<h2>Error!!!!!</h2><p>It didn't works!!</p>"));
451 QMessageBox::about(
this, tr(
"Right ..."),tr(
"<h2>Complete!!</h2><p>It works!!</p>"));
456 QMainWindow::closeEvent(event);
void on_reboot_push_button_clicked(bool check)
void on_torque_enable_toggle_button_toggled(bool check)
void setAddressComboBox(bool torque_enable)
MainWindow(int argc, char **argv, QWidget *parent=0)
void setOperatingModeComboBox()
DynamixelTool * dynamixel_tool_
QStringListModel * loggingModel()
void on_set_position_zero_push_button_clicked(bool check)
bool sendSetBaudrateMsg(int64_t baud_rate)
void closeEvent(QCloseEvent *event)
bool sendAddressValueMsg(std::string addr_name, int64_t value)
void showNoMasterMessage()
bool sendTorqueMsg(int64_t onoff)
DynamixelLoadInfo lode_info
void changeControlTableValue()
void on_factory_reset_push_button_clicked(bool check)
void setEachAddressFunction(QString index)
DynamixelInfo * dynamixel_info_
void changeOperatingMode()
void on_actionAbout_triggered()
bool sendSetIdMsg(uint8_t set_id)
void updateDynamixelInfoLineEdit(dynamixel_workbench_msgs::DynamixelInfo dynamixel_info)
void writeReceivedDynamixelData()
bool sendSetOperatingModeMsg(std::string index, float protocol_version, std::string model_name, int32_t value_of_max_radian_position)
bool setPositionZeroMsg(int32_t zero_position)
void setBaudRateComboBox()