• 通讯文档
  • Sdk接口

›SDK接口

快速上手

  • 简介

SDK接口

  • Api_V4
  • Api_V6

Api_V4

  • V4源码发布包的结构
  • V4源码发布包的使用方法
  • RMAxis类功能实现简介
  • Config.h的配置自定义
  • 连接轴
  • 断开轴
  • 读取当前控制器版本
  • 读取物理IO口数量
  • 读取控制器可用逻辑IO信号
  • 操作逻辑IO信号
  • 操作逻辑IO信号对物理IO映射
  • 设置直接运动规划器参数
  • 移动到位置
  • 回原点
  • 绝对运动
  • 相对运动
  • 推压运动
  • 闭环推压运动
  • 等待运动完成
  • 是否在运动中
  • 是否运动到达
  • 是否推空
  • 设置指令
  • 读取指令
  • 执行指令
  • 触发指令
  • 读取指令
  • 保存指令
  • 读取当前位置
  • 读取当前速度
  • 读取当前电机出力
  • 读取当前力传感器读数
  • 读取错误状态代码
  • 重置错误
  • 开关伺服
  • 停止

V4源码发布包的结构

根目录结构

路径功能
/sdk_common/sdk本体的c++11源码
/sdk_c/sdk的c99接口导出
/sdk_csharp/sdk的c#接口导出, 基于clr类
/sdk_py/sdk的py接口导出
/sdk_node/sdk的node接口导出
/sdk_java/sdk的java接口导出, 基于jni接口
/sdk_语言接口/待添加的其他接口支持

Sdk功能介绍

文件功能
/sdk_common/libmodbus依赖的modbus通讯库, lgplv2协议
/sdk_common/Config控制器寄存器地址配置等, 如需修改点位指令占用等修改此文件
/sdk_common/Exception通讯等异常抛出实现, 如需自定义异常可修改此文件
/sdk_common/ModbusModbus通讯库的简易封装
/sdk_common/RMAxisRM轴动作的封装

V4源码发布包的使用方法

  1. c++用户, 可以直接把sdk_common文件夹下的源码直接全部引入到工程文件中去, 然后包含RMAxis.h头文件即可使用
  2. c用户可以用/sdk_c/文件夹下的cmake生成并编译一个动态库导出给c项目使用
  3. c#用户, 打开/sdk_csharp/sdk_csharp.vcxproj工程文件, 右键项目属性配置所需要使用的x86/x64还有.net framework版本等, 确认后编译, 即可在生成文件夹获得编译出来的Sdk库dll文件。 在要使用的sdk的项目中右键添加引用并选中生成的dll即可。
  4. python用户, 在sdk_py文件夹下执行 sudo python3 setup.py install , 即可触发setup_tool 的自动编译安装, 自动编译安装成功后在python3 repl环境下 直接键入 import motormaster 即可导入sdk包。
