From 9d40f9ea6c4ec6eae42f4ae3bce01105f2459f16 Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 5 Nov 2024 13:00:36 -0600 Subject: [PATCH] Remove Create 3 mentions --- include/botui/Create3ExampleWidget.h | 42 -- include/botui/Create3SensorListWidget.h | 31 -- include/botui/Create3SensorModel.h | 51 -- include/botui/Create3Widget.h | 43 -- include/botui/MotorsSensorsWidget.h | 3 +- src/Create3ExampleWidget.cpp | 481 ----------------- src/Create3SensorListWidget.cpp | 61 --- src/Create3SensorModel.cpp | 326 ----------- src/Create3Widget.cpp | 683 ------------------------ src/HomeWidget.cpp | 17 +- src/MotorsSensorsWidget.cpp | 8 - ui/Create3ExampleWidget.ui | 115 ---- ui/Create3SensorList.ui | 267 --------- ui/Create3SensorListWidget.ui | 104 ---- ui/Create3Widget.ui | 299 ----------- ui/MotorsSensorsWidget.ui | 28 - 16 files changed, 2 insertions(+), 2557 deletions(-) delete mode 100644 include/botui/Create3ExampleWidget.h delete mode 100644 include/botui/Create3SensorListWidget.h delete mode 100644 include/botui/Create3SensorModel.h delete mode 100644 include/botui/Create3Widget.h delete mode 100644 src/Create3ExampleWidget.cpp delete mode 100644 src/Create3SensorListWidget.cpp delete mode 100644 src/Create3SensorModel.cpp delete mode 100644 src/Create3Widget.cpp delete mode 100644 ui/Create3ExampleWidget.ui delete mode 100644 ui/Create3SensorList.ui delete mode 100644 ui/Create3SensorListWidget.ui delete mode 100644 ui/Create3Widget.ui diff --git a/include/botui/Create3ExampleWidget.h b/include/botui/Create3ExampleWidget.h deleted file mode 100644 index 3ea367d3..00000000 --- a/include/botui/Create3ExampleWidget.h +++ /dev/null @@ -1,42 +0,0 @@ -// #ifndef _CREATE3EXAMPLEWIDGET_H_ -// #define _CREATE3EXAMPLEWIDGET_H_ - -// #include "StandardWidget.h" - -// #include -// #include -// namespace Ui -// { -// class Create3ExampleWidget; -// } - -// class Create3SensorModel; - -// class Create3ExampleWidget : public StandardWidget -// { -// Q_OBJECT -// public: -// Create3ExampleWidget(Device *device, QWidget *parent = 0); -// ~Create3ExampleWidget(); - -// private slots: - -// int create3Connect(); -// int isConnected(); -// void indexChanged(int index); -// void run(); - -// private: -// Ui::Create3ExampleWidget *ui; - -// Create3SensorModel *_model; -// double m_setpointVal; -// double m_feedbackVal; -// int m_position_1; -// double m_vel_1; -// void update(); -// QStringListModel *model; -// void updatePids(); -// }; - -// #endif diff --git a/include/botui/Create3SensorListWidget.h b/include/botui/Create3SensorListWidget.h deleted file mode 100644 index 156afd9c..00000000 --- a/include/botui/Create3SensorListWidget.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _CREATE3SENSORLISTWIDGET_H_ -#define _CREATE3SENSORLISTWIDGET_H_ - -#include "StandardWidget.h" - -#include - -namespace Ui -{ - class Create3SensorListWidget; -} - -class Create3SensorModel; - -class Create3SensorListWidget : public StandardWidget -{ - Q_OBJECT -public: - Create3SensorListWidget(Device *device, QWidget *parent = 0); - ~Create3SensorListWidget(); - -private slots: - - -private: - Ui::Create3SensorListWidget *ui; - Create3SensorModel *_model; - -}; - -#endif diff --git a/include/botui/Create3SensorModel.h b/include/botui/Create3SensorModel.h deleted file mode 100644 index caa6a238..00000000 --- a/include/botui/Create3SensorModel.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _CREATE3SENSORMODEL_H_ -#define _CREATE3SENSORMODEL_H_ - -#include - -class Create3SensorModel : public QStandardItemModel -{ -Q_OBJECT -public: - - enum SensorType { - Bump0, - Bump1, - Bump2, - Bump3, - Bump4, - Cliff0, - Cliff1, - Cliff2, - Cliff3, - IR0, - IR1, - IR2, - IR3, - IR4, - IR5, - IR6, - Other - }; - - enum SensorMethod { - Bump, - Cliff, - IR - }; - Create3SensorModel(QObject *parent = 0); - ~Create3SensorModel(); - - Create3SensorModel::SensorType type(const QModelIndex &index) const; - -public slots: - void update(); - -private: - void populate(); - void populateBump(unsigned int port); - void populateCliff(unsigned int port); - void populateIR(unsigned int port); -}; - -#endif diff --git a/include/botui/Create3Widget.h b/include/botui/Create3Widget.h deleted file mode 100644 index 3fbc34ec..00000000 --- a/include/botui/Create3Widget.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _CREATE3WIDGET_H_ -#define _CREATE3WIDGET_H_ - -#include "StandardWidget.h" - -#include -#include -#include - -namespace Ui -{ - class Create3Widget; -} - -class Create3SensorModel; - -class Create3Widget : public StandardWidget -{ - Q_OBJECT -public: - Create3Widget(Device *device, QWidget *parent = 0); - ~Create3Widget(); - -private slots: - - QString getIP(); - void toggleChanged(); - void indexChanged(int index); - void run(); - void rebootBox(); - -private: - Ui::Create3Widget *ui; - - Create3SensorModel *_model; - double m_setpointVal; - double m_feedbackVal; - int m_position_1; - QStringListModel *model; - double m_vel_1; -}; - -#endif diff --git a/include/botui/MotorsSensorsWidget.h b/include/botui/MotorsSensorsWidget.h index 99d51d19..64c34e40 100644 --- a/include/botui/MotorsSensorsWidget.h +++ b/include/botui/MotorsSensorsWidget.h @@ -21,8 +21,7 @@ private slots: void sensorGraph(); void sensorList(); void camera(); - void Create3(); - + private: Ui::MotorsSensorsWidget *ui; }; diff --git a/src/Create3ExampleWidget.cpp b/src/Create3ExampleWidget.cpp deleted file mode 100644 index ac924fae..00000000 --- a/src/Create3ExampleWidget.cpp +++ /dev/null @@ -1,481 +0,0 @@ -// #include "Create3ExampleWidget.h" -// #include "ui_Create3ExampleWidget.h" -// #include "Create3SensorListWidget.h" -// #include -// #include -// #include "NumpadDialog.h" -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include "RootController.h" -// #include -// #include -// #include -// #include -// int exampleIndex; -// QStringList programList; -// // QStandardItemModel model(4,4); -// Create3ExampleWidget::Create3ExampleWidget(Device *device, QWidget *parent) -// : StandardWidget(device, parent), -// ui(new Ui::Create3ExampleWidget) -// { -// ui->setupUi(this); -// performStandardSetup(tr("Create 3 Examples"), false); -// connect(ui->exampleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int))); - -// connect(ui->exampleRunButton, SIGNAL(clicked()), SLOT(run())); - -// // Create model -// model = new QStringListModel(this); -// ui->listWidget->clear(); -// programList.clear(); -// programList << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');"; - -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// qDebug() << "Program List: " << programList; -// ui->listWidget->setSpacing(6); -// } - -// Create3ExampleWidget::~Create3ExampleWidget() -// { -// delete ui; -// } - -// int Create3ExampleWidget::isConnected() -// { -// int connected = 0; -// try -// { -// connected = create3_is_connected(); -// qDebug() << "Create connected? " << connected; -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } -// return connected; -// } - -// int Create3ExampleWidget::create3Connect() -// { -// int connected = 0; -// try -// { -// connected = create3_connect_manual("192.168.125.1", 50051); -// qDebug() << "Create connected? " << connected; -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } -// return connected; -// } -// void Create3ExampleWidget::run() -// { -// exampleIndex = ui->exampleComboBox->currentIndex(); -// switch (exampleIndex) -// { - -// case 0: -// { // 01_Connect -// try -// { -// printf("Connecting to Create3 robot...\n"); -// create3_connect_manual("192.168.125.1", 50051); -// printf("Connected!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } -// break; -// } - -// case 1: // 02_Dock_Undock -// { - -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Undocking...\n"); -// // Move forward at 0.5 m/s for 1 second -// create3_undock(); - -// create3_wait(); - -// printf("Docking...\n"); - -// create3_dock(); - -// create3_wait(); - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } - -// break; -// } - -// case 2: // 03_Move_Velocity -// { -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Moving forward at 0.5 m/s for 1 second...\n"); - -// // Move forward at 0.5 m/s for 1 second -// create3_velocity_set_components(0.5, 0); - -// // Wait for 1 second -// usleep(1000000); - -// // Stop -// create3_velocity_set_components(0.0, 0.0); - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } -// break; -// } - -// case 3: // 04_Rotate -// { -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Rotate at 0.5 m/s for 1 second...\n"); - -// // Rotate at 90 deg/s (PI/2 rad/s) to 90 degrees (PI/2 radians) -// create3_rotate_degrees(90, 90); -// create3_rotate_radians(1.57, 1.57); - -// // Wait for 1 second -// create3_wait(); - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } - -// break; -// } - -// case 4: // 05_Arc -// { -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Rotate at 0.5 m/s for 1 second...\n"); - -// // Arc of 90 deg (PI/2 rad) with radius of 0.5 m -// create3_drive_arc_degrees(0.5, 90, 0.306); -// create3_drive_arc_radians(0.5, -1.57, 0.460); - -// // Wait for 1 second -// create3_wait(); - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } - -// break; -// } - -// case 5: // 06_led_test -// { -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Blinking lights...\n"); -// // Blink the lights green for 5 seconds. - -// Create3LedColor green; -// green.r = 0; -// green.g = 255; -// green.b = 0; - -// Create3Lightring lightring; -// lightring.led0 = green; -// lightring.led1 = green; -// lightring.led2 = green; -// lightring.led3 = green; -// lightring.led4 = green; -// lightring.led5 = green; - -// create3_led_animation(Create3BlinkLights, lightring, 5.0); // Blink the lights green for 5 seconds. - -// // Wait for 1 second -// create3_wait(); - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } - -// break; -// } -// case 6: // 07_sensors -// { -// try -// { -// printf("Connecting to Create3 robot...\n"); - -// create3_connect_manual("192.168.125.1", 50051); - -// printf("Connected!\n"); - -// printf("Sensor Values:\n"); -// printf(" Left Side Cliff: %d\n", create3_sensor_cliff(0)); -// printf(" Left Front Cliff: %d\n", create3_sensor_cliff(1)); -// printf(" Right Front Cliff: %d\n", create3_sensor_cliff(2)); -// printf(" Right Side Cliff: %d\n", create3_sensor_cliff(3)); -// printf("\n"); -// printf(" Left Side IR: %d\n", create3_sensor_ir(0)); -// printf(" Left IR: %d\n", create3_sensor_ir(1)); -// printf(" Left Front IR: %d\n", create3_sensor_ir(2)); -// printf(" Left Center IR: %d\n", create3_sensor_ir(3)); -// printf(" Right Center IR: %d\n", create3_sensor_ir(4)); -// printf(" Right Front IR: %d\n", create3_sensor_ir(5)); -// printf(" Right IR: %d\n", create3_sensor_ir(6)); - -// printf(" Left Bumper: %d\n", create3_sensor_bump(0)); -// printf(" Left Front Bumper: %d\n", create3_sensor_bump(1)); -// printf(" Center Front Bumper: %d\n", create3_sensor_bump(2)); -// printf(" Right Front Bumper: %d\n", create3_sensor_bump(3)); -// printf(" Right Bumper: %d\n", create3_sensor_bump(4)); - -// while (create3_sensor_bump(3) == 0) -// { -// if (create3_sensor_bump(3) == 1) -// { -// create3_velocity_set_components(0.0, 0.0); -// break; -// } -// create3_velocity_set_components(0.15, 0.0); -// } - -// printf("Done!\n"); -// } -// catch (const std::exception &e) -// { -// std::cerr << e.what() << '\n'; -// } -// } - -// default: -// break; -// } -// } -// void Create3ExampleWidget::indexChanged(int index) -// { - -// programList.clear(); -// ui->listWidget->clear(); -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// switch (index) -// { -// case 0: // 01_Connect -// { - -// programList << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');"; -// qDebug() << "Program List: " << programList; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// break; -// } - -// case 1: // 02_Dock_Undock -// { -// programList.clear(); -// programList << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Undocking...');" -// << "create3_undock();" -// << "create3_wait();" -// << "printf('Done!');"; -// qDebug() << "Program List: " << programList; - -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// break; -// } -// case 2: // 03_Move_Velocity -// { - -// programList -// << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Moving forward at 0.5 m/s for 1 second...');" -// << "//Move forward at 0.5 m/s for 1 second" -// << "create3_velocity_set_components(0.5, 0);" -// << "//Wait for 1 second" -// << "usleep(1000000);" -// << "//Stop" -// << "create3_velocity_set_components(0.0, 0.0);" -// << "printf('Done!');"; -// qDebug() << "Program List: " << programList; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(6)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(8)->setForeground(QColor(0, 128, 0)); - -// break; -// } -// case 3: // 04_Rotate -// programList -// << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Rotate at 0.5 m/s for 1 second...');" -// << "//Rotate at 90 deg/s (PI/2 rad/s) to 90 degrees (PI/2 radians)" -// << "create3_rotate_degrees(90, 90);" -// << "create3_rotate_radians(1.57, 1.57);" -// << "//Wait for 1 second" -// << "create3_wait();" -// << "printf('Done!');"; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(7)->setForeground(QColor(0, 128, 0)); - -// break; -// case 4: // 05_Arc -// programList -// << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Rotate at 0.5 m/s for 1 second...');" -// << "//Arc of 90 deg (PI/2 rad) with radius of 0.5 m" -// << "create3_drive_arc_degrees(0.5, 90, 0.306);" -// << "create3_drive_arc_radians(0.5, -1.57, 0.460);" -// << "//Wait for 1 second" -// << "create3_wait();" -// << "printf('Done!');"; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(7)->setForeground(QColor(0, 128, 0)); -// break; -// case 5: // 06_led_test -// programList -// << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Blinking lights...');" -// << "//Blink the lights green for 5 seconds." -// << "Create3LedColor green;" -// << "green.r = 0;" -// << "green.g = 255;" -// << "green.b = 0;" -// << "Create3Lightring lightring;" -// << "lightring.led0 = green;" -// << "lightring.led1 = green;" -// << "lightring.led2 = green;" -// << "lightring.led3 = green;" -// << "lightring.led4 = green;" -// << "lightring.led5 = green;" -// << "// Blink the lights green for 5 seconds." -// << "create3_led_animation(Create3BlinkLights, lightring, 5.0);" -// << "//Wait for 1 second" -// << "create3_wait();" -// << "printf('Done!');"; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); -// ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(16)->setForeground(QColor(0, 128, 0)); -// ui->listWidget->item(18)->setForeground(QColor(0, 128, 0)); -// break; -// case 6: // 07_sensors -// programList -// << "printf('Connecting to Create3 robot...');" -// << "create3_connect_manual('192.168.125.1', 50051);" -// << "printf('Connected!');" -// << "printf('Sensor Values:');" -// << "printf(' Left Side Cliff: %d', create3_sensor_cliff(0));" -// << "printf(' Left Front Cliff: %d', create3_sensor_cliff(1));" -// << "printf(' Right Front Cliff: %d', create3_sensor_cliff(2));" -// << "printf(' Right Side Cliff: %d', create3_sensor_cliff(3));" -// << "printf(' Left Side IR: %d', create3_sensor_ir(0));" -// << "printf(' Left IR: %d', create3_sensor_ir(1));" -// << "printf(' Left Front IR: %d', create3_sensor_ir(2));" -// << "printf(' Left Center IR: %d', create3_sensor_ir(3));" -// << "printf(' Right Center IR: %d', create3_sensor_ir(4));" -// << "printf(' Right Front IR: %d', create3_sensor_ir(5));" -// << "printf(' Right IR: %d', create3_sensor_ir(6));" -// << "printf(' Left Bumper: %d', create3_sensor_bump(0));" -// << "printf(' Left Front Bumper: %d', create3_sensor_bump(1));" -// << "printf(' Center Front Bumper: %d', create3_sensor_bump(2));" -// << "printf(' Right Front Bumper: %d', create3_sensor_bump(3));" -// << "printf(' Right Bumper: %d', create3_sensor_bump(4));" -// << "while (create3_sensor_bump(3) == 0)" -// << "{" -// << " if (create3_sensor_bump(3) == 1)" -// << " {" -// << " create3_velocity_set_components(0.0, 0.0);" -// << " break;" -// << " }" -// << " create3_velocity_set_components(0.15, 0.0);" -// << "}" -// << "printf('Done!');"; -// ui->listWidget->addItems(programList); -// model->setStringList(programList); - -// break; -// default: -// break; -// } -// } diff --git a/src/Create3SensorListWidget.cpp b/src/Create3SensorListWidget.cpp deleted file mode 100644 index 174d0315..00000000 --- a/src/Create3SensorListWidget.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "Create3SensorListWidget.h" -#include "ui_Create3SensorListWidget.h" - -#include "Create3SensorModel.h" -#include -#include -#include "NumpadDialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Create3SensorItemDelegate : public QItemDelegate -{ -public: - Create3SensorItemDelegate(Create3SensorModel *const model, QObject *const parent = 0); - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - const Create3SensorModel *const _model; - const QPixmap _up; - const QPixmap _down; -}; - -Create3SensorItemDelegate::Create3SensorItemDelegate(Create3SensorModel *const model, QObject *const parent) - : QItemDelegate(parent), _model(model), _up(QIcon(":/icons/arrow_up.png").pixmap(16, 16)), _down(QIcon(":/icons/arrow_down.png").pixmap(16, 16)) -{ -} - -void Create3SensorItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QItemDelegate::paint(painter, option, index); -} - -Create3SensorListWidget::Create3SensorListWidget(Device *device, QWidget *parent) - : StandardWidget(device, parent), - ui(new Ui::Create3SensorListWidget), _model(new Create3SensorModel(this)) -{ - ui->setupUi(this); - performStandardSetup(tr("Create 3"), false); - setStyleSheet("QScrollBar:vertical {border: 2px solid grey;background:grey ;width: 100px; margin: 22px 0 22px 0; } QScrollBar::handle:vertical { border: 2px solid grey;background: white; min-height: 20px; } QScrollBar::add-line:vertical { border: 2px solid grey;background: #32CC99; height: 20px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical {border: 2px solid grey; background: #32CC99; height: 20px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 2px solid grey;width: 3px; height: 3px; background: white; }QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {border: 2px solid grey; background: none;}"); - // connect(ui->Create3ConnectButton, SIGNAL(clicked()), SLOT(create3Connect())); - - ui->sensors->setModel(_model); - ui->sensors->setItemDelegate(new Create3SensorItemDelegate(_model, this)); - QTimer *timer = new QTimer(this); - _model->connect(timer, SIGNAL(timeout()), SLOT(update())); - timer->start(200); // 5 FPS -} - -Create3SensorListWidget::~Create3SensorListWidget() -{ - delete ui; -} - - diff --git a/src/Create3SensorModel.cpp b/src/Create3SensorModel.cpp deleted file mode 100644 index 21f6d216..00000000 --- a/src/Create3SensorModel.cpp +++ /dev/null @@ -1,326 +0,0 @@ -#include "Create3SensorModel.h" -#include -#include -#include -#include -#include - -class Create3SensorNameItem : public QStandardItem -{ -public: - Create3SensorNameItem(Create3SensorModel::SensorType type, const int port = -1) - : m_type(type), m_port(port), m_typeName(typeName(type)), m_optionName(optionName(type)) - { - setText(m_typeName); - } - - Create3SensorModel::SensorType sensorType() const - { - return m_type; - } - - int port() const - { - return m_port; - } - - template - static Create3SensorNameItem *cast(T *t) - { - return dynamic_cast(t); - } - -private: - static QString typeName(Create3SensorModel::SensorType type) - { - switch (type) - { - case Create3SensorModel::Bump0: - return QObject::tr("Left Bumper"); - case Create3SensorModel::Bump1: - return QObject::tr("Left Front Bumper"); - case Create3SensorModel::Bump2: - return QObject::tr("Center Front Bumper"); - case Create3SensorModel::Bump3: - return QObject::tr("Right Front Bumper"); - case Create3SensorModel::Bump4: - return QObject::tr("Right Bumper"); - case Create3SensorModel::Cliff0: - return QObject::tr("Left Side Cliff"); - case Create3SensorModel::Cliff1: - return QObject::tr("Left Front Cliff"); - case Create3SensorModel::Cliff2: - return QObject::tr("Right Front Cliff"); - case Create3SensorModel::Cliff3: - return QObject::tr("Right Side Cliff"); - case Create3SensorModel::IR0: - return QObject::tr("Left Side IR"); - case Create3SensorModel::IR1: - return QObject::tr("Left IR"); - case Create3SensorModel::IR2: - return QObject::tr("Left Front IR"); - case Create3SensorModel::IR3: - return QObject::tr("Left Center IR"); - case Create3SensorModel::IR4: - return QObject::tr("Right Center IR"); - case Create3SensorModel::IR5: - return QObject::tr("Right Front IR"); - case Create3SensorModel::IR6: - return QObject::tr("Right IR"); - - default: - break; - } - return QObject::tr("Unknown Sensor"); - } - - static QString optionName(Create3SensorModel::SensorType type) - { - return QString(); - } - - Create3SensorModel::SensorType m_type; - int m_port; - QString m_typeName; - QString m_optionName; -}; - -class Updateable -{ -public: - virtual void update() = 0; - - template - static Updateable *cast(T *t) - { - return dynamic_cast(t); - } -}; - -template -class Create3SensorValueItem : public QStandardItem, public Updateable -{ -public: - Create3SensorValueItem(Create3SensorModel::SensorMethod name, const unsigned char port, const bool owns) - : m_value(typeName(name, port)), m_owns(owns) - { - } - - ~Create3SensorValueItem() - { - } - - virtual void update() - { - - setText(QString("%1").arg(m_value)); - } - - template - static Create3SensorValueItem *cast(L *t) - { - return dynamic_cast(t); - } - -private: - bool m_owns; - int m_value; - - static int typeName(Create3SensorModel::SensorMethod name, int port) - { - if(create3_is_connected()) { - try - { - switch (name) - { - case Create3SensorModel::Bump: - return create3_sensor_bump(port); - case Create3SensorModel::Cliff: - return create3_sensor_cliff(port); - case Create3SensorModel::IR: - return create3_sensor_ir(port); - default: - break; - } - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - return 0; - } - } - return 0; - } -}; - -Create3SensorModel::Create3SensorModel(QObject *parent) - : QStandardItemModel(parent) -{ - populate(); - QTimer *updateTimer = new QTimer(this); - connect(updateTimer, SIGNAL(timeout()), SLOT(update())); - updateTimer->start(200); -} - -Create3SensorModel::~Create3SensorModel() -{ -} - -Create3SensorModel::SensorType Create3SensorModel::type(const QModelIndex &index) const -{ - QModelIndex nameIndex = index.sibling(index.row(), 0); - Create3SensorNameItem *const item = Create3SensorNameItem::cast(itemFromIndex(nameIndex)); - return item ? item->sensorType() : Create3SensorModel::Other; -} - -void Create3SensorModel::update() -{ - // populate(); ADDS TONS OF ROWS updating values - // setItem(0, 1, new Create3SensorValueItem(Create3SensorModel::Bump, 0, true)); - // setItem(1, 1, new Create3SensorValueItem(Create3SensorModel::Bump, 1, true)); - // setItem(2, 1, new Create3SensorValueItem(Create3SensorModel::Bump, 2, true)); - // setItem(3, 1, new Create3SensorValueItem(Create3SensorModel::Bump, 3, true)); - // setItem(4, 1, new Create3SensorValueItem(Create3SensorModel::Bump, 4, true)); - - for (int i = 0; i < 5; i++) - { - setItem(i, 1, new Create3SensorValueItem(Create3SensorModel::Bump, i, true)); - } - for (int i = 5; i < 9; i++) - { - setItem(i, 1, new Create3SensorValueItem(Create3SensorModel::Cliff, i, true)); - } - for (int i = 9; i < 16; i++) - { - setItem(i, 1, new Create3SensorValueItem(Create3SensorModel::IR, i, true)); - } - for (int i = 0; i < rowCount(); ++i) - { - Updateable *updateable = Updateable::cast(item(i, 1)); - if (!updateable) - { - continue; - } - - updateable->update(); - } -} - -void Create3SensorModel::populate() -{ - - for (unsigned int i = 0; i < 6; ++i) - populateBump(i); - for (unsigned int i = 0; i < 5; ++i) - populateCliff(i); - for (unsigned int i = 0; i < 8; ++i) - populateIR(i); -} - -void Create3SensorModel::populateBump(unsigned int port) -{ - switch (port) - { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump0, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump1, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump2, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump3, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 4: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump4, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - default: - break; - } -} - -void Create3SensorModel::populateCliff(unsigned int port) -{ - switch (port) - { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff0, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff1, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff2, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff3, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - - default: - break; - } -} - -void Create3SensorModel::populateIR(unsigned int port) -{ - switch (port) - { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR0, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR1, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR2, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR3, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 4: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR4, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 5: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR5, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 6: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR6, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - default: - break; - } -} diff --git a/src/Create3Widget.cpp b/src/Create3Widget.cpp deleted file mode 100644 index 459bd0ad..00000000 --- a/src/Create3Widget.cpp +++ /dev/null @@ -1,683 +0,0 @@ -#include "Create3Widget.h" -#include "ui_Create3Widget.h" -#include "Create3SensorListWidget.h" -#include "kj/exception.h" -#include "Create3SensorModel.h" -#include -#include -#include "NumpadDialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "RootController.h" -#include "kipr/create3/create3.capnp.h" -#include -#include -#include -#include -#include -#include -#include -int exampleIndex; -QStringList programList; -QMessageBox *msgBox; - -class Create3SensorItemDelegate : public QItemDelegate -{ -public: - Create3SensorItemDelegate(Create3SensorModel *const model, QObject *const parent = 0); - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - const Create3SensorModel *const _model; - const QPixmap _up; - const QPixmap _down; -}; - -QByteArray output; - -Create3Widget::Create3Widget(Device *device, QWidget *parent) - : StandardWidget(device, parent), - ui(new Ui::Create3Widget), _model(new Create3SensorModel(this)) -{ - ui->setupUi(this); - performStandardSetup(tr("Create 3"), false); - setStyleSheet("QScrollBar:vertical {border: 2px solid grey;background:grey ;width: 80px; margin: 22px 0 22px 0; } QScrollBar::handle:vertical { border: 2px solid grey;background: white; min-height: 20px; } QScrollBar::add-line:vertical { border: 2px solid grey;background: #32CC99; height: 20px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical {border: 2px solid grey; background: #32CC99; height: 20px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 2px solid grey;width: 3px; height: 3px; background: white; }QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {border: 2px solid grey; background: none;}"); - - ui->create3IP->setText(getIP()); - - QStringList arguments; - arguments << "/home/kipr/wombat-os/configFiles/create3_server_ip.txt"; - - QProcess *myProcess = new QProcess(parent); - myProcess->start("cat", arguments); - myProcess->waitForFinished(); - output = myProcess->readAllStandardOutput(); - - qDebug() << output; - - QString ipOutput = QString(output); - - if (ipOutput == "192.168.125.1") - { - ui->toggleSwitch->setChecked(false); // Wifi toggle side - } - else if (ipOutput == "192.168.186.3") - { - ui->toggleSwitch->setChecked(true); // Ethernet toggle side - } - - connect(ui->toggleSwitch, SIGNAL(stateChanged(int)), this, SLOT(toggleChanged())); - connect(ui->exampleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int))); - - connect(ui->exampleRunButton, SIGNAL(clicked()), SLOT(run())); - - // Create model - model = new QStringListModel(this); - ui->listWidget->clear(); - programList.clear(); - programList << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');"; - - ui->listWidget->addItems(programList); - model->setStringList(programList); - qDebug() << "Program List: " << programList; - ui->listWidget->setSpacing(6); -} - -Create3Widget::~Create3Widget() -{ - delete ui; -} - -void Create3Widget::toggleChanged() -{ - - StandardWidget::disableMenuBar(); - - ui->toggleSwitch->setEnabled(false); - ui->exampleComboBox->setEnabled(false); - ui->exampleRunButton->setEnabled(false); - - QProcess checkCreate3IPState; - QString startCommand = "cat"; - QStringList startArgs = {"/home/kipr/wombat-os/configFiles/create3_server_ip.txt"}; - - checkCreate3IPState.start(startCommand, startArgs); - checkCreate3IPState.waitForFinished(); - QByteArray output = checkCreate3IPState.readAllStandardOutput(); - - QString ipOutput = QString(output); - - qDebug() << "IP OUTPUT: " << ipOutput; // Get current IP output - - if (ipOutput.contains("192.168.125.1")) - { - - if (QMessageBox::question(this, "Change Interface?", - QString("You are about to change your Create 3 connection from Wifi to Ethernet. \nThe Wombat will reboot once you make this change. \n Do you want to continue? \n (Be sure to change the Fast DDS discovery server IP address to 192.168.186.3)"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - { - - StandardWidget::enableMenuBar(); - ui->toggleSwitch->setChecked(false); // Wifi toggle side - ui->toggleSwitch->setEnabled(true); - ui->exampleComboBox->setEnabled(true); - ui->exampleRunButton->setEnabled(true); - - return; - } - else - { - rebootBox(); - // Use a QTimer to delay the reboot process - QTimer::singleShot(2000, this, [this, msgBox]() - { - QProcess process; - process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh" - << "eth"); - - msgBox->close(); }); - - - } - } - else if (ipOutput.contains("192.168.186.3")) - { - if (QMessageBox::question(this, "Change Interface?", - QString("You are about to change your Create 3 connection from Ethernet to Wifi. \n The Wombat will reboot once you make this change. \nDo you want to continue? \n (Be sure to change the Fast DDS discovery server IP address to 192.168.125.1)"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - { - - StandardWidget::enableMenuBar(); - ui->toggleSwitch->setChecked(true); // Ethernet toggle side - ui->toggleSwitch->setEnabled(true); - ui->exampleComboBox->setEnabled(true); - ui->exampleRunButton->setEnabled(true); - - return; - } - else - { - rebootBox(); - // Use a QTimer to delay the reboot process - QTimer::singleShot(2000, this, [this, msgBox]() - { - QProcess process; - process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh" - << "wifi"); - - msgBox->close(); }); - - } - } -} - -void Create3Widget::rebootBox() -{ - - // Create the QMessageBox - msgBox = new QMessageBox(this); - msgBox->setWindowTitle("Reboot"); - msgBox->setMaximumSize(500, 480); // Limit the size of the QMessageBox - msgBox->setStandardButtons(QMessageBox::NoButton); - - // Create QLabel for the GIF - QLabel *gifLabel = new QLabel(); - gifLabel->setAlignment(Qt::AlignCenter); // Center the GIF label - - // Create QLabel for the message text - QLabel *messageLabel = new QLabel("Rebooting now..."); - messageLabel->setAlignment(Qt::AlignCenter); // Center the message label - - // Create a container widget and a new vertical layout - QWidget *container = new QWidget(); - QVBoxLayout *vLayout = new QVBoxLayout(container); - - // Add the GIF label and message label to the vertical layout - vLayout->addWidget(gifLabel); - vLayout->addWidget(messageLabel); - - // Adjust the vertical layout spacing and margins - vLayout->setSpacing(10); - vLayout->setContentsMargins(10, 10, 10, 10); - - // Set the layout of the container - container->setLayout(vLayout); - - // Access the internal layout of the QMessageBox - QGridLayout *msgBoxLayout = qobject_cast(msgBox->layout()); - if (msgBoxLayout) - { - msgBoxLayout->addWidget(container, 0, 0, 1, msgBoxLayout->columnCount()); - } - - // Setup and start the GIF movie - QMovie *movie = new QMovie("://qml/botguy_noMargin.gif"); - movie->setScaledSize(QSize(200, 240)); - gifLabel->setMovie(movie); - movie->start(); - - // Show the QMessageBox non-blocking - msgBox->setText(""); // Hide the default text to avoid duplication - msgBox->show(); - - // Debug information - qDebug() << "Message box displayed, starting reboot sequence..."; -} - -QString Create3Widget::getIP() -{ - - // The command to execute - const char *command = "arp -a | grep 'iRobot' | awk -F '[()]' '{print $2}'"; - - // Open a pipe to the command - FILE *pipe = popen(command, "r"); - if (!pipe) - { - std::cerr << "Error opening pipe." << std::endl; - } - - // Read the output from the command - char buffer[128]; - std::string result = ""; - while (fgets(buffer, sizeof(buffer), pipe) != nullptr) - { - result += buffer; - } - - // Close the pipe - pclose(pipe); - - // Trim the newline character from the end of the result - result.erase(result.find_last_not_of("\n") + 1); - - // Print or use the result as needed - std::cout << "Output:\n" - << result << std::endl; - - QString output = QString::fromStdString(result); - - return output; -} - -// void Create3Widget::sensorList() -// { -// RootController::ref().presentWidget(new Create3SensorListWidget(device())); -// } - -// void Create3Widget::exampleList() -// { -// RootController::ref().presentWidget(new Create3ExampleWidget(device())); -// } - -void Create3Widget::indexChanged(int index) -{ - - programList.clear(); - ui->listWidget->clear(); - ui->listWidget->addItems(programList); - model->setStringList(programList); - switch (index) - { - case 0: // 01_Connect - { - - programList << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');"; - qDebug() << "Program List: " << programList; - ui->listWidget->addItems(programList); - model->setStringList(programList); - break; - } - - case 1: // 02_Dock_Undock - { - programList.clear(); - programList << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Undocking...');" - << "create3_undock();" - << "create3_wait();" - << "printf('Done!');"; - qDebug() << "Program List: " << programList; - - ui->listWidget->addItems(programList); - model->setStringList(programList); - break; - } - case 2: // 03_Move_Velocity - { - - programList - << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Moving forward at 0.5 m/s for 1 second...');" - << "//Move forward at 0.5 m/s for 1 second" - << "create3_velocity_set_components(0.5, 0);" - << "//Wait for 1 second" - << "usleep(1000000);" - << "//Stop" - << "create3_velocity_set_components(0.0, 0.0);" - << "printf('Done!');"; - qDebug() << "Program List: " << programList; - ui->listWidget->addItems(programList); - model->setStringList(programList); - ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(6)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(8)->setForeground(QColor(0, 128, 0)); - - break; - } - case 3: // 04_Rotate - programList - << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Rotate at 0.5 m/s for 1 second...');" - << "//Rotate at 90 deg/s (PI/2 rad/s) to 90 degrees (PI/2 radians)" - << "create3_rotate_degrees(90, 90);" - << "create3_rotate_radians(1.57, 1.57);" - << "//Wait for 1 second" - << "create3_wait();" - << "printf('Done!');"; - ui->listWidget->addItems(programList); - model->setStringList(programList); - ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(7)->setForeground(QColor(0, 128, 0)); - - break; - case 4: // 05_Arc - programList - << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Rotate at 0.5 m/s for 1 second...');" - << "//Arc of 90 deg (PI/2 rad) with radius of 0.5 m" - << "create3_drive_arc_degrees(0.5, 90, 0.306);" - << "create3_drive_arc_radians(0.5, -1.57, 0.460);" - << "//Wait for 1 second" - << "create3_wait();" - << "printf('Done!');"; - ui->listWidget->addItems(programList); - model->setStringList(programList); - ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(7)->setForeground(QColor(0, 128, 0)); - break; - case 5: // 06_led_test - programList - << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Blinking lights...');" - << "//Blink the lights green for 5 seconds." - << "Create3LedColor green;" - << "green.r = 0;" - << "green.g = 255;" - << "green.b = 0;" - << "Create3Lightring lightring;" - << "lightring.led0 = green;" - << "lightring.led1 = green;" - << "lightring.led2 = green;" - << "lightring.led3 = green;" - << "lightring.led4 = green;" - << "lightring.led5 = green;" - << "// Blink the lights green for 5 seconds." - << "create3_led_animation(Create3BlinkLights, lightring, 5.0);" - << "//Wait for 1 second" - << "create3_wait();" - << "printf('Done!');"; - ui->listWidget->addItems(programList); - model->setStringList(programList); - ui->listWidget->item(4)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(16)->setForeground(QColor(0, 128, 0)); - ui->listWidget->item(18)->setForeground(QColor(0, 128, 0)); - break; - case 6: // 07_sensors - programList - << "printf('Connecting to Create3 robot...');" - << "create3_connect_manual('192.168.125.1', 50051);" - << "printf('Connected!');" - << "printf('Sensor Values:');" - << "printf(' Left Side Cliff: %d', create3_sensor_cliff(0));" - << "printf(' Left Front Cliff: %d', create3_sensor_cliff(1));" - << "printf(' Right Front Cliff: %d', create3_sensor_cliff(2));" - << "printf(' Right Side Cliff: %d', create3_sensor_cliff(3));" - << "printf(' Left Side IR: %d', create3_sensor_ir(0));" - << "printf(' Left IR: %d', create3_sensor_ir(1));" - << "printf(' Left Front IR: %d', create3_sensor_ir(2));" - << "printf(' Left Center IR: %d', create3_sensor_ir(3));" - << "printf(' Right Center IR: %d', create3_sensor_ir(4));" - << "printf(' Right Front IR: %d', create3_sensor_ir(5));" - << "printf(' Right IR: %d', create3_sensor_ir(6));" - << "printf(' Left Bumper: %d', create3_sensor_bump(0));" - << "printf(' Left Front Bumper: %d', create3_sensor_bump(1));" - << "printf(' Center Front Bumper: %d', create3_sensor_bump(2));" - << "printf(' Right Front Bumper: %d', create3_sensor_bump(3));" - << "printf(' Right Bumper: %d', create3_sensor_bump(4));" - << "while (create3_sensor_bump(3) == 0)" - << "{" - << " if (create3_sensor_bump(3) == 1)" - << " {" - << " create3_velocity_set_components(0.0, 0.0);" - << " break;" - << " }" - << " create3_velocity_set_components(0.15, 0.0);" - << "}" - << "printf('Done!');"; - ui->listWidget->addItems(programList); - model->setStringList(programList); - - break; - default: - break; - } -} - -void Create3Widget::run() -{ - - exampleIndex = ui->exampleComboBox->currentIndex(); - switch (exampleIndex) - { - - case 0: - { // 01_Connect - try - { - printf("Connecting to Create3 robot...\n"); - create3_connect_manual("192.168.125.1", 50051); - printf("Connected!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - break; - } - - case 1: // 02_Dock_Undock - { - - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Undocking...\n"); - // Move forward at 0.5 m/s for 1 second - create3_undock(); - - create3_wait(); - - printf("Docking...\n"); - - create3_dock(); - - create3_wait(); - - printf("Done!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - - break; - } - - case 2: // 03_Move_Velocity - { - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Moving forward at 0.5 m/s for 1 second...\n"); - - // Move forward at 0.5 m/s for 1 second - create3_velocity_set_components(0.5, 0); - - // Wait for 1 second - usleep(1000000); - - // Stop - create3_velocity_set_components(0.0, 0.0); - - printf("Done!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - break; - } - - case 3: // 04_Rotate - { - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Rotate at 0.5 m/s for 1 second...\n"); - - // Rotate at 90 deg/s (PI/2 rad/s) to 90 degrees (PI/2 radians) - create3_rotate_degrees(90, 90); - create3_rotate_radians(1.57, 1.57); - - // Wait for 1 second - create3_wait(); - - printf("Done!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - - break; - } - - case 4: // 05_Arc - { - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Rotate at 0.5 m/s for 1 second...\n"); - - // Arc of 90 deg (PI/2 rad) with radius of 0.5 m - create3_drive_arc_degrees(0.5, 90, 0.306); - create3_drive_arc_radians(0.5, -1.57, 0.460); - - // Wait for 1 second - create3_wait(); - - printf("Done!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - - break; - } - - case 5: // 06_led_test - { - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Blinking lights...\n"); - // Blink the lights green for 5 seconds. - - Create3LedColor green; - green.r = 0; - green.g = 255; - green.b = 0; - - Create3Lightring lightring; - lightring.led0 = green; - lightring.led1 = green; - lightring.led2 = green; - lightring.led3 = green; - lightring.led4 = green; - lightring.led5 = green; - - create3_led_animation(Create3BlinkLights, lightring, 5.0); // Blink the lights green for 5 seconds. - - // Wait for 1 second - create3_wait(); - - printf("Done!\n"); - } - // catch (const std::exception &e) - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - - break; - } - case 6: // 07_sensors - { - try - { - printf("Connecting to Create3 robot...\n"); - - create3_connect_manual("192.168.125.1", 50051); - - printf("Connected!\n"); - - printf("Sensor Values:\n"); - printf(" Left Side Cliff: %d\n", create3_sensor_cliff(0)); - printf(" Left Front Cliff: %d\n", create3_sensor_cliff(1)); - printf(" Right Front Cliff: %d\n", create3_sensor_cliff(2)); - printf(" Right Side Cliff: %d\n", create3_sensor_cliff(3)); - printf("\n"); - printf(" Left Side IR: %d\n", create3_sensor_ir(0)); - printf(" Left IR: %d\n", create3_sensor_ir(1)); - printf(" Left Front IR: %d\n", create3_sensor_ir(2)); - printf(" Left Center IR: %d\n", create3_sensor_ir(3)); - printf(" Right Center IR: %d\n", create3_sensor_ir(4)); - printf(" Right Front IR: %d\n", create3_sensor_ir(5)); - printf(" Right IR: %d\n", create3_sensor_ir(6)); - - printf(" Left Bumper: %d\n", create3_sensor_bump(0)); - printf(" Left Front Bumper: %d\n", create3_sensor_bump(1)); - printf(" Center Front Bumper: %d\n", create3_sensor_bump(2)); - printf(" Right Front Bumper: %d\n", create3_sensor_bump(3)); - printf(" Right Bumper: %d\n", create3_sensor_bump(4)); - - while (create3_sensor_bump(3) == 0) - { - if (create3_sensor_bump(3) == 1) - { - create3_velocity_set_components(0.0, 0.0); - break; - } - create3_velocity_set_components(0.15, 0.0); - } - - printf("Done!\n"); - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } - } - - default: - break; - } -} diff --git a/src/HomeWidget.cpp b/src/HomeWidget.cpp index aa2eb545..53e3df03 100644 --- a/src/HomeWidget.cpp +++ b/src/HomeWidget.cpp @@ -188,25 +188,10 @@ void HomeWidget::reboot() // Use a QTimer to delay the reboot process QTimer::singleShot(2000, this, [this, msgBox]() { - qDebug() << "Stopping create3_server.service..."; - // Stop create3_server.service - QProcess create3ServerStop; - create3ServerStop.start("sudo", QStringList() << "systemctl" << "stop" << "create3_server.service"); - bool create3StopRet = create3ServerStop.waitForFinished(); - qDebug() << "Create 3 server stop return value: " << create3StopRet; - qDebug() << "Create 3 server exit code: " << create3ServerStop.exitCode(); - if(create3StopRet == false){ - qDebug() << "create3StopRet: " << create3StopRet; - QMessageBox::information(this, "Failed", "Create 3 server could not be stopped."); - - } - - qDebug() << "Rebooting the system..."; // Reboot the system const int rebootRet = QProcess::execute("reboot"); - if(create3StopRet == false || rebootRet < 0) - QMessageBox::information(this, "Failed", "Reboot failed."); + msgBox->close(); }); diff --git a/src/MotorsSensorsWidget.cpp b/src/MotorsSensorsWidget.cpp index 539086b4..e14dde89 100644 --- a/src/MotorsSensorsWidget.cpp +++ b/src/MotorsSensorsWidget.cpp @@ -5,7 +5,6 @@ #include "CameraLiveWidget.h" #include "ServosWidget.h" #include "CombinedMotorWidget.h" -#include "Create3Widget.h" #include "DepthSensorWidget.h" #include "SensorsWidget.h" #include "SensorListWidget.h" @@ -23,8 +22,6 @@ MotorsSensorsWidget::MotorsSensorsWidget(Device *device, QWidget *parent) connect(ui->sensorGraph, SIGNAL(clicked()), SLOT(sensorGraph())); connect(ui->sensorList, SIGNAL(clicked()), SLOT(sensorList())); connect(ui->camera, SIGNAL(clicked()), SLOT(camera())); - connect(ui->Create3, SIGNAL(clicked()), SLOT(Create3())); - } @@ -58,9 +55,4 @@ void MotorsSensorsWidget::camera() RootController::ref().presentWidget(new CameraLiveWidget(device())); } -void MotorsSensorsWidget::Create3() -{ - RootController::ref().presentWidget(new Create3Widget(device())); -} - diff --git a/ui/Create3ExampleWidget.ui b/ui/Create3ExampleWidget.ui deleted file mode 100644 index 1f3da24b..00000000 --- a/ui/Create3ExampleWidget.ui +++ /dev/null @@ -1,115 +0,0 @@ - - - Create3ExampleWidget - - - - 0 - 0 - 800 - 480 - - - - Sensor List - - - - - - - 22 - - - - Create 3 Examples - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 16777215 - 16777215 - - - - - 01_Connect - - - - - 02_Dock_Undock - - - - - 03_Move_Velocity - - - - - 04_Rotate - - - - - 05_Arc - - - - - 06_LED - - - - - 07_Sensors - - - - - - - - Run - - - - - - - - - - - - - 0 - - - - - - - - - 0 - - - - - - - - - - - - diff --git a/ui/Create3SensorList.ui b/ui/Create3SensorList.ui deleted file mode 100644 index d25b083f..00000000 --- a/ui/Create3SensorList.ui +++ /dev/null @@ -1,267 +0,0 @@ - - - SensorListWidget - - - - 0 - 0 - 800 - 480 - - - - Sensor List - - - - - 10 - 10 - 781 - 486 - - - - - - - - 22 - - - - Create 3 Info - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - 0 - 80 - - - - - 33 - - - - Create Connect - - - - - - - - - - 22 - - - - Create Connected State: - - - - - - - - 22 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 22 - - - - Battery %: - - - - - - - - 25 - 0 - - - - - 22 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 22 - - - - Select Test Program: - - - - - - - - 01_Connect - - - - - 02_Dock_Undock - - - - - 03_Move_Velocity - - - - - 04_Rotate - - - - - 05_Arc - - - - - 06_LED_Test - - - - - - - - - - - 22 - - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - false - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - Qt::NoPen - - - false - - - false - - - false - - - 1 - - - 300 - - - false - - - true - - - false - - - 36 - - - false - - - - - - - - - - - 22 - - - - - - - - - - PlotWidget - QWidget -
PlotWidget.h
- 1 -
-
- - -
diff --git a/ui/Create3SensorListWidget.ui b/ui/Create3SensorListWidget.ui deleted file mode 100644 index 356bf0c8..00000000 --- a/ui/Create3SensorListWidget.ui +++ /dev/null @@ -1,104 +0,0 @@ - - - Create3SensorListWidget - - - - 0 - 0 - 800 - 480 - - - - Sensor List - - - - - - - 22 - - - - Create 3 Sensor List - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - 22 - - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - false - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - Qt::NoPen - - - false - - - false - - - false - - - 1 - - - 300 - - - false - - - true - - - false - - - 36 - - - false - - - - - - - - - - - diff --git a/ui/Create3Widget.ui b/ui/Create3Widget.ui deleted file mode 100644 index 328f3f66..00000000 --- a/ui/Create3Widget.ui +++ /dev/null @@ -1,299 +0,0 @@ - - - Create3Widget - - - - 0 - 0 - 800 - 480 - - - - Create 3 - - - - - - - 22 - - - - - - - 7 - - - 0 - - - 0 - - - - - 10 - - - - - - 180 - 37 - - - - - 225 - 16777215 - - - - - Ubuntu - 25 - false - true - false - false - true - - - - font: 700 25pt "Ubuntu"; - - - Create3 IP: - - - - - - - - 25 - 0 - - - - - 22 - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 10 - - - - - - 25 - 0 - - - - - 60 - 16777215 - - - - - 22 - - - - Wifi - - - Qt::AlignCenter - - - - - - - - 100 - 16777215 - - - - QCheckBox::indicator{ - margin-left:13%; - margin-right:10% -} - -QCheckBox::indicator:checked{ - image:url("://qml/right.png"); -} - -QCheckBox::indicator:unchecked{ - image:url("://qml/left.png"); -} - - - - - - false - - - - - - - - 35 - 0 - - - - - 134 - 16777215 - - - - - 22 - - - - Ethernet - - - Qt::AlignCenter - - - - - - - - - - - - 22 - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 16777215 - 16777215 - - - - - 01_Connect - - - - - 02_Dock_Undock - - - - - 03_Move_Velocity - - - - - 04_Rotate - - - - - 05_Arc - - - - - 06_LED - - - - - 07_Sensors - - - - - - - - Run - - - - - - - - - - - - - 0 - - - - - - - - - 0 - - - - - - - - - - - - - - - PlotWidget - QWidget -
PlotWidget.h
- 1 -
-
- - -
diff --git a/ui/MotorsSensorsWidget.ui b/ui/MotorsSensorsWidget.ui index d6a3ea32..06b9b755 100644 --- a/ui/MotorsSensorsWidget.ui +++ b/ui/MotorsSensorsWidget.ui @@ -108,34 +108,6 @@ - - - - - 0 - 80 - - - - - 33 - - - - Create 3 - - - - :/icons/robot.png:/icons/robot.png - - - - 30 - 30 - - - -