WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
XRPServo.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"
12#include "wpi/units/angle.hpp"
13
14namespace wpi::xrp {
15
16/**
17 * @ingroup xrp_api
18 * @{
19 */
20
21/**
22 * XRPServo.
23 *
24 * <p>A SimDevice based servo
25 */
26class XRPServo {
27 public:
28 /**
29 * Constructs an XRPServo.
30 *
31 * @param deviceNum the servo channel
32 */
33 explicit XRPServo(int deviceNum);
34
35 /**
36 * Set the servo angle.
37 *
38 * @param angle Desired angle in radians
39 */
40 void SetAngle(wpi::units::radian_t angle);
41
42 /**
43 * Get the servo angle.
44 *
45 * @return Current servo angle in radians
46 */
47 wpi::units::radian_t GetAngle() const;
48
49 private:
50 hal::SimDevice m_simDevice;
51 hal::SimDouble m_simPosition;
52
53 std::string m_deviceName;
54
55 static std::map<int, std::string> s_simDeviceMap;
56 static std::set<int> s_registeredDevices;
57
58 static void CheckDeviceAllocation(int deviceNum);
59};
60
61/** @} */
62
63} // namespace wpi::xrp
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
XRPServo(int deviceNum)
Constructs an XRPServo.
wpi::units::radian_t GetAngle() const
Get the servo angle.
void SetAngle(wpi::units::radian_t angle)
Set the servo angle.
Definition XRPOnBoardIO.hpp:13