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

Class ICS3 Reference

Doi Yusuke edited this page Mar 28, 2017 · 25 revisions

Class ICS3

The interface class of ICS3 communication.

Constructor

  • explicit ICS3(const std::string& path, const Baudrate& baudrate = RATE115200())

explicit ICS3(const std::string& path, const Baudrate& baudrate = RATE115200())

This constructor setup device for ICS3 communication.

  • param:
    • path: Path of serial device.
    • baudrate: Baud rate of serial communication.
  • throw:
    • std::invalid_argument: Fail path. ex) Non tty device.
    • std::runtime_error: Fail setup task. ex) Not exist device or fail set termios.

Usage

constexpr auto my_baudrate = ics::Baudrate::RATE115200();
ics::ICS3 ics3 {"/dev/ttyUSB0", my_baudrate}; // open and setup "/dev/ttyUSB0"

Samples have ics3 instance without declaration. that mean ICS3 instance.

Methods

  • Angle move(const ID& id, Angle angle)
  • Angle free(const ID& id, Angle unit = Angle::newRadian())
  • Parameter get(const ID& id, const Parameter& type)
  • void set(const ID& id, const Parameter& param)
  • EepRom getRom(const ID& id)
  • void setRom(const ID& id, const EepRom& rom)
  • ID getID()
  • void setID(const ID& id)

Angle move(const ID& id, Angle angle)

Move a motor to angle. Return now angle of it.

  • param:
    • id: id of a servo motor.
    • angle: Want position.
  • return: Now angle. angle unit is the same(param:angle).
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID servoId {0};
auto target = ics::Angle::newDegree(20); // can take constexpr
auto now_pos = ics3.move(servoId, target); // servo(id:0) move to 20°,
                                           // return degree before moving.

Angle free(const ID& id, Angle unit = Angle::newRadian())

The motor get free torque, Return now angle of it.

  • param:
    • id: id of a servo motor.
    • unit: Unit of return angle.
  • return: Now angle. angle unit is the same(param:unit)
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID servoID {0};
constexpr auto my_unit = ics::Angle::newDegree();
auto new_pos = ics3.free(servoId, my_unit);
// The motor(id:0) get free torque, return degree before moving.

Parameter get(const ID& id, const Parameter& type)

The motor give you parameter.

  • param:
    • id: id of a servo motor.
    • type: Parameter type that is your want it.
  • return: Now parameter data.
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID id {0};
constexpr auto specify = ics::Parameter::stretch();
auto now_stretch = ics3.get(id, specify);
// get stretch parameter on the motor(id:0)

void set(const ID& id, const Parameter& param)

Set Parameter to a motor.

  • param:
    • id: id of a servo motor.
    • param: value of new setting.
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID id {0};
auto new_stretch = ics::Parameter::stretch(35); // can take constexpr
ics3.set(id, new_stretch); // set 35 to stretch parameter on the motor(id:0)

EepRom getRom(const ID& id)

The motor return EEPROM data.

  • param:
    • id: id of a servo motor.
  • return: EEPROM data of the motor.
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID id {0};
auto rom = ics3.getRom(id); // get EEPROM data on the motor(id:0)

void setRom(const ID& id, const EepRom& rom)

Set EEPROM to a motor.

  • param:
    • id: id of a servo motor.
    • rom: new EEPROM data of the motor.
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID id {0};
// ics::Baudrate new_rom; // cannot compile this line.
// you cannot create ics::EepRom. you get EepRom only by ICS3::getRom.
ics3.setRom(id, new_rom); // set EEPROM data to the motor(id:0).

ID getID()

The motor return ID. この関数を実行するとき,必ずモータを一つだけ繋いでください.

  • return: the motor's ID.
  • throw: std::runtime_error: Communication error.

Usage

auto id = ics3.getID(); // get motor's ID

void setID(const ID& id)

Set ID to the motor. この関数を実行するとき,必ずモータを一つだけ繋いでください.

  • param:
    • id: new ID.
  • throw: std::runtime_error: Communication error.

Usage

constexpr ics::ID newID {20};
ics3.setID(newID);