Coordinate Control (RobotArm)
Coordinate control means specifying the end-effector pose in the base coordinate system as [x, y, z, rx, ry, rz]: where x, y, z are positions (mm), and rx, ry, rz are orientations (°, Euler-angle semantics follow the controller implementation). This document is based on RobotArm (include/RobotArm.hpp), for MyCobotPro450, with Linux + TCP communication (see Environment Setup and Build).
All interfaces below follow the same format: Function, Return Value, Parameter Description, and Range. For the full API index, see API Reference.
Coordinate Component Ranges (MyCobotPro450)
| Axis id | Component | Range |
|---|---|---|
| 1 | x (mm) | -474 ~ 474 |
| 2 | y (mm) | -474 ~ 474 |
| 3 | z (mm) | -180 ~ 677 |
| 4 | rx (°) | -180 ~ 180 |
| 5 | ry (°) | -180 ~ 180 |
| 6 | rz (°) | -180 ~ 180 |
Speed sp / speed: 1 ~ 100 (same throughout this document).
Single Axis
int sendCoord(uint8_t axis, float coord, uint8_t sp)
- Function: Sends a target coordinate/orientation value for one axis.
- Return Value: Usually
1on success,-1on failure. - Parameter Description:
axisis 1~6 (mapping to x, y, z, rx, ry, rz);coordis the target value;spis speed level. - Range:
axis: 1 ~ 6;coord: see table above;sp: 1 ~ 100.
Six Axes
Coords getCoords()
- Function: Reads the current 6D pose [x, y, z, rx, ry, rz].
- Return Value:
Coords(std::array<float, 6>), index 0 ~ 5 maps to axis 1 ~ 6. - Parameter Description: None.
- Range: None.
int SendCoords(Coords coords, uint8_t sp)
- Function: Sends the full 6D pose in one command.
- Return Value: Usually
1on success,-1on failure. - Parameter Description:
coordssix components;spspeed level. - Range: Each component follows the axis ranges in the table above;
sp: 1 ~ 100.
Coordinate JOG
int jogCoord(uint8_t axis, uint8_t direction, uint8_t speed)
- Function: Continuously moves along a specified coordinate axis in one direction until a limit is reached or
stop()is called. - Return Value: Usually
1on success,-1on failure. - Parameter Description:
axis;direction;speed. - Range:
axis: 1 ~ 6;direction: 0 negative, 1 positive;speed: 1 ~ 100.
In-Position Check (Coordinate Target)
int isInPosition(Angles angle_coords, bool mode)
- Function: Checks whether the end-effector has reached a given 6D target. For coordinate mode, set the second argument to
true(the underlying type is stillstd::array<float, 6>for bothAngles/Coords). - Return Value:
1reached;0not reached;-1abnormal or no valid response. - Parameter Description:
angle_coordssix target values (here representing x, y, z, rx, ry, rz);mode. - Range: For coordinate checks, use
mode == true; component ranges are shown in this chapter's coordinate table.
Motion Stop (Used with JOG, etc.)
int stop()
- Function: Stops the current motion.
- Return Value: Usually
1on success,-1on failure. - Parameter Description: None.
- Range: None.
Example (Excerpt)
The example below demonstrates reading coordinates, sending a 6D pose, checking in-position status in coordinate mode, coordinate JOG, and stop. Ensure target points are within the robot workspace and the path is safe.
#include "RobotArm.hpp"
#include "config.hpp"
#include <iostream>
#include <thread>
#include <chrono>
using namespace std::chrono_literals;
int main() {
Param p;
p.ip_serial = "192.168.0.232";
p.port_baud = 4500;
RobotArm arm(TCP_COMM, p);
if (arm.powerOn() != 1) {
std::cerr << "powerOn failed\n";
return 1;
}
Coords cur = arm.getCoords();
std::cout << "x=" << cur[0] << " y=" << cur[1] << " z=" << cur[2] << "\n";
Coords goal = {200.f, 100.f, 250.f, 0.f, 0.f, 0.f}; // Set target based on current real robot pose
if (arm.SendCoords(goal, 30) != 1) {
std::cerr << "SendCoords failed\n";
}
while (arm.isInPosition(goal, true) != 1) {
cur = arm.getCoords();
std::cout << "x=" << cur[0] << " ...\n";
std::this_thread::sleep_for(200ms);
}
arm.jogCoord(1, 1, 30);
std::this_thread::sleep_for(2s);
arm.stop();
arm.powerOff();
return 0;
}