Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Class Angle Reference

Doi Yusuke edited this page Dec 1, 2016 · 10 revisions

Class Angle

The Angle class for any unit on ICS3.

Constructor

Nothing. but you can take factory function.

Static factory methods

  • 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)

Angle newDegree(double degree = 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.

Usage

auto new_degree = ics::Angle::newDegree(130); // angle is 130[deg]

Angle newRadian(double radian = 0.0)

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.

Usage

auto new_radian = ics::Angle::newRadian(ics::Angle::PI/2.0);
// angle is pi/2[rad]

Angle newCalibration(double rawCalibration, double angle = 0.0)

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.

Caution

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.

Usage

auto new_raw_angle = ics::Angle::newCalibration(1, 2000);
// raw data is 9500(auto add 7500). 2000[raw data] mean 67.5[deg].

Angle newSameUnit(const Angle& unit, double angle = 0.0)

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.

Usage

constexpr auto unit = ics::Angle::newDegree(30); // it can have angle data.
auto new_degree = ics::Angle::newSameUnit(unit, -50); // angle is -50[deg]

Copy and move

  • Angle(const Angle&) noexcept = default
  • Angle& operator=(const Angle&) noexcept

Angle& operator=(const Angle&) noexcept

Copy operator= copy only data. Don't effect to unit.

Example

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].

Methods

  • 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)

constexpr double get() const noexcept

get angle on unit.

  • return: angle on unit.

Usage

constexpr auto degree = ics::Angle::newDegree(70); // create 70[deg]
auto angle = degree.get(); // angle is 70.

constexpr operator double() const noexcept

get angle on unit.

  • return: angle on unit.

Usage

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.

void set(double angle)

set angle on unit.

  • param:
  • angle: angle on same unit.
  • throw:
  • std::out_of_range: raw data must be between 3500 to 11500.

Usage

auto degree = ics::Angle::newDegree(-50); // create degree
degree.set(20); // set 20[deg]

Angle& operator=(double angle)

set angle on unit.

  • param:
  • angle: angle on same unit.
  • throw:
  • std::out_of_range: raw data must be between 3500 to 11500.

Usage

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

constexpr uint16_t getRaw() const noexcept

get raw data of communication.

  • return: raw data.

Usage

constexpr auto degree = ics::Angle::newDegree(67.5); // create 67.5[deg]
auto raw_data = degree.getRaw(); // raw_data is 9500

void setRaw(uint16_t rawData)

set raw data of communication.

  • param:
  • rawData: raw data.
  • throw:
  • std::out_of_range: must be 3500 <= rawData <= 11500.

Usage

auto degree = ics::Angle::newDegree(); // create degree
degree.setRaw(9500); // degree's angle is 67.5[deg]