void Arm::setAngle(float angle) { if (!isAdjusting) { isAdjusting = true; } float newAngle = Arm::voltageToDegree(angle); float accel_x = accel->GetAcceleration(ADXL345_I2C::kAxis_X); float accel_y = accel->GetAcceleration(ADXL345_I2C::kAxis_Y); float accel_z = accel->GetAcceleration(ADXL345_I2C::kAxis_Z); pitch = (atan2(accel_x, sqrt(accel_y * accel_y + accel_z * accel_z))) / PI; printf("%f\n", pitch); if (fabs(curAngle - newAngle) > VOLT_THRESH) { if (curAngle > newAngle) { tiltDown(); } else { tiltUp(); } } else { isAdjusting = false; tiltZero(); return; } }
void Arm::update() { SmoothJoystick* joy = robot->gunnerJoy; if (joy->GetTriggerState() == TRIG_R) { tiltUp(); } else if (joy->GetTriggerState() == TRIG_L) { tiltDown(); } else { tiltZero(); } if (joy->GetRawButton(BUTTON_GRAB)) { grab(); } else { grabWheel -> Set(0.0f); } }
EditorMainWindow::EditorMainWindow(QWidget *parent) : QMainWindow(parent) { camera_ = 0; ui.setupUi(this); QApplication::connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(openRequested())); QApplication::connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(saveRequested())); QApplication::connect(ui.actionDerive_map, SIGNAL(triggered()), this, SLOT(deriveMap())); QApplication::connect(ui.action_Quit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); QApplication::connect(ui.actionZoom_In, SIGNAL(triggered()), this, SLOT(zoominRequested())); QApplication::connect(ui.actionZoom_Out, SIGNAL(triggered()), this, SLOT(zoomoutRequested())); QApplication::connect(ui.horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScroll(int))); QApplication::connect(ui.verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScroll(int))); QApplication::connect(ui.actionRotate_Left, SIGNAL(triggered()), this, SLOT(rotateLeft())); QApplication::connect(ui.actionRotate_Right, SIGNAL(triggered()), this, SLOT(rotateRight())); QApplication::connect(ui.actionTilt_Up, SIGNAL(triggered()), this, SLOT(tiltUp())); QApplication::connect(ui.actionTilt_Down, SIGNAL(triggered()), this, SLOT(tiltDown())); QApplication::connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(undo())); QApplication::connect(ui.actionRedo, SIGNAL(triggered()), this, SLOT(redo())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S),this), SIGNAL(activated()), this, SLOT(saveRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O),this), SIGNAL(activated()), this, SLOT(openRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Z),this), SIGNAL(activated()), this, SLOT(zoominRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_X),this), SIGNAL(activated()), this, SLOT(zoomoutRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(rotateLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(rotateRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(tiltUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(tiltDown())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(panLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(panRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(panUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(panDown())); ui.action_Save->setEnabled(false); ui.editorGLWidget->setEnabled(false); QToolButton* party_button = new QToolButton(); party_button->setText("Parties"); party_button->setCheckable(true); party_button->setChecked(false); handlers_.push_back(new TerrainHandler(*this, "party", false, tool_buttons_.size())); QApplication::connect(party_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_P),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(party_button); tool_buttons_.push_back(party_button); QToolButton* height_button = new QToolButton(); height_button->setText("Height"); height_button->setCheckable(true); height_button->setChecked(true); handlers_.push_back(new TerrainHandler(*this, "", false, tool_buttons_.size())); QApplication::connect(height_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_H),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(height_button); tool_buttons_.push_back(height_button); QToolButton* picker_button = new QToolButton(); picker_button->setText("Picker"); picker_button->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, "", true, tool_buttons_.size())); QApplication::connect(picker_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(picker_button); tool_buttons_.push_back(picker_button); std::vector<std::string> terrain_ids; hex::base_terrain::get_terrain_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::base_terrain::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], false, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } terrain_ids.clear(); hex::terrain_feature::get_feature_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::terrain_feature::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], true, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } }