New Programmer Need Help with PROS

In this program, the base is able to run but the intake is not. Does anyone now why and is willing to help/

#include “main.h”
//MOTORS
pros::Motor LB(6, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor LF(2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor RB(4, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor RF(3, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor topRoller(12, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor bottomRoller(5, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightIntake(17, pros::E_MOTOR_GEARSET_06, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor leftIntake(18, pros::E_MOTOR_GEARSET_06, false, pros::E_MOTOR_ENCODER_COUNTS);
//CONTROLLER
pros::Controller controller(pros::E_CONTROLLER_MASTER);
void setDrive(int left, int right){
LB = left;
RB = right;
LF = left;
RF = right;
}
void setIntakes(int left, int right){
leftIntake = left;
rightIntake = right;

}
void setDriveMotors(){
int leftJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int rightJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
int joystick = (leftJoystick + rightJoystick)/2;
if(abs(leftJoystick) < 10){
leftJoystick = 0;
}
if(abs(rightJoystick) < 10){
rightJoystick = 0;
}
if(abs(leftJoystick - rightJoystick) < 5){
leftJoystick = joystick;
rightJoystick = joystick;
}
setDrive(leftJoystick,rightJoystick);
}

void initialize() {
pros::lcd::initialize();
pros::lcd::set_text(1, “78009A was here”);
LB.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
RB.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
LF.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
RF.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);

}

void disabled() {}

void competition_initialize() {}

void autonomous() {}

void opcontrol() {
while(true){
setDriveMotors();

if(controller.get_digital(DIGITAL_X)){
setIntakes(50,50);
}

	pros::delay(20);
}

}

Im pretty sure you need

if(controller.get_digital(E_CONTROLLER_DIGITAL_X)){
    setIntakes(50, 50);
}

Whoa there!

Firstly:

It is considered to be bad etiquette to post more than one thread with the same or very similar question.

Secondly:
It drastically helps with readability when you put code inside of code tags [code] ... [/code]

Here is your code formatted

#include “main.h”
//MOTORS
pros::Motor LB(6, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor LF(2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor RB(4, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor RF(3, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor topRoller(12, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor bottomRoller(5, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightIntake(17, pros::E_MOTOR_GEARSET_06, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor leftIntake(18, pros::E_MOTOR_GEARSET_06, false, pros::E_MOTOR_ENCODER_COUNTS);
//CONTROLLER
pros::Controller controller(pros::E_CONTROLLER_MASTER);
void setDrive(int left, int right){
LB = left;
RB = right;
LF = left;
RF = right;
}
void setIntakes(int left, int right){
leftIntake = left;
rightIntake = right;

}
void setDriveMotors(){
int leftJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int rightJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
int joystick = (leftJoystick + rightJoystick)/2;
if(abs(leftJoystick) < 10){
leftJoystick = 0;
}
if(abs(rightJoystick) < 10){
rightJoystick = 0;
}
if(abs(leftJoystick - rightJoystick) < 5){
leftJoystick = joystick;
rightJoystick = joystick;
}
setDrive(leftJoystick,rightJoystick);
}

void initialize() {
pros::lcd::initialize();
pros::lcd::set_text(1, “78009A was here”);
LB.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
RB.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
LF.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
RF.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);

}

void disabled() {}

void competition_initialize() {}

void autonomous() {}

void opcontrol() {
while(true){
setDriveMotors();

if(controller.get_digital(DIGITAL_X)){
setIntakes(50,50);
}


	pros::delay(20);
}


}

Much better.

Thirdly:

To get to your question, what is wrong with your code?

Well, let’s use some thinking. If you are not getting an error message from your code, that probably means that your syntax is fine, or close to fine. So we can probably determine that it probably isn’t a syntax problem.

Since you stated that the drivetrain is able to run, but not the intake, we can probably assume that the problem won’t be in the motor configuration since you configure both motors the same way.

Looking at your functions, since the setDrive function works, and it is more or less exactly the same to your setIntakes function, the problem probably isn’t in your void setIntakes.

Well then, looking at opcontrol, there are only three lines of code dealing with the intakes.

if(controller.get_digital(DIGITAL_X)){
setIntakes(50,50);
}

So there is a good chance that there is a problem in these three lines.

I would add an else statement to turn off the intakes, because otherwise you will never be able to turn them off.

Something like:

if(controller.get_digital(DIGITAL_X)){
setIntakes(50,50);
}else {
setIntakes(0,0);
}

I would suggest you try @NagiRamen’s suggestion as well, though I don’t think that it will fix it based on this.

Unfortunately, this is somewhat vague. If you want more help, it would be helpful to have some more information. Consider these questions:
Is the rightIntake not working? Is the leftIntake not working? Are both not working? Do they move at all? Do the motors spin when not powered? Can the brain drive the motor from the devices screen?

3 Likes

They both don’t work and the brain can drive the motor and they don’t move at. They worked on my vexCode program though.

then use vexcode…?

PROS is better and we are switching

Maybe don’t use the function you configured in the while command, and use the direct motor movements. Something similar happened in VexCode with your turn function, so I ended up using the normal command. I myself am new to PROS so I’m not sure if this will help, but it’s worth a shot, and could be the reason the intakes aren’t working.

This does not work thx though

What doesn’t work about it? Can you describe the behavior exhibited by the robot?

3 Likes

ummmm, perhaps it might be slightly more powerful… vexcode is still very good and if your code works on it, I don’t see why you would still want to switch to pros…

While this is the case there are very specific use cases where you are going to be able to use the advantages that pros has to offer. I would suggest learning pros during the summer/early season instead of the late season. There are very few high school teams that use pros. Vexcode is very functional, has an easier graphics system, and will run almost anything because the V5 brain has more than enough processing power.

1 Like