import motormaster
axis = motormaster.create_axis_modbus_rtu('/dev/ttyUSB0', 115200, 0')
print(axis.get_version()) 

C++用户需要注意编译器需要支持最低c++11标准。

Linux Python用户需要注意, 使用setup_tool, 需要确保build_essentials和cmake已经安装, windows用户同样需要确保msvc和cmake的安装。

RMAxis类功能实现简介

对RM控制器的控制主要依赖于

  1. 对IO线圈寄存器的操作(触发执行/停止等动作)
  2. 对保持寄存器的读写(位置/推力等数据)

以回原点的实现为例

void RMAxis::go_home()
{
    this->set_input_signal("go_home", false);
    std::this_thread::sleep_for(IO_GAP_TIME);
    this->set_input_signal("go_home", true);
}
  1. 设置输入io信号"go_home" 为低
  2. 等待IO_GAP_TIME, 约10ms 消抖时间
  3. 再次设置输入io信号"go_home" 为高, 以上升沿触发 执行回原点操作

以触发特定index的点位指令的实现为例

void RMAxis::trig_command(int index)
{
    this->set_parameter<int>("selected_command_index", index);
    this->set_input_signal("start", false);
    std::this_thread::sleep_for(IO_GAP_TIME);
    this->set_input_signal("start", true);
}
  1. 写入保持寄存器"selected_command_index" 为 要触发的指令序号
  2. 设置输入io信号"start" 为低
  3. 等待IO_GAP_TIME, 约10ms 消抖时间
  4. 再次设置输入io信号"start" 为高, 以上升沿触发 执行点位指令操作

Config.h的配置自定义

  1. IO消抖时间
#define IO_GAP_TIME 10ms

因RM控制器的IO寄存器存在和外部IO映射的关系, 一般情况下为10ms, 如遇到通讯无法触发IO或者在极高速通讯时IO读写无动作的情况可以适当改大该值范围在 10ms ~ 100ms之间。

  1. SDK指令占用的控制器点位指令槽
#define EXECUTE_COMMAND_INDEX 15
#define COMMAND_REACH_SIGNAL "reach_15"

SDK执行绝对运动/相对运动/推压运动等时占用的控制器点位表位置, 默认情况为点位表最后一位第15条指令, 并以第15条指令到位为到位信号, 如有特殊需求可以修改该位置范围0~15。

  1. SDK所使用的参数
inline void init_parameters(std::map<std::string, param_t>& params)
{
    params["current_command_position"] =        { PARAM_FLOAT, PARAM_NORMAL, 4902 };
    // ...
}

该函数会在sdk被初始化的时候调用, 并初始化参数表的地址。 params["参数名字"] = { 参数数据类型, 参数编辑级别, 参数地址 } 一般情况下无需对其做出改动, 如有变更需要联系技术售服协助修改。

连接轴

C
CPP
CSharp
Python
// 函数原型
rm_handle_t rm_create_modbus_rtu(const char* device, int baudrate, uint8_t slave_id);
rm_handle_t rm_create_modbus_tcp(const char* address, int port, uint8_t slave_id);

// 使用示例
rm_axis_handle handle = rm_create_modbus_rtu("\\\\.\\COM8", 115200, 0);
rm_axis_handle handle = rm_create_modbus_tcp("192.168.0.233", 502, 0);
// 函数原型
static RMAxis* create_rmaxis_modbus_rtu(std::string device, int baudrate, uint8_t slave_id);
static RMAxis* create_rmaxis_modbus_tcp(std::string address, int port, uint8_t slave_id);

// 使用示例
auto axis = RMAxis::create_rmaxis_modbus_rtu("\\\\.\\COM8", 115200, 0);
auto axis = RMAxis::create_rmaxis_modbus_tcp("192.168.0.233", 502, 0);
// 函数原型
public static Axis CreateModbusRtu(string device, int baudrate, ushort slave_id);
public static Axis CreateModbusTcp(string address, int port, ushort slave_id);

// 使用示例
var axis = Axis.CreateModbusRtu("\\\\.\\COM8", 115200, 0);
var axis = Axis.CreateModbusTcp("192.168.0.233", 502, 0);
## 函数原型
def create_axis_modbus_rtu(device, baudrate, axis_no):
def create_axis_modbus_tcp(address, port, slave_id):

## 使用示例
axis = sdk.create_axis_modbus_rtu('\\\\.\\COM8', 115200, 0)
axis = sdk.create_axis_modbus_tcp('192.168.0.233', 502, 0)
变量描述
device串口设备 \\.\COM8 或 /dev/ttyS0 等
baudrate波特率
slave_id站号
变量描述
addressip地址
port端口
slave_id站号

连接到指定设备上的控制器。

断开轴

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_destroy(rm_axis_t axis);

// 使用示例
rm_destroy(axis);
// 函数原型
void destroy_rmaxis(IRMAxis* axis);

// 使用示例
destroy_rmaxis(axis);
// 函数原型
public static void Destroy(RMAxis axis)

// 使用示例
Sdk.Destroy(axis)
;
## 函数原型
def destroy(axis):

## 使用示例
axis.close()
// 使用示例
delete axis;

断开连接的轴

读取当前控制器版本

C
CPP
CSharp
Python
Javascript
// 函数原型
typedef struct {
int32_t major;
int32_t minor;
int32_t build;
int32_t type;
} version_t;

version_t rm_get_version(rm_axis_t handle);

// 使用示例
version_t version = rm_get_version(handle);
// 函数原型
typedef struct {
int32_t major;
int32_t minor;
int32_t build;
int32_t type;
} version_t;

virtual version_t get_version() = 0;

// 使用示例
auto version = axis.get_version();
// 函数原型
public struct version_t
{
public int major;
public int minor;
public int build;
public int type;
}

public Native.version_t Version {get;}

// 使用示例
var version = axis.Version;
## 函数原型
class Version(ctypes.Structure):
_fields_ = [('major', ctypes.c_int),
('minor', ctypes.c_int),
('build', ctypes.c_int),
('type', ctypes.c_int)]

def get_version(self):

## 使用示例
version = axis.get_version()
// 函数原型
interface version_t
{
major: number;
minor: number;
build: number;
type: number;
}

get_version : () => version_t;

// 使用示例
var version = axis.get_version()

读取当前控制器版本,用于进一步调试或诊断异常。

IO功能控制

控制器IO分为 逻辑IO信号 和 物理IO信号。 逻辑IO信号 指控制器内部的信号,可通过通讯的方式进行操作来执行对应的功能。 物理IO信号 指控制器上实际引出的IO口信号, 如分体式RM-C控制器上存在的16个输入和16个输出口。 物理IO口单独无法执行任何功能, 必须把 内部的逻辑IO信号映射到物理IO信号后才能进行触发操作。

读取物理IO口数量

C
CPP
CSharp
Javascript
// 函数原型
int rm_get_input_count(rm_axis_t handle);
int rm_get_output_count(rm_axis_t handle);
// 函数原型
int get_input_count() = 0;
int get_output_count() = 0;
// 函数原型
public int InputCount{get;}
public int OutputCount{get;}
// 函数原型
get_input_count : () => void;
get_output_count : () => void;

读取控制器物理IO口的数量。

读取控制器可用逻辑IO信号

C
CPP
CSharp
Javascript
// 函数原型
int rm_list_input_signal(rm_axis_t handle, char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE]);
int rm_list_output_signal(rm_axis_t handle, char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE]);

