-
Notifications
You must be signed in to change notification settings - Fork 0
Okapi
davidmoshal edited this page Mar 18, 2023
·
2 revisions
Notes: Mar 17, 2023
- to use Okapi namespace:
using namespace okapi;- to use Okapi motor drives (tank vs arcade):
#include "main.h"
#include "okapi/api.hpp"
using namespace okapi;
// Define the ports for the left and right motors
#define LEFT_MOTOR_PORT 2
#define RIGHT_MOTOR_PORT 1
void opcontrol() {
std::shared_ptr<ChassisController> drive =
ChassisControllerBuilder()
.withMotors(LEFT_MOTOR_PORT, -RIGHT_MOTOR_PORT)
// 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;
while (true) {
// Tank drive with left and right sticks.
drive->getModel()->arcade(controller.getAnalog(ControllerAnalog::leftY),
controller.getAnalog(ControllerAnalog::rightY));
// 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);
}
// Wait for some time before repeating loop
pros::delay(20);
}