Brick
Toggle main menu visibility
Loading...
Searching...
No Matches
rotation.h
Go to the documentation of this file.
1
/**
2
* @file rotation.h
3
* @brief V5 rotation sensor using Core's geometry and physical units.
4
*/
5
6
#pragma once
7
8
#include "core/math/geometry/rotation2d.h"
9
#include "core/math/units.h"
10
#include "
crust/devices/device.h
"
11
12
namespace
crust
{
13
14
/**
15
* @brief Class implementing the V5 Rotation Sensor.
16
*
17
* Provides functions for getting angle (wrapped), position (continuous), and angular velocity.
18
* The sensor is able to be reversed, and its position can be set.
19
*/
20
class
Rotation
:
public
Device
{
21
public
:
22
/**
23
* @brief Constructs a Rotation Sensor.
24
* @param port Physical Smart Port number [1, 21].
25
* @param reversed True to reverse the reported direction.
26
*/
27
explicit
Rotation
(
int
port
,
bool
reversed
=
false
);
28
29
/**
30
* @brief Gets the shaft's absolute orientation within one revolution.
31
* @return Wrapped orientation represented by a Rotation2d.
32
* @note set_position() does not affect this value! The offset for this function can be set
33
* manually in the brain's devices tab.
34
*/
35
Rotation2d
angle
()
const
;
36
37
/**
38
* @brief Gets the shaft's accumulated rotation relative to the current zero point.
39
* @return Continuous units::Angle that can span multiple revolutions.
40
*/
41
units::Angle
position
()
const
;
42
43
/**
44
* @brief Gets the shaft's angular velocity.
45
* @return units::AngularVelocity.
46
*/
47
units::AngularVelocity
velocity
()
const
;
48
49
/**
50
* @brief Sets the accumulated position to a continuous units::Angle.
51
* @param position value to set.
52
* @note Rounds to the nearest 0.01 degree for the C SDK. Does not change the result of angle().
53
*/
54
void
set_position
(units::Angle
position
);
55
56
/**
57
* @brief Sets the accumulated position to a wrapped Rotation2d.
58
* @param position value to set.
59
* @note Rounds to the nearest 0.01 degree, wraps a rounded full revolution to zero.
60
* Does not change the result of angle().
61
*/
62
void
set_position
(
Rotation2d
position
);
63
64
/**
65
* @brief Sets the accumulated position to zero.
66
* @note Does not change the result of angle().
67
*/
68
void
reset_position
();
69
70
/**
71
* @brief Configures the direction reported.
72
* @param reversed True to reverse the sensor.
73
*/
74
void
set_reversed
(
bool
reversed
);
75
76
/**
77
* @brief Gets the sensor's reversal flag.
78
* @return True if sensor is reversed.
79
*/
80
bool
reversed
()
const
;
81
};
82
83
}
// namespace crust
Rotation2d
Definition
rotation2d.h:16
crust::Device::port
int port() const
Gets the physical Smart Port number.
Definition
device.h:24
crust::Device::Device
Device(int port, int expected_type)
Resolves and caches the C SDK handle for a physical Smart Port.
crust::Rotation::reversed
bool reversed() const
Gets the sensor's reversal flag.
crust::Rotation::Rotation
Rotation(int port, bool reversed=false)
Constructs a Rotation Sensor.
crust::Rotation::reset_position
void reset_position()
Sets the accumulated position to zero.
crust::Rotation::set_position
void set_position(Rotation2d position)
Sets the accumulated position to a wrapped Rotation2d.
crust::Rotation::velocity
units::AngularVelocity velocity() const
Gets the shaft's angular velocity.
crust::Rotation::angle
Rotation2d angle() const
Gets the shaft's absolute orientation within one revolution.
crust::Rotation::set_position
void set_position(units::Angle position)
Sets the accumulated position to a continuous units::Angle.
crust::Rotation::set_reversed
void set_reversed(bool reversed)
Configures the direction reported.
crust::Rotation::position
units::Angle position() const
Gets the shaft's accumulated rotation relative to the current zero point.
device.h
Implements device port and connection logic used by VEX device subclasses.
crust
The namespace of the entire Crust package, which contains direct abstractions for VEX hardware.
crust
devices
rotation.h
Generated by
1.18.0