// 使用示例
char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE] = {0};
int signal_count = rm_list_input_signal(handle, signal_out);
for(int i=0; i<signal_count; i++)
printf(signal_out[i]);
// 函数原型
int list_input_signal(char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE]) = 0;
int list_output_signal(char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE]) = 0;

// 使用示例
char signal_out[MAX_ARRAY_SIZE][MAX_STRING_SIZE] = {0};
int signal_count = axis.list_input_signal(handle, signal_out);
for(int i=0; i<signal_count; i++)
printf(signal_out[i]);
// 函数原型
public List<string> InputSignal{get;}
public List<string> OutputSignal{get;}
// 函数原型
list_input_signal : () => Array<string>;
list_output_signal : () => Array<string>;
变量描述
handle轴句柄
signal_out逻辑IO信号名称
返回值逻辑IO信号数量

读取当前控制器可用逻辑IO信号。

操作逻辑IO信号

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_set_input_signal(rm_axis_t handle, const char* signal, bool level);
bool rm_get_input_signal(rm_axis_t handle, const char* signal);
bool rm_get_output_signal(rm_axis_t handle, const char* signal);
// 函数原型
void set_input_signal(const char* signal, bool level) = 0;
bool get_input_signal(const char* signal) = 0;
bool get_output_signal(const char* signal) = 0;
// 函数原型
public void SetInputSignal(string signal, bool level);
public bool GetInputSignal(string signal);
public bool GetOutputSignal(string signal);
## 函数原型
def set_input_signal(self, signal, level):
def get_input_signal(self, signal):
def get_output_signal(self, signal):
// 函数原型
set_input_signal : (signal : string, level : boolean) => void;
get_input_signal : (signal : string) => boolean;
get_output_signal : (signal : string) => boolean;
变量描述
handle轴句柄
signal逻辑IO信号名称
返回值逻辑IO信号状态

读写当前控制器逻辑IO信号状态。

操作逻辑IO信号对物理IO映射

C
CPP
CSharp
Javascript
// 函数原型
const char* rm_get_map_input(rm_axis_t handle, int port);
const char* rm_get_map_output(rm_axis_t handle, int port);
void rm_set_map_input(rm_axis_t handle, const char* signal, int port);
void rm_set_map_output(rm_axis_t handle, const char* signal, int port);
// 函数原型
virtual const char* get_map_input(int port) = 0;
virtual const char* get_map_output(int port) = 0;
virtual void set_map_input(const char* signal, int port) = 0;
virtual void set_map_output(const char* signal, int port) = 0;
// 函数原型
public string GetInputMap(int port);
public string GetOutputMap(int port);
public void SetInputMap(string signal, int port);
public void SetOutputMap(string signal, int port);
// 函数原型
get_map_input : (port : number) => string;
get_map_output : (port : number) => string;
set_map_input : (signal: string, port: number) => void;
set_map_output : (signal: string, port: number) => void;
变量描述
handle轴句柄
port物理IO端口序号
signal逻辑IO信号名称
返回值逻辑IO信号名称

