RobotPy 2020 Physics Example available

One of the things that has set RobotPy apart in the past from Java/C++ is that we had a simulator and in particular we could drive a robot on a virtual field. Unfortunately, we’ve had to do without that this season because we’re using WPILibC this year.

Until now.

Here’s how you do it:

The physics support is quite a hack – but it’s a start!

PS: Java/C++ teams have this too. It’s mildly harder for them to set it up, particularly because the field view hasn’t been officially released yet!


I am wondering if CAN (either CTRE or Rev) is available in the physics module. I looked in the help file, and did not see any so I assume it is not there, but it would be nice if it were. In addition, I am wondering if vision targets are available.

I understand these are tall asks and understand if they are neither present nor possible, but it would be nice to help us troubleshoot some things as we play with more advanced motor controller features and functions.

I really love the implementation of the physics module and new simulator. These are incredible updates.

It’s up to the vendors to provide support for CAN devices. Both CTRE and REV have very limited simulation support right now, so basic things like motor values might work, but any of the advanced motor controls probably aren’t implemented yet.

Here’s a python interactice session showing ways to explore what simulated devices and values are available:

>>> import ctre
>>> import hal.simulation
>>> srx = ctre.WPI_TalonSRX(1)
>>> hal.simulation.SimDeviceSim.enumerateDevices()
['Talon SRX[1]']
>>> srxSim = hal.simulation.SimDeviceSim("Talon SRX[1]")
>>> srxSim.enumerateValues()
[('Motor Output', False), ('Inverted?', False)]
>>> srxSimMotorOutput = srxSim.getDouble('Motor Output')
>>> srx.set(1)
>>> srxSimMotorOutput.get()
1 Like

Thank you that is excellent! I know the vendors are not supporting the sim as well as we would like, but understand because they are making incredible hardware that is helping us take our robot to the next level.