4.12 机器人示教运动
概述
Jogging 类提供机器人在示教模式下的点动控制接口,支持单轴步进、单轴连续点动、多轴联动及停止操作。
核心功能
- 支持机器人单轴步进示教运动
- 支持机器人单轴连续点动示教运动
- 支持机器人多轴连续示教运动
- 支持停止机器人连续示教运动
- 支持通过方向符号控制正向 / 反向点动
- 支持设置步进长度和旋转步进角度
使用场景
- 机器人调试和示教过程
- 位置微调和姿态修正
- 上位机远程手动调姿
- 机器人安装和校准
- 复杂轨迹执行前的定位确认
4.12.1 单轴步进示教运动
| 方法名 | Jogging.Move(int ajNum , MoveMode moveMode , double stepLength = 0, double stepAngle = 0) |
|---|---|
| 描述 | 控制机器人按设定步进量进行单轴示教运动( moveMode 取 MoveMode.Stepping ) |
| 请求参数 | ajNum : int 轴编号(1~6 对应当前坐标系各轴;笛卡尔坐标系下 x/y/z/rx/ry/rz 对应 1~6;数值正负表示运动方向) moveMode : MoveMode 运动模式,单轴步进场景固定为 MoveMode.Stepping stepLength : double 单次直线步进长度,单位 mm(步进模式下生效) stepAngle : double 单次旋转步进角度,单位 °(步进模式下生效) |
| 返回值 | StatusCode: 返回点动是否成功的状态码 |
| 兼容的机器人软件版本 | 协作 (Copper): v7.5.0.0+ 工业 (Bronze): v7.5.0.0+ |
示例代码
cs
using Agilebot.IR;
using Agilebot.IR.Types;
public class StepJogging
{
public static StatusCode Run(string controllerIP, bool useLocalProxy = true)
{
// [ZH] 初始化捷勃特机器人
// [EN] Initialize the Agilebot robot
Arm controller = new Arm(controllerIP, useLocalProxy);
// [ZH] 连接捷勃特机器人
// [EN] Connect to the Agilebot robot
StatusCode code = controller.ConnectSync();
Console.WriteLine(code != StatusCode.OK ? code.GetDescription() : "连接成功/Successfully connected.");
if (code != StatusCode.OK)
{
return code;
}
try
{
// [ZH] 获取机器人模式
// [EN] Get robot mode
(UserOpMode opMode, StatusCode opCode) = controller.GetOpMode();
if (opCode == StatusCode.OK)
{
Console.WriteLine($"当前机器人模式/Current robot mode: {opMode}");
if (opMode != UserOpMode.UNLIMITED_MANUAL && opMode != UserOpMode.LIMIT_MANUAL)
{
Console.WriteLine($"示教运动必须在机器人手动模式下/Jogging must be in manual mode");
return StatusCode.OtherReason;
}
}
else
{
Console.WriteLine($"获取机器人模式失败/Failed to get robot mode: {opCode.GetDescription()}");
}
// [ZH] 设置单步示教运动参数
// [EN] Set step jogging parameters
int ajNum = 1; // 轴序号,正数表示正方向运动
MoveMode moveMode = MoveMode.Stepping; // 单步运动模式
double stepLength = 5.0; // 步长,单位为mm或角度
double stepAngle = 5.0; // 轴旋转角度,单位为角度
Console.WriteLine("开始单步示教运动/Starting Step Jogging");
Console.WriteLine($"轴序号/Axis Number: {ajNum}");
Console.WriteLine($"运动模式/Move Mode: {moveMode}");
Console.WriteLine($"步长/Step Length: {stepLength}");
// [ZH] 执行单步示教运动
// [EN] Execute step jogging movement
code = controller.Jogging.Move(ajNum, moveMode, stepLength, stepAngle);
if (code == StatusCode.OK)
{
Console.WriteLine("单步示教运动执行成功/Step Jogging Executed Successfully");
Console.WriteLine(
$"轴{ajNum}向正方向移动{stepLength}单位/Axis {ajNum} moved {stepLength} units in positive direction"
);
}
else
{
Console.WriteLine($"单步示教运动执行失败/Step Jogging Execution Failed: {code.GetDescription()}");
}
// [ZH] 等待一秒后执行反向运动
// [EN] Wait one second then execute reverse movement
Thread.Sleep(1000);
// [ZH] 执行反向单步运动
// [EN] Execute reverse step movement
int reverseAjNum = -ajNum; // 负数表示负方向运动
code = controller.Jogging.Move(reverseAjNum, moveMode, stepLength, stepAngle);
if (code == StatusCode.OK)
{
Console.WriteLine("反向单步示教运动执行成功/Reverse Step Jogging Executed Successfully");
Console.WriteLine(
$"轴{Math.Abs(reverseAjNum)}向负方向移动{stepLength}单位/Axis {Math.Abs(reverseAjNum)} moved {stepLength} units in negative direction"
);
}
else
{
Console.WriteLine(
$"反向单步示教运动执行失败/Reverse Step Jogging Execution Failed: {code.GetDescription()}"
);
}
}
catch (Exception ex)
{
Console.WriteLine($"执行过程中发生异常/Exception occurred during execution: {ex.Message}");
code = StatusCode.OtherReason;
}
finally
{
// [ZH] 关闭连接
// [EN] Close the connection
StatusCode disconnectCode = controller.Disconnect();
if (disconnectCode != StatusCode.OK)
{
Console.WriteLine(disconnectCode.GetDescription());
if (code == StatusCode.OK)
code = disconnectCode;
}
}
return code;
}
}4.12.2 单轴连续点动示教运动
| 方法名 | Jogging.Move(int ajNum , MoveMode moveMode , double stepLength = 0, double stepAngle = 0) |
|---|---|
| 描述 | 控制机器人进行单轴连续点动示教运动( moveMode 取 MoveMode.Continuous ) |
| 请求参数 | ajNum : int 轴编号(1~6 对应当前坐标系各轴;笛卡尔坐标系下 x/y/z/rx/ry/rz 对应 1~6;数值正负表示运动方向) moveMode : MoveMode 运动模式,单轴连续点动场景固定为 MoveMode.Continuous stepLength : double 步长参数(连续模式下通常不使用) stepAngle : double 步角参数(连续模式下通常不使用) |
| 返回值 | StatusCode: 返回点动是否成功的状态码 |
| 兼容的机器人软件版本 | 协作 (Copper): v7.5.0.0+ 工业 (Bronze): v7.5.0.0+ |
示例代码
cs
using Agilebot.IR;
using Agilebot.IR.Types;
public class ContinuousJogging
{
public static StatusCode Run(string controllerIP, bool useLocalProxy = true)
{
// [ZH] 初始化捷勃特机器人
// [EN] Initialize the Agilebot robot
Arm controller = new Arm(controllerIP, useLocalProxy);
// [ZH] 连接捷勃特机器人
// [EN] Connect to the Agilebot robot
StatusCode code = controller.ConnectSync();
Console.WriteLine(code != StatusCode.OK ? code.GetDescription() : "连接成功/Successfully connected.");
if (code != StatusCode.OK)
{
return code;
}
try
{
// [ZH] 获取机器人模式
// [EN] Get robot mode
(UserOpMode opMode, StatusCode opCode) = controller.GetOpMode();
if (opCode == StatusCode.OK)
{
Console.WriteLine($"当前机器人模式/Current robot mode: {opMode}");
if (opMode != UserOpMode.UNLIMITED_MANUAL && opMode != UserOpMode.LIMIT_MANUAL)
{
Console.WriteLine($"示教运动必须在机器人手动模式下/Jogging must be in manual mode");
return StatusCode.OtherReason;
}
}
else
{
Console.WriteLine($"获取机器人模式失败/Failed to get robot mode: {opCode.GetDescription()}");
}
// [ZH] 设置示教运动参数
// [EN] Set jogging parameters
int ajNum = 3; // 轴序号,正数表示正方向运动
MoveMode moveMode = MoveMode.Continuous; // 连续运动模式
Console.WriteLine("开始连续示教运动/Starting Continuous Jogging");
Console.WriteLine($"轴序号/Axis Number: {ajNum}");
Console.WriteLine($"运动模式/Move Mode: {moveMode}");
// [ZH] 启动连续示教运动
// [EN] Start continuous jogging movement
code = controller.Jogging.Move(ajNum, moveMode);
if (code == StatusCode.OK)
{
Console.WriteLine("连续示教运动启动成功/Continuous Jogging Started Successfully");
Console.WriteLine("运动3秒后自动停止/Moving for 3 seconds then auto stop");
// [ZH] 运动3秒
// [EN] Move for 3 seconds
Thread.Sleep(3000);
// [ZH] 停止示教运动
// [EN] Stop jogging movement
controller.Jogging.Stop();
Console.WriteLine("示教运动已停止/Jogging Movement Stopped");
}
else
{
Console.WriteLine($"连续示教运动启动失败/Continuous Jogging Start Failed: {code.GetDescription()}");
}
}
catch (Exception ex)
{
Console.WriteLine($"执行过程中发生异常/Exception occurred during execution: {ex.Message}");
code = StatusCode.OtherReason;
}
finally
{
// [ZH] 关闭连接
// [EN] Close the connection
StatusCode disconnectCode = controller.Disconnect();
if (disconnectCode != StatusCode.OK)
{
Console.WriteLine(disconnectCode.GetDescription());
if (code == StatusCode.OK)
code = disconnectCode;
}
}
return code;
}
}4.12.3 多轴连续示教运动
| 方法名 | Jogging.MultiMove(int[] ajNums ) |
|---|---|
| 描述 | 控制机器人多轴同时进行连续示教运动 |
| 请求参数 | ajNums : int [] 轴编号列表(1~6 对应当前坐标系各轴;笛卡尔坐标系下 x/y/z/rx/ry/rz 对应 1~6;数值正负表示各轴运动方向) |
| 返回值 | StatusCode: 返回点动是否成功的状态码 |
| 兼容的机器人软件版本 | 协作 (Copper): v7.5.0.0+ 工业 (Bronze): v7.5.0.0+ |
示例代码
cs
using Agilebot.IR;
using Agilebot.IR.Jogging;
using Agilebot.IR.Types;
public class MultiJogging
{
public static StatusCode Run(string controllerIP, bool useLocalProxy = true)
{
// [ZH] 初始化捷勃特机器人
// [EN] Initialize the Agilebot robot
Arm controller = new Arm(controllerIP, useLocalProxy);
// [ZH] 连接捷勃特机器人
// [EN] Connect to the Agilebot robot
StatusCode code = controller.ConnectSync();
Console.WriteLine(code != StatusCode.OK ? code.GetDescription() : "连接成功/Successfully connected.");
if (code != StatusCode.OK)
{
return code;
}
try
{
// [ZH] 获取机器人模式
// [EN] Get robot mode
(UserOpMode opMode, StatusCode opCode) = controller.GetOpMode();
if (opCode == StatusCode.OK)
{
Console.WriteLine($"当前机器人模式/Current robot mode: {opMode}");
if (opMode != UserOpMode.UNLIMITED_MANUAL && opMode != UserOpMode.LIMIT_MANUAL)
{
Console.WriteLine($"示教运动必须在机器人手动模式下/Jogging must be in manual mode");
return StatusCode.OtherReason;
}
}
else
{
Console.WriteLine($"获取机器人模式失败/Failed to get robot mode: {opCode.GetDescription()}");
}
Console.WriteLine("开始多轴示教运动/Starting Multi-axis Jogging");
Console.WriteLine("演示多轴运动/Demo multi-axis step movements");
// [ZH] 多轴运动
// [EN] Multi-axis step movement
Console.WriteLine("\n=== 多轴运动/Multi-axis Step Movement ===");
int[] axes = { 1, 2, 3 }; // 正方向运动
code = controller.Jogging.MultiMove(axes);
if (code == StatusCode.OK)
{
Console.WriteLine("连续示教运动启动成功/Continuous Jogging Started Successfully");
Console.WriteLine("运动3秒后自动停止/Moving for 3 seconds then auto stop");
// [ZH] 运动3秒
// [EN] Move for 3 seconds
Thread.Sleep(3000);
// [ZH] 停止示教运动
// [EN] Stop jogging movement
controller.Jogging.Stop();
Console.WriteLine("示教运动已停止/Jogging Movement Stopped");
}
else
{
Console.WriteLine($"连续示教运动启动失败/Continuous Jogging Start Failed: {code.GetDescription()}");
}
Console.WriteLine("\n多轴示教运动完成/Multi-axis Jogging Completed");
}
catch (Exception ex)
{
Console.WriteLine($"执行过程中发生异常/Exception occurred during execution: {ex.Message}");
code = StatusCode.OtherReason;
}
finally
{
// [ZH] 关闭连接
// [EN] Close the connection
StatusCode disconnectCode = controller.Disconnect();
if (disconnectCode != StatusCode.OK)
{
Console.WriteLine(disconnectCode.GetDescription());
if (code == StatusCode.OK)
code = disconnectCode;
}
}
return code;
}
}4.12.4 停止机器人连续运动
| 方法名 | Jogging.Stop() |
|---|---|
| 描述 | 终止机器人当前示教点动(JOG)连续运动 |
| 请求参数 | 无 |
| 返回值 | void |
| 备注 | 仅在连续点动模式下需要调用此方法停止运动 |
| 兼容的机器人软件版本 | 协作 (Copper): v7.5.0.0+ 工业 (Bronze): v7.5.0.0+ |
示例代码
cs
using Agilebot.IR;
using Agilebot.IR.Types;
public class ContinuousJogging
{
public static StatusCode Run(string controllerIP, bool useLocalProxy = true)
{
// [ZH] 初始化捷勃特机器人
// [EN] Initialize the Agilebot robot
Arm controller = new Arm(controllerIP, useLocalProxy);
// [ZH] 连接捷勃特机器人
// [EN] Connect to the Agilebot robot
StatusCode code = controller.ConnectSync();
Console.WriteLine(code != StatusCode.OK ? code.GetDescription() : "连接成功/Successfully connected.");
if (code != StatusCode.OK)
{
return code;
}
try
{
// [ZH] 获取机器人模式
// [EN] Get robot mode
(UserOpMode opMode, StatusCode opCode) = controller.GetOpMode();
if (opCode == StatusCode.OK)
{
Console.WriteLine($"当前机器人模式/Current robot mode: {opMode}");
if (opMode != UserOpMode.UNLIMITED_MANUAL && opMode != UserOpMode.LIMIT_MANUAL)
{
Console.WriteLine($"示教运动必须在机器人手动模式下/Jogging must be in manual mode");
return StatusCode.OtherReason;
}
}
else
{
Console.WriteLine($"获取机器人模式失败/Failed to get robot mode: {opCode.GetDescription()}");
}
// [ZH] 设置示教运动参数
// [EN] Set jogging parameters
int ajNum = 3; // 轴序号,正数表示正方向运动
MoveMode moveMode = MoveMode.Continuous; // 连续运动模式
Console.WriteLine("开始连续示教运动/Starting Continuous Jogging");
Console.WriteLine($"轴序号/Axis Number: {ajNum}");
Console.WriteLine($"运动模式/Move Mode: {moveMode}");
// [ZH] 启动连续示教运动
// [EN] Start continuous jogging movement
code = controller.Jogging.Move(ajNum, moveMode);
if (code == StatusCode.OK)
{
Console.WriteLine("连续示教运动启动成功/Continuous Jogging Started Successfully");
Console.WriteLine("运动3秒后自动停止/Moving for 3 seconds then auto stop");
// [ZH] 运动3秒
// [EN] Move for 3 seconds
Thread.Sleep(3000);
// [ZH] 停止示教运动
// [EN] Stop jogging movement
controller.Jogging.Stop();
Console.WriteLine("示教运动已停止/Jogging Movement Stopped");
}
else
{
Console.WriteLine($"连续示教运动启动失败/Continuous Jogging Start Failed: {code.GetDescription()}");
}
}
catch (Exception ex)
{
Console.WriteLine($"执行过程中发生异常/Exception occurred during execution: {ex.Message}");
code = StatusCode.OtherReason;
}
finally
{
// [ZH] 关闭连接
// [EN] Close the connection
StatusCode disconnectCode = controller.Disconnect();
if (disconnectCode != StatusCode.OK)
{
Console.WriteLine(disconnectCode.GetDescription());
if (code == StatusCode.OK)
code = disconnectCode;
}
}
return code;
}
}