WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
XRPMotor.hpp
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 <map>
8#include <set>
9#include <string>
10
11#include "wpi/hal/SimDevice.hpp"
14
15namespace wpi::xrp {
16
17/**
18 * @defgroup xrp_api XRP Hardware API
19 * @{
20 */
21
22/**
23 * XRPMotor.
24 *
25 * <p>A SimDevice based motor controller representing the motors on an XRP robot
26 */
28 public:
29 /**
30 * Constructs an XRPMotor.
31 *
32 * @param deviceNum the motor channel
33 */
34 explicit XRPMotor(int deviceNum);
35
36 void SetThrottle(double throttle) override;
37 double GetThrottle() const override;
38
39 void SetInverted(bool isInverted) override;
40 bool GetInverted() const override;
41
42 void Disable() override;
43
44 void StopMotor() override;
45 std::string GetDescription() const override;
46
47 private:
48 hal::SimDevice m_simDevice;
49 hal::SimDouble m_simThrottle;
50 hal::SimBoolean m_simInverted;
51
52 std::string m_deviceName;
53
54 static std::map<int, std::string> s_simDeviceMap;
55 static std::set<int> s_registeredDevices;
56
57 static void CheckDeviceAllocation(int deviceNum);
58};
59
60/** @} */
61
62} // namespace wpi::xrp
Interface for motor controlling devices.
Definition MotorController.hpp:14
The Motor Safety feature acts as a watchdog timer for an individual motor.
Definition MotorSafety.hpp:24
C++ wrapper around a HAL simulator boolean value handle.
Definition SimDevice.hpp:244
A move-only C++ wrapper around a HAL simulator device handle.
Definition SimDevice.hpp:278
C++ wrapper around a HAL simulator double value handle.
Definition SimDevice.hpp:169
XRPMotor(int deviceNum)
Constructs an XRPMotor.
double GetThrottle() const override
Gets the throttle of the motor controller.
void StopMotor() override
Called to stop the motor when the timeout expires.
void SetInverted(bool isInverted) override
Sets the inversion state of the motor controller.
void SetThrottle(double throttle) override
Sets the throttle of the motor controller.
std::string GetDescription() const override
Returns a description to print when an error occurs.
bool GetInverted() const override
Gets the inversion state of the motor controller.
void Disable() override
Disables the motor controller.
Definition XRPOnBoardIO.hpp:13