PROS V5 OKAPI Issue

Hey PROS Users,

Just started trying to use PROS and I’m having an odd issue.

So for my auton test, this code works fine.

 auto drive = ChassisControllerFactory::create(
   {20, 13}, {-19, -12},
   AbstractMotor::gearset::green,
   {4_in, 15_in}
 );

void autonomous() {
  drive.moveDistance(3_ft);
  drive.turnAngle(360_deg);
}

So I know that okapi namespace is working. However, when I try and run opcontrol… I don’t get anything. I’ve confirmed that this method is at least called by include drive.moveDistance() call within opcontrol… and it does get called. So I feel as though its a problem with the controller. Aditionally, I can initialize the Controller from the pros namespace and can get it to work with the okapi tank method. Firmware is the latest for everything and tried 2 different remotes. I’m sure it’s something I’m doing wrong. Any ideas?

void opcontrol() {
  // Joystick to read analog values for tank or arcade control
  // Master controller by default
  Controller controller;

  auto chassis = ChassisControllerFactory::create(
    {20, 13}, {-19, -12},
    AbstractMotor::gearset::green,
    {4_in,14_in}
  );

  // Arm related objects
  ControllerButton capFlipperUpButton(ControllerDigital::A);
  ControllerButton capFlipperDownButton(ControllerDigital::B);
	ControllerButton intakeInButton(ControllerDigital::R1);
	ControllerButton intakeOutButton(ControllerDigital::R2);

	Motor intakeMotor = 18_rmtr;
  Motor capFlipperMotor = 8_mtr;

  while (true) {
    // Tank drive with left and right sticks and deadband of 0
    chassis.tank(controller.getAnalog(ControllerAnalog::leftY),controller.getAnalog(ControllerAnalog::rightY));
		if (capFlipperUpButton.isPressed()) {
			intakeMotor.move_voltage(-127);
		} else if (capFlipperDownButton.isPressed()) {
			intakeMotor.move_voltage(127);
		} else {
			intakeMotor.move_voltage(0);
		}

		if (intakeInButton.isPressed()) {
			intakeMotor.move_voltage(-127);
		} else if (intakeOutButton.isPressed()) {
			intakeMotor.move_voltage(127);
		} else {
			intakeMotor.move_voltage(0);
		}

    pros::Task::delay(10);
  }
}

You’re not going to enjoy hearing that I just tried out your code and it’s working fine for me.

What versions of PROS Kernel and okapilib are you using?

Hmmm… it compiled and downloaded and ran for me… just didn’t do anything in opcontrol() related to Controller.

Kernel is 3.1.5. Okapilib is 3.3.11. Both were installed yesterday.

move_voltage() takes a range of [-12000, 12000], so passing -127 or 127 will likely seem like passing 0. See the docs here: https://pros.cs.purdue.edu/v5/api/cpp/motors.html#move-voltage

2 Likes

So I got it working now… I created a totally new project… copied my auton, opcontrol, and init and it all worked. No idea what the issue was. Are there certain files that should be excluded with GitHub? Perhaps something with compiled files?? No idea?

I realized this too! Thanks!

Perhaps you hadn’t done a clean build after changing something in your header files?

2 Likes

Does anyone know how to put this in a .h file?
auto chassis = ChassisControllerFactory::create( {10, 9}, {-1, -2}, AbstractMotor::gearset::green, {4_in,14_in} );