CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
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/MotorSafety.h"
10#include <functional>
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 std::function<void()> m_stopMotor;
23 std::string const &m_description;
24
25public:
26 /**
27 * \brief Constructor for MotorSafetyImplem
28 * \param stopMotor Function to stop the motor
29 * \param description Description of motor controller
30 */
31 MotorSafetyImplem(std::function<void()> stopMotor, std::string const &description) :
32 m_stopMotor{std::move(stopMotor)},
33 m_description{description}
34 {}
35
36 /**
37 * \brief Stops the controller
38 */
39 void StopMotor() override
40 {
41 m_stopMotor();
42 }
43 /**
44 * \returns Description of motor controller
45 */
46 std::string GetDescription() const override
47 {
48 return m_description;
49 }
50};
51
52}
53}
54}
Implem of MotorSafety interface from WPILib.
Definition MotorSafetyImplem.hpp:20
void StopMotor() override
Stops the controller.
Definition MotorSafetyImplem.hpp:39
MotorSafetyImplem(std::function< void()> stopMotor, std::string const &description)
Constructor for MotorSafetyImplem.
Definition MotorSafetyImplem.hpp:31
std::string GetDescription() const override
Definition MotorSafetyImplem.hpp:46
Definition StatusCodes.h:18
Definition span.hpp:401