读写当前控制器物理IO映射信号。

通用运动控制

常用运动控制指令,如不需要进行复杂指令执行,只需要使用以下api指令即可完成大部分操作。

设置直接运动规划器参数

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_config_motion(rm_axis_handle handle, float velocity, float acceleration, float deacceleration);

// 使用示例
rm_config_motion(axis, 100.f, 500.f, 500.f);
// 函数原型
virtual void config_motion(float velocity, float acceleration, float deacceleration) = 0;

// 使用示例
axis.config_motion(100.f, 500.f, 500.f);
// 函数原型
void ConfigMotion(float velocity, float acceleration, float deacceleration);

// 使用示例
axis.ConfigMotion(100, 500, 500)
## 函数原型
def config_motion(self, velocity, acceleration, deacceleration):

## 使用示例
axis.config_motion(100, 3000, 3000)
// 函数原型
config_motion : (velocity: number, acceleration: number, deacceleration: number) => void;

// 使用示例
axis.config_motion(100, 3000, 3000)
变量描述
handle轴句柄
velocity速度 mm/s
acceleration加速度 mm/s^2
deacceleration减速度 mm/s^2

设置直接运动时规划器的速度,加速度和减速度和移动到位置配合使用。

移动到位置

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_move_to(rm_axis_t handle, float position);

// 使用示例
rm_move_to(axis, 10.f);
// 函数原型
virtual void move_to(float position) = 0;

// 使用示例
axis.move_to(10.f);
// 函数原型
public void MoveTo(float position);

// 使用示例
axis.MoveTo(10)
## 函数原型
def move_to(self, position):

## 使用示例
axis.move_to(10)
// 函数原型
move_to : (position: number) => void;

## 使用示例
axis.move_to(10)
变量描述
handle轴句柄
position位置 mm

设置直接运动时规划器的目标位置和设置直接运动规划器参数配合使用。

回原点

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_go_home(rm_axis_handle handle);

// 使用示例
rm_go_home(axis);
// 函数原型
virtual void go_home() = 0;

// 使用示例
axis.go_home();
// 函数原型
void GoHome();

// 使用示例
axis.GoHome();
## 函数原型
def go_home(self):

## 使用示例
axis.go_home()
// 函数原型
go_home : () => void;

## 使用示例
axis.go_home()
变量描述
handle轴句柄

触发轴回原点, 如果没有设置 自动回原点 的话 每次上电后只需要触发执行一次就行 可以通过读取逻辑信号 "gone_home" 来判断是否执行完成

绝对运动

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_move_absolute(rm_axis_handle handle, float position, float velocity, float acceleration, float deacceleration, float band);

// 使用示例
rm_move_absolute(axis, 10.f, 100.f, 3000.f, 3000.f, 0.1f);
// 函数原型
virtual void move_absolute(
float position, float velocity,
float acceleration, float deacceleration, float band)
= 0;

// 使用示例
axis.move_absolute(10.f, 100.f, 3000.f, 3000.f, 0.1f);
// 函数原型
void MoveAbsolute(float position, float velocity, float acceleration, float deacceleration, float band);

// 使用示例
axis.MoveAbsolute(10, 100, 3000, 3000, 0.1)
## 函数原型
def move_absolute(self, position, velocity, acceleration, deacceleration, band):

## 使用示例
axis.move_absolute(10, 100, 3000, 3000, 0.1)
// 函数原型
move_absolute : (
position: number, velocity: number,
acceleration: number, deacceleration: number, band: number) => void;

// 使用示例
axis.move_absolute(10, 100, 3000, 3000, 0.1)
变量描述
handle轴句柄
position位置 mm
velocity速度 mm/s
acceleration加速度 mm/s^2
deacceleration减速度 mm/s^2
band定位范围 mm

以设定速度加速度绝对运动到给定位置。

相对运动

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_move_relative(rm_axis_handle handle, float position, float velocity, float acceleration, float deacceleration, float band);

// 使用示例
rm_move_relative(axis, 10.f, 100.f, 3000.f, 3000.f, 0.1f);
// 函数原型
virtual void move_relative(
float position, float velocity,
float acceleration, float deacceleration, float band)
= 0;

