purduesigbots / pros

Source code for PROS kernel: open source C/C++ development for the VEX V5 microcontroller
https://pros.cs.purdue.edu
Other
259 stars 76 forks source link

PROS 4: Position returned by multiple motor groups is incorrect. #521

Closed Richard-Stump closed 1 year ago

Richard-Stump commented 1 year ago

Expected Behavior:

Having multiple motors/motor group objects on one port can lead to issues with get_position(). Motors/motor groups should return the same position regardless of the direction each object is in. I believe that the solution is to use the sign of the motor's port to modify the position/velocity of the move command (not sure exactly how to modify each function). It appears that reversing the motor in the middle of movement causes very weird behavior with VexOS.

Steps to reproduce:

Example:

void opcontrol() {
  pros::Motor_Group group1({19}, pros::Motor_Gear::green);
  pros::Motor_Group group2({-19}, pros::Motor_Gear::green);

  group1.move_relative(3600, 100);

  while (true) {
    pros::delay(20);
    std::cout << group1.get_position() << " " << group2.get_position() << std::endl; // reading -3600.4 -9001
  }
}

Relevant Thread:

https://discordapp.com/channels/1025259843763847229/1071283409407709205

WillXuCodes commented 1 year ago

Closing since rewrites are ongoing for motor groups or motors.