WPILibC++ 2024.3.2
SubsystemBase.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <string>
8#include <string_view>
9
12
14
15namespace frc2 {
16/**
17 * A base for subsystems that handles registration in the constructor, and
18 * provides a more intuitive method for setting the default command.
19 *
20 * This class is provided by the NewCommands VendorDep
21 */
22class SubsystemBase : public Subsystem,
23 public wpi::Sendable,
24 public wpi::SendableHelper<SubsystemBase> {
25 public:
26 void InitSendable(wpi::SendableBuilder& builder) override;
27
28 /**
29 * Gets the name of this Subsystem.
30 *
31 * @return Name
32 */
33 std::string GetName() const override;
34
35 /**
36 * Sets the name of this Subsystem.
37 *
38 * @param name name
39 */
41
42 /**
43 * Gets the subsystem name of this Subsystem.
44 *
45 * @return Subsystem name
46 */
47 std::string GetSubsystem() const;
48
49 /**
50 * Sets the subsystem name of this Subsystem.
51 *
52 * @param name subsystem name
53 */
55
56 /**
57 * Associate a Sendable with this Subsystem.
58 * Also update the child's name.
59 *
60 * @param name name to give child
61 * @param child sendable
62 */
63 void AddChild(std::string name, wpi::Sendable* child);
64
65 protected:
66 /**
67 * Constructor. Telemetry/log name defaults to the classname.
68 */
70 /**
71 * Constructor.
72 *
73 * @param name Name of the subsystem for telemetry and logging.
74 */
76};
77} // namespace frc2
A base for subsystems that handles registration in the constructor, and provides a more intuitive met...
Definition: SubsystemBase.h:24
void SetSubsystem(std::string_view name)
Sets the subsystem name of this Subsystem.
void AddChild(std::string name, wpi::Sendable *child)
Associate a Sendable with this Subsystem.
void SetName(std::string_view name)
Sets the name of this Subsystem.
std::string GetSubsystem() const
Gets the subsystem name of this Subsystem.
SubsystemBase(std::string_view name)
Constructor.
std::string GetName() const override
Gets the name of this Subsystem.
SubsystemBase()
Constructor.
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
A robot subsystem.
Definition: Subsystem.h:43
Helper class for building Sendable dashboard representations.
Definition: SendableBuilder.h:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Interface for Sendable objects.
Definition: Sendable.h:16
basic_string_view< char > string_view
Definition: core.h:501
Definition: TrapezoidProfileSubsystem.h:12