// 使用示例
axis.move_relative(10.f, 100.f, 3000.f, 3000.f, 0.1f);
// 函数原型
void MoveRelative(float position, float velocity, float acceleration, float deacceleration, float band);

// 使用示例
axis.MoveRelative(10, 100, 3000, 3000, 0.1)
## 函数原型
def move_relative(self, position, velocity, acceleration, deacceleration, band):

## 使用示例
axis.move_relative(10, 100, 3000, 3000, 0.1)
// 函数原型
move_relative : (
position: number, velocity: number,
acceleration: number, deacceleration: number, band: number) => void;

// 使用示例
axis.move_relative(10, 100, 3000, 3000, 0.1)
变量描述
handle轴句柄
position位置 mm
velocity速度 mm/s
acceleration加速度 mm/s^2
deacceleration减速度 mm/s^2
band定位范围 mm

以设定速度加速度绝对运动到给定位置。

推压运动

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_push(rm_axis_handle handle, float force, float distance, float velocity);

// 使用示例
rm_push(axis, 50.f, 5.f, 20.f);
// 函数原型
virtual void push(
float force,
float distance, float velocity)
= 0;

// 使用示例
axis.push(50.f, 5.f, 20.f);
// 函数原型
void Push(float force, float distance, float velocity);

// 使用示例
axis.Push(50, 5, 20);
## 函数原型
def push(self, force, distance, velocity):

## 使用示例
axis.push(50, 5, 20)
// 函数原型
push : (
force: number,
distance: number, velocity: number) => void;

// 使用示例
axis.push(50, 5, 20)
变量描述
handle轴句柄
force出力 %
distance距离 mm
velocity速度 mm/s

以设定速度和出力推压到指定距离

闭环推压运动

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_precise_push(
rm_axis_t handle,
float force,
float distance, float velocity,
float force_band, uint32_t force_check_time)
;

// 使用示例
rm_precise_push(axis, 5.f, 5.f, 5.f, 0.1f, 50);
// 函数原型
virtual void precise_push(
float force,
float distance, float velocity,
float force_band, uint32_t force_check_time)
= 0;

// 使用示例
axis.precise_push(5.f, 5.f, 5.f, 0.1f, 50);
// 函数原型
public void PrecisePush(
float force,
float distance, float velocity,
float force_band, uint force_check_time
)
;

// 使用示例
axis.PrecisePush(5, 5, 5, 0.1, 50);
## 函数原型
def precise_push(self, force, distance, velocity, force_band, force_check_time):

## 使用示例
axis.precise_push(5, 5, 5, 0.1, 50)
// 函数原型
precise_push : (
force: number,
distance: number, velocity: number,
force_band: number, force_check_time: number) => void;

// 使用示例
axis.precise_push(5, 5, 5, 0.1, 50)
变量描述
handle轴句柄
force出力 N
distance距离 mm
velocity速度 mm/s
force_band力定位范围 N
force_check_time力定位时间 ms

以设定速度和出力推压到指定距离

等待运动完成

C
CPP
CSharp
Python
Javascript
// 函数原型
bool rm_wait_complete(rm_axis_t handle, uint32_t timeout_ms);
// 函数原型
virtual bool wait_complete(uint32_t timeout_ms) = 0;
// 函数原型
public bool WaitComplete(uint timeout_ms);
## 函数原型
def wait_complete(self, timeout_ms):
// 函数原型
wait_complete : (timeout_ms: number) => boolean;
变量描述
handle轴句柄
timeout等待超时时间 ms
返回值是否超时

等待运动完成,如果超时还未完成函数将返回,并将返回值设置成true,意为运动未完成但等待已经超时。

是否在运动中

C
CPP
CSharp
Python
Javascript
// 函数原型
bool rm_is_moving(rm_axis_handle handle);

// 使用示例
bool moving = rm_is_moving(axis);
// 函数原型
virtual bool is_moving() = 0;

// 使用示例
bool moving = axis.is_moving();
// 函数原型
bool IsMoving();

// 使用示例
bool moving = axis.IsMoving();
## 函数原型
def is_moving(self):

## 使用示例
moving = axis.is_moving()
// 函数原型
is_moving : () => boolean;

// 使用示例
var moving = axis.is_moving()
变量描述
handle轴句柄
返回值是否在运动

检查轴是否在运动

是否运动到达

C
CPP
CSharp
Python
Javascript
// 函数原型
bool rm_is_reached(rm_axis_handle handle);

