WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
XRPServo.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 <map>
8#include <set>
9#include <string>
10
11#include <hal/SimDevice.h>
12#include <units/angle.h>
13
14namespace frc {
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(units::radian_t angle);
41
42 /**
43 * Get the servo angle.
44 *
45 * @return Current servo angle in radians
46 */
47 units::radian_t GetAngle() const;
48
49 /**
50 * Set the servo position.
51 *
52 * @param position Desired position (Between 0.0 and 1.0)
53 * @deprecated Use SetAngle() instead
54 */
55 [[deprecated("Use SetAngle() instead")]]
56 void SetPosition(double position);
57
58 /**
59 * Get the servo position.
60 *
61 * @return Current servo position
62 * @deprecated Use GetAngle() instead
63 */
64 [[deprecated("Use GetAngle() instead")]]
65 double GetPosition() const;
66
67 private:
68 hal::SimDevice m_simDevice;
69 hal::SimDouble m_simPosition;
70
71 std::string m_deviceName;
72
73 static std::map<int, std::string> s_simDeviceMap;
74 static std::set<int> s_registeredDevices;
75
76 static void CheckDeviceAllocation(int deviceNum);
77};
78
79/** @} */
80
81} // namespace frc
XRPServo.
Definition XRPServo.h:26
XRPServo(int deviceNum)
Constructs an XRPServo.
double GetPosition() const
Get the servo position.
units::radian_t GetAngle() const
Get the servo angle.
void SetAngle(units::radian_t angle)
Set the servo angle.
void SetPosition(double position)
Set the servo position.
A move-only C++ wrapper around a HAL simulator device handle.
Definition SimDevice.h:645
C++ wrapper around a HAL simulator double value handle.
Definition SimDevice.h:536
Definition CAN.h:11