"Compressor already allocated" error

Hi, we are getting an error when we initialize our pneumatics objects (compressor, solenoids). It normally says “Compressor already allocated” When we comment out the instantiation of the objects, the error stops occurring. Any ideas on how to fix? Thanks.

Most likely you’re instantiating the subsystem more than once. Look for where you’re doing new PneumaticsSubsystem and see if there’s any way that code can get called more than once. In this case, you have a getInstance(), but the constructor is public–typically for singletons like this the constructor should be private to prevent any other code from directly instantiating instead of going through getInstance(). So my guess is you are calling new PneumaticsSubsystem somewhere and using getInstance() in other places.

Or possibly getInstance is failing to assign to instance.

Also, if you’re trying to use the singleton pattern, then compressor, solenoid1, and solenoid2 should not be static.

We had an extra instantiation of the PneumaticsSystem class, and replaced its uses with the main one, and the error stopped happening. Thank you so much!

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