// 使用示例
bool reached = rm_is_reached(axis);
// 函数原型
virtual bool is_reached() = 0;

// 使用示例
bool reached = axis.is_reached();
// 函数原型
bool IsReached();

// 使用示例
bool reached = axis.IsReached();
## 函数原型
def is_reached(self):

## 使用示例
reached = axis.is_reached()
// 函数原型
is_reached : () => boolean;

// 使用示例
var reached = axis.is_reached()
变量描述
handle轴句柄
返回值是否运动到达

检查轴是否到达运动目标

是否推空

C
CPP
CSharp
Python
Javascript
// 函数原型
bool rm_is_push_empty(rm_axis_handle handle);

// 使用示例
bool empty = rm_is_push_empty(axis);
// 函数原型
virtual bool is_push_empty() = 0;

// 使用示例
bool empty = axis.is_push_empty();
// 函数原型
bool IsPushEmpty();

// 使用示例
bool empty = axis.IsPushEmpty();
## 函数原型
def is_push_empty(self):

## 使用示例
empty = axis.is_push_empty()
// 函数原型
is_push_empty : () => boolean;

// 使用示例
var empty = axis.is_push_empty()
变量描述
handle轴句柄
返回值是否推空

检查轴推压运动是否推空, 可以在推压运动完成后用这来检测是否推压/夹持空。

指令

C/CPP
CSharp
Python
Javascript
typedef enum {
COMMAND_NONE = 0,
COMMAND_GO_HOME = 1,
COMMAND_DELAY = 2,
COMMAND_MOVE_ABSOLUTE = 3,
COMMAND_PUSH = 4,
COMMAND_MOVE_RELATIVE = 5,
COMMAND_PRECISE_PUSH = 6
} command_type_t;

typedef struct {
command_type_t type;
float position;
float velocity;
float acceleration;
float deacceleration;
float band;
float push_force;
float push_distance;
int32_t delay;
int32_t next_command_index;
} command_t;
public enum MOTION_COMMAND : uint
{
NONE = 0,
GO_HOME = 1,
DELAY = 2,
MOVE_ABSOLUTE = 3,
PUSH = 4,
MOVE_RELATIVE = 5,
CLOSE_LOOP_PUSH = 6
};

[StructLayout(LayoutKind.Sequential)]
public struct motion_command_t
{
public MOTION_COMMAND type;
public float position;
public float velocity;
public float acceleration;
public float deacceleration;
public float tolerance;
public float push_force;
public float push_distance;
public int delay;
public int next_command_index;
}

class Command(ctypes.Structure):
_fields_ = [('type', ctypes.c_int),
('position', ctypes.c_float),
('velocity', ctypes.c_float),
('acceleration', ctypes.c_float),
('deacceleration', ctypes.c_float),
('tolerance', ctypes.c_float),
('push_force', ctypes.c_float),
('push_distance', ctypes.c_float),
('delay', ctypes.c_float),
('next_command_index', ctypes.c_int)]
interface command_t
{
type : "none" | "move_abs" | "move_rel" | "push" | "delay" | "closed_loop_push";
position: number;
velocity: number;
acceleration: number;
deacceleration: number;
band: number;
push_force: number;
push_distance: number;
delay: number;
next_command_index: number;
}
指令结构体

设置指令

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_set_command(rm_axis_handle handle, int32_t index, command_t command);

// 使用示例
rm_set_command(axis,0, command);
// 函数原型
virtual void set_command(int index, command_t command) = 0;

// 使用示例
axis.set_command(axis,0, command);
// 函数原型
void SetCommand(int index, Native.motion_command_t command);

// 使用示例
axis.SetCommand(0, command);
## 函数原型
def set_command(self, index, command):

## 使用示例
axis.set_command(0, command)
// 函数原型
set_command : (index: number, command: command_t) => void;

// 使用示例
axis.set_command(0, command)
变量描述
handle轴句柄
index指令序号
command指令

设置指定序号的指令

读取指令

C
CPP
CSharp
Python
Javascript
// 函数原型
command_t rm_get_command(rm_axis_t handle, int index);

// 使用示例
command_t command = rm_get_command(axis, 0);
// 函数原型
virtual command_t get_command(int index) = 0;

// 使用示例
auto command = axis.get_command(0);
// 函数原型
Native.motion_command_t GetCommand(int index);

// 使用示例
var command = axis.GetCommand(0);
## 函数原型
def get_command(self, index):

