-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛[BUG] - motor .get_direction()
does not work
#695
Comments
are the motors plugged in |
it turns out I was confusing two issues- I'm having a constructor take a motor group instead of a vector of ints. I was trying to check the direction of the motors so I could copy/paste it to the "motor groups" that are used internally in the code. This didn't work, and then the example code didn't work (when I don't have motors in port 1 or 3), and I made this issue. I've done more testing now and it seems like something still isn't quite right. No matter what I do with the directions of 11 and 15, the only thing I see printed is 0. I tried pros::MotorGroup mg({11, 15});
int dir = mg.get_direction();
using namespace pros;
void opcontrol() {
std::cout << "Motor Direction: " << dir << "\n";
printf("\n\n");
pros::Controller master(E_CONTROLLER_MASTER);
while (true) {
mg.move(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y));
dir = mg.get_direction();
std::cout << "Motor Direction: " << dir << "\n";
pros::delay(2);
}
} This is also true of pros::Motor mg(11);
int dir = mg.get_direction();
using namespace pros;
void opcontrol() {
std::cout << "Motor Direction: " << dir << "\n";
printf("\n\n");
pros::Controller master(E_CONTROLLER_MASTER);
while (true) {
mg.move(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y));
// Print the motor direction for the motor at index 1. (port 3)
dir = mg.get_direction();
std::cout << "Motor Direction: " << dir << "\n";
pros::delay(2);
}
} and it is also true of the C functions, only 0 is printed. void opcontrol() {
while (true) {
pros::c::motor_move(-11, pros::c::controller_get_analog(pros::E_CONTROLLER_MASTER, pros::E_CONTROLLER_ANALOG_LEFT_Y));
printf("Motor Direction: %d\n", pros::c::motor_get_direction(11));
pros::delay(2);
}
} In all of these examples, I confirmed the motors were moving with the joystick. Sorry for not being as thorough initially! |
We can't reproduce this. "2147483647" is when the motor is not plugged in, which you seem to have resolved. But if the motor is moving, it should output -1 or 1. Are you running the latest version of the kernel? |
@thiccaxe @ssejrog |
But then you wouldn't be able to reverse the motor from C? This might be okay if the C functions (i.e. |
re @djava
The C functions do indeed support negative port numbers, so there's not too much of an issue. As far as breaking API goes, |
Deprecating |
I think the C API is infrequently used to the extent that this shouldn't be too much of an issue. Also, it turns out there's even more API madness: the C++ API has a method |
@ion098
|
Describe the bug
This outputs
2147483647
To Reproduce
Steps to reproduce the behavior:
The example project uses
motor = 127
instead ofmotor.move()
, so with that this is the example code.Expected behavior
Because the motor isn't reversed, I should see
1
.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: