Replies: 2 comments 1 reply
-
|
I was able to more-or-less achieve the desired effect, but I'm still curious if there is a better / 'correct' way since each sub object does not have the .type specified an all I really did was add all of the properties of the child objects to the parent. drivebase.cpp void Drivetrain::InitSendable(frc::SendableBuilder &builder)
{
// Modules
m_frontLeft.InitSendable(builder, "FL");
m_frontRight.InitSendable(builder, "FR");
m_backLeft.InitSendable(builder, "BL");
m_backRight.InitSendable(builder, "BR");
builder.SetSmartDashboardType("DriveBase");
builder.SetActuator(true);
}SwerveModule.cpp void SwerveModule::InitSendable(frc::SendableBuilder &builder)
{
InitSendable(builder, "");
}
void SwerveModule::InitSendable(frc::SendableBuilder &builder, std::string name)
{
builder.SetSmartDashboardType("SwerveModule");
builder.SetActuator(true);
// Prefix for nested objects
if(name != "") name += "/";
// Drive Control
builder.AddDoubleProperty(
name + "Drive kP", [this] { return m_drivePIDController.GetP(); }, [this](double value) { m_drivePIDController.SetP(value); });
// etc...
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
You probably want SendableRegistry::AddChild and/or SendableRegistry::SetSubsystem. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
-
InitSendable(frc::SendableBuilder &builder) {} is my new favorite thing, but is it possible to 'nest' sendable objects?
I guess I expected to see is a builder.AddSendable() function that would let me nest subsystems within other systems. Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions