How to program a simulation

I have been trying to explore using the desktop simulator to simulate the hardware for our robot. I am currently trying to simulate a compressor/CTRE PCM, but I am not sure if I am understanding how it is supposed to work. The problem is made more difficult by virtue of the fact that all of the methods in CTREPCMSim immediately dive down into the JNI level.

If I don’t do anything, the compressor shows up on the SmartDashboard, but it always says “Enabled:false” and “PressureSwitch:false”. Enabling the robot doesn’t change it. On the simulator there are three dropdowns with Compressor, one says “controllable” with true and false, and enabled and pressureswitch, also with true and false. I can change the controllable dropdown, but not the enabled and pressureswitch dropdowns. What I wanted to do is implement a simulated air leak, so if the compressor is off, the pressure would drop enough to turn the pressure switch on, and then increase until it goes off again. I tried using setPressureSwitch to false and true, but getCompressorOn didn’t change. Do I have to implement all of the standard behavior of the Compressor? There doesn’t seem to be enough documentation for me to do that.

Am I going about this all wrong? Are the simulation classes only for unittesting? I feel like there should be a bunch of prebuilt modules for the desktop simulator to essentially build a simulated robot, but that doesn’t seem to be the case. A case in point would be the compressor. The compressor is handled essentially entirely under the covers, but my team has been having difficulty get our pneumatics to work. I wanted to have a simulation of the compressor to test our software, but if I am not sure of the behavior of the compressor in the first place, I certainly can’t program a simulation of it from scratch.

Also, as an aside, I get this message when I run my code:

NT: local publish to ‘/SmartDashboard/PneumaticSubsystem/Value’ disabled due to type mismatch (wanted ‘string’, currently ‘boolean’)
NT: local subscribe to ‘/SmartDashboard/PneumaticSubsystem/Value’ disabled due to type mismatch (wanted ‘string’, published as ‘boolean’)

Any idea what is causing that?

If you put both a Solenoid and a DoubleSolenoid to SmartDashboard with the same name (PneumaticSubsystem) you’d get that message.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.