## 使用示例
command = axis.get_command(0)
// 函数原型
get_command : (index: number) => command_t;

// 使用示例
var command = axis.get_command(0)
变量描述
handle轴句柄
index指令序号

读取指定序号的指令

执行指令

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_execute_command(rm_axis_handle handle, motion_command_t command);

// 使用示例
rm_execute_command(axis, command);
// 函数原型
virtual void execute_command(command_t command) = 0;

// 使用示例
axis.execute_command(command);
// 函数原型
void ExecuteCommand(Native.motion_command_t command);

// 使用示例
axis.ExecuteCommand(command);
## 函数原型
def execute_command(self, command):

## 使用示例
axis.execute_command(command)
// 函数原型
execute_command : (command: command_t) => void;

// 使用示例
axis.execute_command(command)
变量描述
handle轴句柄
command指令

触发执行指定指令

触发指令

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_trig_command(rm_axis_handle handle, int32_t index);

// 使用示例
rm_trig_command(axis, 0);
// 函数原型
virtual void trig_command(int index) = 0;

// 使用示例
axis.trig_command(0);
// 函数原型
void TrigCommand(int index);

// 使用示例
axis.TrigCommand(0);
## 函数原型
def trig_command(self, index):

## 使用示例
axis.trig_command(0)
// 函数原型
trig_command : (index: number) => void;

// 使用示例
axis.trig_command(0)
变量描述
handle轴句柄
index指令序号

触发执行指定序号的指令

读取指令

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_load_commands(rm_axis_t handle);

// 使用示例
rm_load_commands(axis);
// 函数原型
virtual void load_commands() = 0;

// 使用示例
axis.load_commands();
// 函数原型
void LoadCommands()

// 使用示例
axis.LoadCommands()
;
## 函数原型
def load_commands(self):

## 使用示例
axis.load_commands()
// 函数原型
load_commands : () => void;

// 使用示例
axis.load_commands()
变量描述
handle轴句柄

读取指令表

保存指令

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_save_commands(rm_axis_t handle);

// 使用示例
rm_save_commands(axis);
// 函数原型
virtual void save_commands() = 0;

// 使用示例
axis.save_commands();
// 函数原型
void SaveCommands();

// 使用示例
axis.SaveCommands();
## 函数原型
def save_commands(self):

## 使用示例
axis.save_commands()
// 函数原型
save_commands : () => void;

// 使用示例
axis.save_commands()
变量描述
handle轴句柄

保存指令表

状态

读取当前位置

C
CPP
CSharp
Python
Javascript
// 函数原型
float rm_position(rm_axis_t handle);

// 使用示例
float position = rm_position(axis);
// 函数原型
virtual float position() = 0;

// 使用示例
float position = axis.position();
// 函数原型
public float Position{get;}

// 使用示例
var position = axis.Position;
## 函数原型
def position(self):

## 使用示例
position = axis.position()
// 函数原型
position : () => number;

// 使用示例
position = axis.position()
变量描述
handle轴句柄
返回值位置 mm

读取当前位置

读取当前速度

C
CPP
CSharp
Python
Javascript
// 函数原型
float rm_velocity(rm_axis_t handle);

// 使用示例
float velocity = rm_velocity(axis);
// 函数原型
virtual float velocity() = 0;

// 使用示例
float velocity = axis.velocity();
// 函数原型
public float Velocity{get;}

// 使用示例
var velocity = axis.Velocity;
## 函数原型
def velocity(self):

## 使用示例
velocity = axis.velocity()
// 函数原型
velocity : () => number;

// 使用示例
velocity = axis.velocity()
变量描述
handle轴句柄
返回值速度 mm/s

读取当前速度

读取当前电机出力

C
CPP
CSharp
Python
Javascript
// 函数原型
float rm_torque(rm_axis_t handle);

// 使用示例
float torque = rm_torque(axis);
// 函数原型
virtual float torque() = 0;

// 使用示例
float torque = axis.torque();
// 函数原型
public float Torque{get;}

// 使用示例
var torque = axis.Torque;
## 函数原型
def torque(self):

## 使用示例
torque = axis.torque()
// 函数原型
torque : () => number;

// 使用示例
torque = axis.torque()
变量描述
handle轴句柄
返回值出力%

读取当前电机出力

读取当前力传感器读数

C
CPP
CSharp
Python
Javascript
// 函数原型
float rm_force_sensor(rm_axis_t handle);

