This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Class Angle Reference
Doi Yusuke edited this page Dec 1, 2016
·
10 revisions
The Angle class for any unit on ICS3.
Nothing. but you can take factory function.
- static constexpr Angle newDegree(double degree = 0.0)
- static constexpr Angle newRadian(double radian = 0.0)
- static constexpr Angle newCalibration(double rawCalibration, double angle = 0.0)
- static constexpr Angle newSameUnit(const Angle& unit, double angle = 0.0)
method of get new Angle instance of degree.
- patam:
- degree: angle of initialization.
- return: Angle instance
- throw:
- std::out_of_range: must be -130 < degree < 130.
auto new_degree = ics::Angle::newDegree(130); // angle is 130[deg]
method of get new Angle instance of radian.
- patam:
- radian: angle of initialization.
- return: Angle instance
- throw:
- std::out_of_range: must be -(13/18)pi < radian < (13/18)pi.
auto new_radian = ics::Angle::newRadian(ics::Angle::PI/2.0);
// angle is pi/2[rad]
method of get new Angle instance of any unit.
- patam:
- rawCalibration: Calibration for communication data.
- radian: angle of initialization on same calibration.
- return: Angle instance
- throw:
- std::out_of_range: raw data must be between 3500 to 11500.
The motor can take angles that must be bigger than -135[deg] and smaller than 135[deg]. On raw data, -135[deg] is 3500, 0[deg] is 7500 and 135[deg] is 11500.
On Degree, calibration is 800.0/27.0.
auto new_raw_angle = ics::Angle::newCalibration(1, 2000);
// raw data is 9500(auto add 7500). 2000[raw data] mean 67.5[deg].
method of get new Angle instance of duplicate unit.
- patam:
- unit: new Angle's unit.
- angle: angle of initialization on same unit.
- return: Angle instance
- throw:
- std::out_of_range: raw data must be between 3500 to 11500.
constexpr auto unit = ics::Angle::newDegree(30); // it can have angle data.
auto new_degree = ics::Angle::newSameUnit(unit, -50); // angle is -50[deg]
- Angle(const Angle&) noexcept = default
- Angle& operator=(const Angle&) noexcept
Copy operator= copy only data. Don't effect to unit.
auto degree = ics::Angle::newDegree(50); // create 50[deg]
constexpr auto radian = ics::Angle::newRadian(ics::Angle::PI / 6.0); // create pi/6[rad]
degree = radian; // degree is 30[deg]. don't change unit.
degree.set(-20); // degree is -20[deg].
- constexpr double get() const noexcept
- constexpr operator double() const noexcept
- void set(double)
- Angle& operator=(double)
- constexpr uint16_t getRaw() const noexcept
- void setRaw(uint16_t)
get angle on unit.
- return: angle on unit.
constexpr auto degree = ics::Angle::newDegree(70); // create 70[deg]
auto angle = degree.get(); // angle is 70.
get angle on unit.
- return: angle on unit.
constexpr auto degree = ics::Angle::newDegree(70); // create 70[deg]
double angle {degree}; // angle is 70.
auto angle2 = static_cast<double>(degree); // you can this.
set angle on unit.
- param:
- angle: angle on same unit.
- throw:
- std::out_of_range: raw data must be between 3500 to 11500.
auto degree = ics::Angle::newDegree(-50); // create degree
degree.set(20); // set 20[deg]
set angle on unit.
- param:
- angle: angle on same unit.
- throw:
- std::out_of_range: raw data must be between 3500 to 11500.
auto degree1 = ics::Angle::newDegree(-50); // create degree
auto degree2 = ics::Angle::newDegree(); // create degree
degree1 = degree2 = 20; // set 20[deg] to degree1 and degree2
get raw data of communication.
- return: raw data.
constexpr auto degree = ics::Angle::newDegree(67.5); // create 67.5[deg]
auto raw_data = degree.getRaw(); // raw_data is 9500
set raw data of communication.
- param:
- rawData: raw data.
- throw:
- std::out_of_range: must be 3500 <= rawData <= 11500.
auto degree = ics::Angle::newDegree(); // create degree
degree.setRaw(9500); // degree's angle is 67.5[deg]