The field m_drivetrain is not visible

I’m a very new java programmer and I’m trying to make a simple drive train for our robot from last year just to test.

I have a subsystem for DriveTrain and a command for ArcadeDrive. but when I try to add the requirements for the subsystem it says it’s not visible. It can be solved by making m_drivetrain (in Robotcontainer) public and static but I was wondering if this was correct or if it would cause problems later.
The latest code is pushed to github here if anyone wants to take a look: GitHub - FalcoTech/FalcoTech2023
Screenshot 2023-01-09 171847

It’s declared as private, which means it can’t be accessed from another class. Make it public instead.

EDIT: it also needs to be static, see below discussion.


wasn’t sure if it would cause problems later. Much appreciated <3
I’m sure I’ll be back to chiefdelphi with more questions lol

1 Like

Also you’re accessing it statically which requires the static keyword. “public static final”


correct me if I’m wrong please: to access something statically means it can be defined/accessed in multiple classes?

It means that there’s only one of them, rather than one per instantiation (object) of the class. It also means you can access it via the class name, rather than needing an object of the class.

got it. I think it just threw me off because a lot of examples that I saw were defining their subsystems as private

That’s because a more common way to solve this issue (best practice) is to pass the subsystem to the command’s constructor, rather than having the command back-reference a global (static). This is called dependency injection.