Pros gyro okapilib auton

I currently use the okapilib chassis controller for my autons. I call commands like chassis.moveDistance(18_cm); or chassis.turnAngle(80_deg);

my controller setup looks like:

#include "okapi/api.hpp"

using namespace okapi;

const int DRIVE_MOTOR_LEFT = 1;
const int DRIVE_MOTOR_RIGHT = -2;
const auto WHEEL_DIAMETER = 4_in;
const auto CHASSIS_WIDTH = 14.375_in;

auto chassis = ChassisControllerFactory::create(
  DRIVE_MOTOR_LEFT, DRIVE_MOTOR_RIGHT,
  AbstractMotor::gearset::red,
  {WHEEL_DIAMETER, CHASSIS_WIDTH}
);

I was wondering if I could use my gyro to keep the robot straight and more importantly get accurate turning. If I could integrate it into my okapilib chassis controller, that would be great. Btw: I don’t really get the okaplib chassis controller api for including gyro in the PID. That is why I asked here.

Thanks.

OkapiLib does not support using the gyro with the chassis controller.

1 Like

I found this, but I may be misunderstanding it.

image

Yes, that is for an AsyncController, which is different from a ChassisController (it controls individual motors or motor groups, not chassis).

2 Likes

Ok, is there a good manual way to make accurate turns using a gyro

I am using the below code on a new file:

#include “main.h”
///*
#include “okapi/api.hpp”

using namespace okapi;

const int DRIVE_MOTOR_LEFT = 1;
const int DRIVE_MOTOR_RIGHT = -2;
const auto WHEEL_DIAMETER = 4_in;
const auto CHASSIS_WIDTH = 15.16_in;

auto chassis = ChassisControllerFactory::create(
DRIVE_MOTOR_LEFT, DRIVE_MOTOR_RIGHT,
AbstractMotor::gearset::green,
{WHEEL_DIAMETER, CHASSIS_WIDTH}
);
//*/

I am getting the error below! Has Okapilib been updated or something? I only works on the old file!

image

Is this code in a new project? There has been an update, but it’s up to you to update your projects. New projects are automatically updated when they are created.

1 Like

cool, thanks I have updated my code to the new okapilib syntax!

1 Like