CTRE Phoenix 6 C++ 24.3.0
MotorSafetyImplem.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
9#include "frc/motorcontrol/MotorController.h"
10#include "frc/MotorSafety.h"
11
12namespace ctre {
13namespace phoenix6 {
14namespace wpiutils {
15
16/**
17 * \brief Implem of MotorSafety interface from WPILib. This also allows
18 * late/lazy construction of WPILib's motor safety object.
19 */
20class MotorSafetyImplem : public frc::MotorSafety {
21private:
22 frc::MotorController &m_motorController;
23 std::string const &m_description;
24
25public:
26 MotorSafetyImplem(frc::MotorController &motorController, std::string const &description) :
27 m_motorController{motorController},
28 m_description{description}
29 {}
30
31 /**
32 * \brief Stops the controller
33 */
34 void StopMotor() override
35 {
36 m_motorController.StopMotor();
37 }
38 /**
39 * \returns Description of motor controller
40 */
41 std::string GetDescription() const override
42 {
43 return m_description;
44 }
45};
46
47}
48}
49}
Implem of MotorSafety interface from WPILib.
Definition: MotorSafetyImplem.hpp:20
MotorSafetyImplem(frc::MotorController &motorController, std::string const &description)
Definition: MotorSafetyImplem.hpp:26
void StopMotor() override
Stops the controller.
Definition: MotorSafetyImplem.hpp:34
std::string GetDescription() const override
Definition: MotorSafetyImplem.hpp:41
Definition: string_util.hpp:15