// 使用示例
float force = rm_force_sensor(axis);
// 函数原型
virtual float force_sensor() = 0;

// 使用示例
float force = axis.force_sensor();
// 函数原型
public float ForceSensor{get;}

// 使用示例
var force = axis.ForceSensor;
## 函数原型
def force_sensor(self):

## 使用示例
force = axis.force_sensor()
// 函数原型
force_sensor : () => number;

// 使用示例
force = axis.force_sensor()
变量描述
handle轴句柄
返回值出力%

读取当前电机出力

读取错误状态代码

C
CPP
CSharp
Python
Javascript
// 函数原型
uint32_t rm_error_code(rm_axis_t handle);

// 使用示例
uint32_t error = rm_error_code(axis);
// 函数原型
virtual uint32_t error_code() = 0;

// 使用示例
uint32_t error = axis.error_code(axis);
// 函数原型
public uint ErrorCode{get;}

// 使用示例
var error = axis.ErrorCode;
## 函数原型
def error_code(self):

## 使用示例
error = axis.error_code()
// 函数原型
error_code : () => number;

// 使用示例
error = axis.error_code()
变量描述
handle轴句柄
返回值当前错误状态代码

读取当前错误状态代码

错误代码描述
0正常
1通用错误
2电机失相
3位置超差
4速度超差
5电机堵转
6初相励磁错误

重置错误

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_reset_error(rm_axis_t handle);

// 使用示例
rm_reset_error(axis);
// 函数原型
virtual void reset_error() = 0;

// 使用示例
axis.reset_error();
// 函数原型
void ResetError()

// 使用示例
axis.ResetError()
;
## 函数原型
def reset_error(self):

## 使用示例
axis.reset_error()
// 函数原型
reset_error : () => void;

// 使用示例
axis.reset_error()
变量描述
handle轴句柄

重置控制器错误状态

开关伺服

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_set_servo_on_off(rm_axis_t handle, bool on_off);
bool rm_get_servo_on_off(rm_axis_t handle);

// 使用示例
rm_set_servo_on_off(axis, false);
// 函数原型
virtual void set_servo_on_off(bool on_off) = 0;
virtual bool get_servo_on_off() = 0;

// 使用示例
axis.set_servo_on_off(false);
// 函数原型
public bool ServoOnOff{get; set;}

// 使用示例
axis.ServoOnOff = false;
## 函数原型
def set_servo_on_off(self,on_off):

## 使用示例
axis.set_servo_on_off(False)
// 函数原型
set_servo_on_off : (on_off: boolean) => void;
get_servo_on_off : () => boolean;

// 使用示例
axis.set_servo_on_off(false)
变量描述
handle轴句柄
on_off伺服开关信号

设置伺服开关信号

停止

C
CPP
CSharp
Python
Javascript
// 函数原型
void rm_stop(rm_axis_t handle);

// 使用示例
rm_stop(axis);
// 函数原型
virtual void stop() = 0;

// 使用示例
axis.stop();
// 函数原型
public void Stop()

// 使用示例
axis.Stop()
;
## 函数原型
def stop(self):

## 使用示例
axis.stop()
// 函数原型
stop : () => void;

// 使用示例
axis.stop()
变量描述
handle轴句柄

停止轴运动

Last updated on 2024/5/10
← 简介Api_V6 →
  • IO功能控制
    • 读取物理IO口数量
    • 读取控制器可用逻辑IO信号
    • 操作逻辑IO信号
    • 操作逻辑IO信号对物理IO映射
  • 通用运动控制
    • 设置直接运动规划器参数
    • 移动到位置
    • 回原点
    • 绝对运动
    • 相对运动
    • 推压运动
    • 闭环推压运动
    • 等待运动完成
    • 是否在运动中
    • 是否运动到达
    • 是否推空
  • 指令
    • 设置指令
    • 读取指令
    • 执行指令
    • 触发指令
    • 读取指令
    • 保存指令
  • 状态
    • 读取当前位置
    • 读取当前速度
    • 读取当前电机出力
    • 读取当前力传感器读数
    • 读取错误状态代码
    • 重置错误
    • 开关伺服
    • 停止
开发资料
通讯参数Sdk接口常见问题更新日志
更多
产品资料微信公众号技术支持
Copyright © 2025 佛山市增广智能科技有限公司
备案/许可证号:粤ICP备19021060号