Why does only one motor work in this code?

When I was working with my team, only motor 3 was working of the ones declared below:
okapi::MotorGroup intake = MotorGroup({5,7});
okapi::MotorGroup rollers = MotorGroup({3,4});

Does anyone know why? I am seriously confused as to why this is happening, for not even motor 4 is moving, only 3.

EDIT: Adding opcontrol

EDIT 2: got rid of unnecessary comments

    void opcontrol()
{
	okapi::Controller controller;
	//Button inputs
okapi::ControllerButton intakeButton(okapi::ControllerDigital::R2, false);
okapi::ControllerButton outtakeButton(okapi::ControllerDigital::R1, false);

std::shared_ptr<okapi::OdomChassisController> drive = okapi::ChassisControllerBuilder().withMotors({1,-12},{11,-2}).withDimensions(okapi::AbstractMotor::gearset::green, scales).withOdometry(scales).buildOdometry();
std::shared_ptr<okapi::ChassisModel> model = std::dynamic_pointer_cast<okapi::ChassisModel>(drive->getModel());

	while(1){

		    		drive->getModel()->arcade(controller.getAnalog(ControllerAnalog::leftY),
	                                  controller.getAnalog(ControllerAnalog::leftX));

		if(intakeButton.isPressed()){
			 intake.moveVelocity(160); //Test motor velocities
			 rollers.moveVelocity(120);
			
		}
		else if(outtakeButton.isPressed()){
			 intake.moveVelocity(-90); //More testing here, too
			 rollers.moveVelocity(-50); //test
		}
		else {
			 intake.moveVelocity(0);
			 rollers.moveVelocity(0);

		}
		pros::delay(10); 
	}
}

As far as I can tell, these constructors look fine. Can you post the rest of your code? In addition, check your wires and/or the motors themselves.

Given that the motor in port 3 works fine, I think it’s safe to say that the code you’ve given us so far likely is correct, given that both constructors have the exact same syntax. What this leads me to believe is that either there is a problem somewhere else in the code or the problem is in the hardware.

2 Likes

@thermonuke

I added my opcontrol into the edit so that you can take a look and see what is happening with the code. I know rpm is somewhat low, but I decided to start low and build up from there. Thank you for your response!

It seems like the code is completely fine, especially given that the motor in port 3 works correctly. I would think that there is an issue with the wires or motors themselves, so check all your connections.

2 Likes

Thank you! I’ll try the connections again soon and let you know how it goes!

I would also suggest you check out your port. v5 ports are notorious for frying under high static conditions.

4 Likes