![]() I know one could always construct a complex-enough scenario, especially if you’re doing state-space controllers, where that level of accuracy is required. For software test, I do believe that “speed ~= command” gets a whole lot of it, and some exponential or first order model gets almost all the rest… The 2021 physics sim classes will hopefully give something more accurate than that for less effort (a couple lines of input-output plumbing in simulationPeriodic()).Īgreed - when I was thinking “super accurate physics simulation” I was more thinking the fidelity where you could go back to the mechanical team and describe the effectiveness of their design. You have to set up something like “the encoder moves at a rate proportional to the voltage applied”. Here’s an example of that quantization error causing noise in a simulated flywheel’s angular velocity calculation (change in angle divided by change in time). It’s kinda nice the HAL sim inherently models that. The simulation encoder setter rounds the internal edge count to the nearest integer, which gives you finite resolution, as you’d expect. When you call SetPosition() or SetRate(), it’ll convert by the distance per pulse and set the internal count such that GetPosition() will return the value you passed to the setter. For example, the way WPILib’s EncoderSim (which is intended for quadrature encoders plugged into the roboRIO) works is you can call SetPosition() or SetRate(), it’ll set the internal count such that GetPosition() will return the value you passed to the setter. To follow this framework, vendors will need to provide simulation versions of their classes with sensor set calls. Set the sim encoder position to the value from the drivetrain sim object Call update on the drivetrain sim object with the loop time (e.g., 20ms)Ĭ. Set the drivetrain sim object’s inputs to the motor outputsī. We have a factory function specifically for kitbots too for those who want a drivetrain, not necessarily their drivetrain.Ī. Its constructor takes information like the types of motors you have, the width and mass of the drivetrain, and the gear ratio. ![]() Instantiate a physics sim class like DifferentialDrivetrainSim.Each sim object can take the real object in its constructor so it knows what object its setters are affecting. Instantiate a simulation version of an object, like EncoderSim or MotorSim.The current simulation physics workflow is as follows: We set up simulation so that users add code simulationPeriodic() and create sim objects, but otherwise don’t have to touch the normal robot code. I would like to see a user-defined link ratio so that Talons and such can return a roughly realistic encoder value based on motor speed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |