RobotDriver C++ API Reference

This document describes the public interfaces of the RobotArm class (include/RobotArm.hpp). Signatures and types follow the header file; Angles and Coords are std::array<float, 6>, and Param contains ip_serial and port_baud (see include/config.hpp).

Note: RobotArm currently does not encapsulate extended capabilities such as gripper or tool/base IO.

Each API item below is documented with Function, Return Value, Parameter Description, and Range. The listed ranges apply to MyCobotPro450.


Quick Connection and Types

#include "RobotArm.hpp"
#include "config.hpp"

Param p;
p.ip_serial = "192.168.0.232";
p.port_baud = 4500;
RobotArm arm(TCP_COMM, p);
Symbol Range / Meaning
TCP_COMM 1, Socket (TCP)

General convention: for most int APIs, 1 usually means command success or valid response received under normal communication, and -1 usually means communication failure or invalid/missing response. Actual behavior follows controller firmware.


Construction and Destruction

RobotArm(uint8_t mode, Param params)

  • Function: Constructs an instance; internally creates Protocol and starts communication (begin()).
  • Return Value: None.
  • Parameter Description: mode is communication type; params contains address/port or serial parameters.
  • Range: mode ∈ {TCP_COMM (1), SERIAL_COMM (2)}; for TCP, port_baud is the port (for example 4500) and ip_serial is a reachable IP. Serial communication is not supported at present.

~RobotArm()

  • Function: Destructor; releases protocol and communication resources.
  • Return Value: None.
  • Parameter Description: None.
  • Range: None.

System Configuration, Power, and Version Information

int powerOn()

  • Function: Powers on the robotic arm.
  • Return Value: 1 success; 0 failure; -1 no communication (subject to controller behavior).
  • Parameter Description: None.
  • Range: None.

int powerOff()

  • Function: Powers off the robotic arm.
  • Return Value: 1 command accepted; -1 no communication.
  • Parameter Description: None.
  • Range: None.

int isPowerOn()

  • Function: Checks power state.
  • Return Value: 1 powered on; 0 not powered on; 2 power-on failure state; -1 no communication.
  • Parameter Description: None.
  • Range: None.

vector<int> isInitCalibration()

  • Function: Queries zero-position / calibration related status.
  • Return Value: Integer vector; length and semantics depend on the controller.
  • Parameter Description: None.
  • Range: None.

string getLibVersion()

  • Function: Reads library version string.
  • Return Value: Version string (for example, matching LIB_VERSION).
  • Parameter Description: None.
  • Range: None.

string getSystemVersion()

  • Function: Reads main controller/system version.
  • Return Value: Version string.
  • Parameter Description: None.
  • Range: None.

int getModifyVersion()

  • Function: Reads main controller patch version.
  • Return Value: Integer patch version.
  • Parameter Description: None.
  • Range: None.

string getRobotType()

  • Function: Reads robot model type string.
  • Return Value: For example 4503, depending on controller return.
  • Parameter Description: None.
  • Range: None.

string getAtomVersion()

  • Function: Reads end-effector firmware version.
  • Return Value: Version string.
  • Parameter Description: None.
  • Range: None.

int getToolModifyVersion()

  • Function: Reads end-effector patch version.
  • Return Value: Integer.
  • Parameter Description: None.
  • Range: None.

Control Mode and Refresh Mode

int getFreshMode()

  • Function: Gets refresh/queue motion mode.
  • Return Value: 0 interpolation/queue order; 1 refresh mode (latest command first); may return -1 on failure.
  • Parameter Description: None.
  • Range: None.

int setFreshMode(bool mode)

  • Function: Sets position motion mode.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: mode: false0 (interpolation), true1 (refresh).
  • Range: Boolean mapped to 0 / 1.

int getControlMode()

  • Function: Gets control mode (position/torque).
  • Return Value: 0 position mode; 1 torque mode; -1 on failure.
  • Parameter Description: None.
  • Range: None.

int setControlMode(bool mode)

  • Function: Sets control mode.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: mode: false→position (0), true→torque (1).
  • Range: Boolean mapped to 0 / 1.

Joint Control

int sendAngle(uint8_t joint, float angle, uint8_t sp)

  • Function: Sends target angle for a single joint.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: joint joint index; angle target angle (°); sp speed level.
  • Range: joint: 1 ~ 6; angle (°): J1 -162~162, J2 -125~125, J3 -154~154, J4 -162~162, J5 -162~162, J6 -165~165; sp: 1 ~ 100.

