I’m a C++ guy and I think one could solve the problem of subsystems driving other subsystems by making all motor driving functions non-const and all sensor reading functions const. This way one could provide only a const pointer to the other subsystems but non-const pointers to the commands allowing commands to drive the subsystems but not allow the other subsystems to, yet allow both access to sensor readings.
I did a quick look to see if Java provides similar, but it looks like perhaps not.
I’m trying to think if the idea of sharing a sensor between two subsystems perhaps indicates that a better subsystem configuration is possible. I’m not sure I like collecting all sensors into a globally accessible sensor class-- one subsystem may reset an encoder and mess up code in another for example.
I guess I prefer the idea of making access functions in a subsystem that owns a sensor better, but I think it could use further discussion.
I suspect perhaps that code in a subsystem that needs a sensor from another subsystem might better be coded in a command that requires both subsystems. But I think I can also think of counterexample where that won’t work well.
Can you give a good concrete example where two subsystems require a single sensor so we can kick around various approaches to resolve it within the command based paradigm?