I have just begun using Okapi and I copied the beginner code from the documentation and it does not work. Nothing moves or responds and I have not got any error in the console. Let me know if you find any issues with the code below thank you!
#include “okapi/api.hpp”
using namespace okapi;
void opcontrol() {
// Chassis Controller - lets us drive the robot around with open- or closed-loop control
std::shared_ptr drive =
ChassisControllerBuilder()
.withMotors(1, -10, 5 ,6)
// Green gearset, 4 in wheel diam, 11.5 in wheel track
.withDimensions(AbstractMotor::gearset::green, {{4_in, 11.5_in}, imev5GreenTPR})
.build();
// Joystick to read analog values for tank or arcade control
// Master controller by default
Controller controller;
;
ControllerButton armUpButton(ControllerDigital::A);
ControllerButton armDownButton(ControllerDigital::B);
Motor armMotor(-8);
while (true) {
// Tank drive with left and right sticks
drive->getModel()->tank(controller.getAnalog(ControllerAnalog::leftY),
controller.getAnalog(ControllerAnalog::rightY));
// else, the arm isn't all the way down
if (armUpButton.isPressed()) {
armMotor.moveVoltage(12000);
} else if (armDownButton.isPressed()) {
armMotor.moveVoltage(-12000);
} else {
armMotor.moveVoltage(0);
}
// Wait and give up the time we don't need to other tasks.
// Additionally, joystick values, motor telemetry, etc. all updates every 10 ms.
pros::delay(10);
}
}