int sendAngles(Angles angles, uint8_t sp)

  • Function: Sends target angles for all six joints in one command.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: angles length 6; sp speed level.
  • Range: Each element uses the same joint-specific range as sendAngle; sp: 1 ~ 100.

float getAngle(uint8_t joint)

  • Function: Reads current angle of one joint.
  • Return Value: Floating angle (°); may return sentinel value when invalid/failed (depends on integration behavior).
  • Parameter Description: joint joint index.
  • Range: joint: 1 ~ 6.

Angles getAngles()

  • Function: Reads all six current joint angles.
  • Return Value: Angles, six floating-point values.
  • Parameter Description: None.
  • Range: None.

float getJointMinAngle(uint8_t joint)

  • Function: Reads software minimum angle limit of a joint.
  • Return Value: Float (°).
  • Parameter Description: joint.
  • Range: joint: 1 ~ 6.

float getJointMaxAngle(uint8_t joint)

  • Function: Reads software maximum angle limit of a joint.
  • Return Value: Float (°).
  • Parameter Description: joint.
  • Range: joint: 1 ~ 6.

int jogAngle(uint8_t joint, uint8_t direction, uint8_t speed)

  • Function: Continuous joint JOG until limit is reached or stop() is called.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: joint; direction; speed.
  • Range: joint: 1 ~ 6; direction: 0 negative, 1 positive; speed: 1 ~ 100.

int setFreeMoveMode(bool state)

  • Function: Sets free-move mode (manual guiding, etc.).
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: state, false off, true on.
  • Range: Mapped to 0 / 1.

int getFreeMoveMode()

  • Function: Gets free-move mode state.
  • Return Value: 0 off; 1 on; -1 no communication.
  • Parameter Description: None.
  • Range: None.

int setMotorEnabled(uint8_t joint, bool state)

  • Function: Enables/disables torque for one joint motor.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: joint; state (false disable torque, true enable torque).
  • Range: joint: 1 ~ 6 or 254 (all joints).

int servoRestore(uint8_t joint)

  • Function: Clears joint abnormality / restore command.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: joint.
  • Range: joint: 1 ~ 6 or 254 (all joints).

void setWaitArrival(bool enable)

  • Function: Sets whether motion commands wait for arrival before returning (closed-loop/open-loop); default is not closed-loop.
  • Return Value: None.
  • Parameter Description: enable, true closed-loop wait, false open-loop immediate return.
  • Range: Boolean.

bool getWaitArrival() const

  • Function: Queries whether wait-arrival is enabled.
  • Return Value: true / false.
  • Parameter Description: None.
  • Range: None.

bool waitPosArrived(int timeout_ms = 30000)

  • Function: Blocks until POS_ARRIVED-type arrival feedback is received.
  • Return Value: true if arrived, false on timeout.
  • Parameter Description: timeout_ms timeout.
  • Range: timeout_ms > 0 (ms), default 30000.

Drag Teaching

int dragTeachSave()

  • Function: Starts drag-teach trajectory recording.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: Single recording duration ≤ 120 s.

int dragTeachPause()

  • Function: Pauses drag-teach recording.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

int dragTeachExecute()

  • Function: Executes recorded trajectory once.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

int dragTeachClean()

  • Function: Clears recorded drag-teach sample points.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

Coordinate Control

int sendCoord(uint8_t axis, float coord, uint8_t sp)

  • Function: Sends a single coordinate/pose component.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: axis 1~6 maps to x,y,z,rx,ry,rz; coord value; sp speed level.
  • Range: axis: 1 ~ 6; x,y (mm) -474 ~ 474; z (mm) -180 ~ 677; rx,ry,rz (°) -180 ~ 180; sp: 1 ~ 100.

int SendCoords(Coords coords, uint8_t sp)

  • Function: Sends full 6D pose [x,y,z,rx,ry,rz].
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: coords length 6; sp speed level.
  • Range: Each component follows the corresponding sendCoord axis range; sp: 1 ~ 100.

Coords getCoords()

  • Function: Reads current coordinates/pose.
  • Return Value: Coords, six floating-point values.
  • Parameter Description: None.
  • Range: None.

int jogCoord(uint8_t axis, uint8_t direction, uint8_t speed)

  • Function: Continuous coordinate-axis JOG.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: axis; direction; speed.
  • Range: axis: 1 ~ 6; direction: 0 negative, 1 positive; speed: 1 ~ 100.

Motion Control (Shared by Joint and Coordinate)

