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
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
From the Robot Mesh API
vex::drivetrain::drivetrain ( motor & leftMotor, motor & rightMotor, float wheelTravel = 319.1764, float trackWidth = 292.1, distanceUnits unit = distanceUnits::mm )
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.
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”
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.
That specific command will have the motors motion profile to their target.
While I appreciate any exhortation to RTM, not everyone is using VCS.
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.
Sorry to revive an old thread. Just a question. Does the drivetrain within the vex namespace have PID control between left and right? Can you use two of these for 4 motors? Finally- we utilize GitHub for versioning… can we download the Vex C++ Project from RobotMesh?
I am pretty sure the drive train does not have PID between left and right. If you are looking for that functionality I would suggest PROS, the Okapi library shipped with PROS has chassis like that. Also using PROS would solve your last issue to use with github.
@carp The Robot Mesh Desktop program lets you download local copies of your online projects, and we also have the RMBuild command line tool if you want to use our API in a more freeform manner.