View Single Post
  #7   Spotlight this post!  
Unread 13-02-2015, 15:53
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: What is the purpose of RobotMap.java in CommandBased?

Quote:
Originally Posted by cstelter View Post
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?
Here is an example this year. We have a command that runs a gripper on top of an elevator. I want to be able to do certain things with that gripper, but only when that elevator is below a certain height. The sensor is also used to run a controller that sets the elevator at a different height. Both subsystems want access to the sensor, but the sensor is mainly used with the elevator.

You can accidentally control any subsystem from any command, not sure how its any less easy with a sensor subsystem.

Quote:
I do agree that RobotMap should just be used for holding constants, not the actual objects, which you should have a separate Storage class for.
I strongly disagree with the second part of this statement, and its the same reason our team does not use the RobotBuilder system. Look up programming principles like Data Hiding and Encapsulation. By putting all of the devices in a storage class you are breaking those principles.

Last edited by notmattlythgoe : 13-02-2015 at 15:56.
Reply With Quote