int stop()

  • Function: Stops current motion.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

int pause()

  • Function: Pauses motion commands.
  • Return Value: int, e.g. 1 paused, 0 not stopped, -1 error (controller-specific).
  • Parameter Description: None.
  • Range: None.

int resume()

  • Function: Resumes motion.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

int isPaused()

  • Function: Checks pause state.
  • Return Value: 1 paused; 0 not paused; -1 error.
  • Parameter Description: None.
  • Range: None.

int isMoving()

  • Function: Checks whether robot is moving.
  • Return Value: 1 moving; 0 static; -1 error.
  • Parameter Description: None.
  • Range: None.

int isInPosition(Angles angle_coords, bool mode)

  • Function: Checks whether current state reached a target (angles or coordinates).
  • Return Value: 1 reached; 0 not reached; -1 abnormal or no valid response.
  • Parameter Description: angle_coords six target values; mode data type flag.
  • Range: mode: false means joint angles (°); true means coordinates (mm/°, same axis definition as sendCoord). Component ranges follow the corresponding joint/coordinate tables.

Robot Exception Handling and Status

int getErrorInformation()

  • Function: Reads motion/system error code.
  • Return Value: 0 no error; 1~6 joint over-limit; 32 coordinate no-solution (near reach limit); 33 no adjacent solution in linear motion; 34 speed fusion error; 35 no adjacent solution in null-space motion; 36 singularity no-solution; 81~86 collision-related for J1~J6 (recover using resume, etc.); others depend on firmware.
  • Parameter Description: None.
  • Range: None.

int clearErrorInfomation()

  • Function: Clears clearable error information (method spelling follows header file).
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: None.
  • Range: None.

vector<int> getRobotStatus()

  • Function: Reads robot status.
  • Return Value: When length is typically 20, items are: 1) collision flag; 2) moving flag; 3~8) J1~J6 over-limit flags; 9~14) J1~J6 motor hardware error flags; 15~20) J1~J6 software communication error flags (0 usually normal, non-zero abnormal). Length may vary by firmware.
  • Parameter Description: None.
  • Range: None.

RobotStatus getRobotStatusDetail()

  • Function: Reads structured status (collision, moving, limits, joint status words, communication status words, etc.).
  • Return Value: RobotStatus struct (see RobotArm.hpp).
  • Parameter Description: None.
  • Range: Fields are 0/1 flags or status words, depending on protocol.

vector<int> getMotorsRunErr()

  • Function: Reads motor errors during motion.
  • Return Value: List of length 6, all 0 usually means normal.
  • Parameter Description: None.
  • Range: None.

Speed / Acceleration Parameters

int getMaxSpeed(uint8_t mode)

  • Function: Reads max speed parameter.
  • Return Value: Current max speed setting; -1 on failure.
  • Parameter Description: mode: 0 joint angular speed, 1 coordinate linear speed.
  • Range: mode ∈ {0, 1}; physical ranges: angular speed 1 ~ 150 (°/s), coordinate speed 1 ~ 200 (mm/s).

int setMaxSpeed(uint8_t mode, uint16_t max_speed)

  • Function: Sets max speed.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: mode same as getMaxSpeed; max_speed target value.
  • Range: mode: 0 / 1; max_speed: angular 1~150 (°/s), coordinate 1~200 (mm/s).

int getMaxAcc(uint8_t mode)

  • Function: Reads max acceleration parameter.
  • Return Value: Current max acceleration; -1 on failure.
  • Parameter Description: mode: 0 joint angular acceleration, 1 coordinate acceleration.
  • Range: mode ∈ {0, 1}; angular acceleration 1 ~ 150 (°/s²), coordinate acceleration 1 ~ 400 (mm/s²).

int setMaxAcc(uint8_t mode, uint16_t max_acc)

  • Function: Sets max acceleration.
  • Return Value: int, usually 1 on success, -1 on failure.
  • Parameter Description: mode same as getMaxAcc; max_acc target value.
  • Range: mode: 0 / 1; max_acc: angular 1~150 (°/s²), coordinate 1~400 (mm/s²).

Encoders

vector<int> getServoEncoders()

  • Function: Reads six-joint servo encoder values.
  • Return Value: Integer vector of length 6 (controller parsing semantics apply).
  • Parameter Description: None.
  • Range: None.

Debug

Define ROBOT_ARM_DEBUG during compilation to enable internal RobotArm debug logs (see header comments).


← Previous | Next →

results matching ""

    No results matching ""