PID for V5 motors

  1. 3 months ago

    abennett5139

    Sep 13 Concord, NC 5139

    Hey so I was wondering if anyone had any example code or any help to help me learn how to make a PID for my Autonomous. Example codes in any programming language (RobotC, RobotMesh, or VCS) would be appreciated. Thanks

  2. It's built in to the V5 motors. In RMS, we have a Drivetrain class that helps with wrangling two motors at the same time, doing encoder turns, and doing distance-based driving. Check out this example project for a dead-reckoning autonomous with V5 in Robot Mesh Studio C++. I also wrote a version of this in Blockly and in Python .

  3. abennett5139

    Sep 13 Concord, NC 5139

    @John TYler It's built in to the V5 motors. In RMS, we have a Drivetrain class that helps with wrangling two motors at the same time, doing encoder turns, and doing distance-based driving. Check out this example project for a dead-reckoning autonomous with V5 in Robot Mesh Studio C++. I also wrote a version of this in Blockly and in Python .

    So when you made the dt what were the numbers 319.1764, 292.1 for?

  4. tabor473

    Sep 13 V5 Beta Tester OYES, WPI

    @abennett5139 So when you made the dt what were the numbers 319.1764, 292.1 for?

    From the Robot Mesh API

    vex::drivetrain::drivetrain	(	motor & 	leftMotor,
    motor & 	rightMotor,
    float 	wheelTravel = 319.1764,
    float 	trackWidth = 292.1,
    distanceUnits 	unit = distanceUnits::mm 
    )	
  5. Edited 3 months ago by John TYler

    Wheel circumference and drive train width, in millimeters. When you are setting up a drivetrain with the configuration tool on the right side it asks for those values and tells you what it's asking for.

  6. abennett5139

    Sep 13 Concord, NC 5139

    @tabor473 From the Robot Mesh API

    vex::drivetrain::drivetrain ( motor & leftMotor, motor & rightMotor, float wheelTravel = 319.1764, float trackWidth = 292.1, distanceUnits unit = distanceUnits::mm )

    Ok so the dead reckoning program isn't a PID per say like it isn't accounting for motor variances and one motor being slightly slower than the other it is just linking them together and setting their velocity's the same. But it could curve one way or the other due to not every motor being exactly the same, correct?

  7. tabor473

    Sep 13 V5 Beta Tester OYES, WPI

    @abennett5139 Ok so the dead reckoning program isn't a PID per say like it isn't accounting for motor variances and one motor being slightly slower than the other it is just linking them together and setting their velocity's the same. But it could curve one way or the other due to not every motor being exactly the same, correct?

    So with V5 motors when you tell them to go at "50 rpm" they do PID to achieve that 50 RPM. This program just helps organize low level motor PID into high level commands like "drive straight 1 meter"

  8. The motors handle doing PID on their end. The program asks them to move to a position, and the motors handle things from there. The Drivetrain class handles the math of translating linear and rotational units to motor movement positions based on the configuration.

  9. 2 months ago

    M8R

    Sep 14 Los Angeles, California TP 2150A/ITZ 7700S

    rtfm .
    That specific command will have the motors motion profile to their target.

  10. Rick TYler

    Sep 14 Teachers/Coaches, Event Partner, V5 Beta Moderator Redmond, Washington Founder of Exothermic Robotics

    @M8R rtfm .
    That specific command will have the motors motion profile to their target.

    While I appreciate any exhortation to RTM, not everyone is using VCS.

  11. In Robot Mesh Studio, is there a way to cluster/pair/combine motors in order to take advantage of the vex.Drivetrain class for a 4 wheeled robot where every wheel is driven by a separate motor? In other words when the Drivetrain sends a command to the "left motor", both left motors respond as one? Thanks.

  12. Rick TYler

    Oct 12 Teachers/Coaches, Event Partner, V5 Beta Moderator Redmond, Washington Founder of Exothermic Robotics

    @roboballer In Robot Mesh Studio, is there a way to cluster/pair/combine motors in order to take advantage of the vex.Drivetrain class for a 4 wheeled robot where every wheel is driven by a separate motor? In other words when the Drivetrain sends a command to the "left motor", both left motors respond as one? Thanks.

    Not yet. You can do this on the Cortex by using y-cables and driving one pair of wheels from one port. If you do this, I would plug one pair of wheels into a lower port (like 2-5) and one into a higher port (6-9). I would avoid using ports 1 and 10 for drive motors. Currently, there is no way to create a 4-motor drivetrain in VEX IQ or VEX V5.

 

or Sign Up to reply!