What does this code in "Getting Started" do?

I was looking at previous years versions of the “Getting Started”
example for java.

I use it annually as a gentle introduction for new programmers, and I usually understand the minor yearly changes.

I didn’t pay close enough attention to last years change in lines 28-31.
What do these lines do?

public Robot() {
SendableRegistry.addChild(m_robotDrive, m_leftDrive);
SendableRegistry.addChild(m_robotDrive, m_rightDrive);
}

Given how uninformed I have to be to ask this question, I expect and will tolerate mild aspersions to my knowledge … I just REALLY want to know.

1 Like

From the WPILib docs:

The SendableRegistry class is the public interface for registering sensors and actuators for use on dashboards and LiveWindow.

Assuming the lines you sent just adds the two drive base components (left and right side of tank drive here) so you can view it on dashboards and such. Correct me if I’m wrong anyone; this is just what I’m reading from the docs.

Thank you for your reply. I should clarify that my difficulty with these lines is mostly with the first line.
Why is an object ‘Robot’ being instantiated? This wasn’t done in 2023 or previous years.

The robot was always getting instantiated (see main in Main.java). What you’re doing here is defining a constructor when you were previously relying on the default (do nothing) constructor. You’re doing this because you now have something you want to do in the constructor.

1 Like