Skip to content

Commit

Permalink
Merge branch '15in' of github.com:msoe-vex/rr-ros1-robot-code-templat…
Browse files Browse the repository at this point in the history
…e into 15in
  • Loading branch information
alienboy13 committed Feb 12, 2022
2 parents 0bf5ee6 + b5f5013 commit ffa5f4b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/v5_hal/firmware/src/nodes/LiftNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,27 @@ int LiftNode::getPosition() {
}

void LiftNode::teleopPeriodic() {
if (m_top_limit_switch->getValue() || m_bottom_limit_switch->getValue()) {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
} else {
if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R1)) {
m_left_motor->moveVoltage(MAX_MOTOR_VOLTAGE);
if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R1) &&
!m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R2)) {
if(m_top_limit_switch->getValue()) {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
} else {
m_left_motor->moveVoltage(MAX_MOTOR_VOLTAGE);
m_right_motor->moveVoltage(-1 * MAX_MOTOR_VOLTAGE);
} else if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R2)) {
m_left_motor->moveVoltage(-1 * MAX_MOTOR_VOLTAGE);
}
} else if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R1) &&
!m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R2)) {
if (m_bottom_limit_switch) {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
} else {
m_left_motor->moveVoltage(-1*MAX_MOTOR_VOLTAGE);
m_right_motor->moveVoltage(MAX_MOTOR_VOLTAGE);
} else {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
}
}
} else {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
}
};

Expand Down
11 changes: 11 additions & 0 deletions src/v5_hal/firmware/src/nodes/TankDriveNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ void TankDriveNode::resetEncoders() {
m_motors.right_4_motor->resetEncoder();
}

TankDriveNode::FourMotorDriveEncoderVals TankDriveNode::getIntegratedEncoderVals() {
FourMotorDriveEncoderVals encoder_vals = {
m_motors.left_1_motor->getPosition(),
m_motors.left_2_motor->getPosition(),
m_motors.left_3_motor->getPosition(),
m_motors.left_4_motor->getPosition()
};

return encoder_vals;
}

void TankDriveNode::initialize() {
resetEncoders();
}
Expand Down

0 comments on commit ffa5f4b

Please sign in to comment.