You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1065 lines
52 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. using jkType;
  6. namespace HBLConsole.Communication
  7. {
  8. delegate void CallBackFuncType(int error_code);
  9. class jakaAPI
  10. {
  11. /// <summary>
  12. /// 获取版本控制器的Ip
  13. /// </summary>
  14. /// <param name="controller_name"></param>
  15. /// <param name="ip"></param>
  16. /// <returns></returns>
  17. [DllImport("jakaAPI.dll", EntryPoint = "get_controller_ip", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  18. public static extern int get_controller_ip(char[] controller_name, ref byte ip);
  19. /// <summary>
  20. /// 创建机器人控制句柄
  21. /// </summary>
  22. /// <param name="ip"></param>
  23. /// <param name="handle"></param>
  24. /// <returns></returns>
  25. [DllImport("jakaAPI.dll", EntryPoint = "create_handler", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  26. public static extern int create_handler(char[] ip, ref int handle);
  27. /// <summary>
  28. /// 断开机器人控制句柄
  29. /// </summary>
  30. /// <param name="handle"></param>
  31. /// <returns></returns>
  32. [DllImport("jakaAPI.dll", EntryPoint = "destory_handler", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  33. public static extern int destory_handler(ref int handle);
  34. /// <summary>
  35. /// 打开机器人电源
  36. /// </summary>
  37. /// <param name="handle">机器人控制句柄</param>
  38. /// <returns>ERR_SUCC 成功 其他失败</returns>
  39. [DllImport("jakaAPI.dll", EntryPoint = "power_on", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  40. public static extern int power_on(ref int handle);
  41. /// <summary>
  42. /// 关闭机器人电源
  43. /// </summary>
  44. /// <param name="handle">机器人控制句柄</param>
  45. /// <returns>ERR_SUCC 成功 其他失败</returns>
  46. [DllImport("jakaAPI.dll", EntryPoint = "power_off", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  47. public static extern int power_off(ref int handle);
  48. /// <summary>
  49. /// 机器人控制柜关机
  50. /// </summary>
  51. /// <param name="handle"></param>
  52. /// <returns>ERR_SUCC 成功 其他失败</returns>
  53. [DllImport("jakaAPI.dll", EntryPoint = "shut_down", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  54. public static extern int shut_down(ref int handle);
  55. /// <summary>
  56. /// 控制机器人上使能
  57. /// </summary>
  58. /// <param name="handle"></param>
  59. /// <returns></returns>
  60. [DllImport("jakaAPI.dll", EntryPoint = "enable_robot", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  61. public static extern int enable_robot(ref int handle);
  62. /// <summary>
  63. /// 控制机器人下使能
  64. /// </summary>
  65. /// <param name="handle"></param>
  66. /// <returns></returns>
  67. [DllImport("jakaAPI.dll", EntryPoint = "disable_robot", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  68. public static extern int disable_robot(ref int handle);
  69. /// <summary>
  70. /// 控制机器人手动模式下运动
  71. /// </summary>
  72. /// <param name="handle"></param>
  73. /// <param name="aj_num">标识值,在关节空间下代表关节号0-5,笛卡尔下依次为x,y,z,rx,ry,rz</param>
  74. /// <param name="move_mode">机器人运动模式,增量运动或者连续运动</param>
  75. /// <param name="coord_type">机器人运动坐标系,工具坐标系,基坐标系(当前的世界/用户坐标系)或关节空间</param>
  76. /// <param name="vel_cmd">指令速度,旋转轴或关节运动单位为rad/s,移动轴单位为mm/s</param>
  77. /// <param name="pos_cmd">指令位置,旋转轴或关节运动单位为rad,移动轴单位为mm</param>
  78. /// <returns></returns>
  79. [DllImport("jakaAPI.dll", EntryPoint = "jog", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  80. public static extern int jog(ref int handle, int aj_num, JKTYPE.MoveMode move_mode, JKTYPE.CoordType coord_type, double vel_cmd, double pos_cmd);
  81. /// <summary>
  82. /// 控制机器人手动模式下运动停止
  83. /// </summary>
  84. /// <param name="handle"></param>
  85. /// <param name="num"></param>
  86. /// <returns></returns>
  87. [DllImport("jakaAPI.dll", EntryPoint = "jog_stop", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  88. public static extern int jog_stop(ref int handle, ref int num);
  89. /// <summary>
  90. /// 机器人关节运动
  91. /// </summary>
  92. /// <param name="handle"></param>
  93. /// <param name="joint_pos">机器人关节运动目标位置</param>
  94. /// <param name="move_mode">指定运动模式:增量运动(相对运动)或绝对运动</param>
  95. /// <param name="is_block">设置接口是否为阻塞接口,TRUE为阻塞接口 FALSE为非阻塞接口</param>
  96. /// <param name="speed">机器人关节运动速度,单位:rad/s</param>
  97. /// <returns></returns>
  98. [DllImport("jakaAPI.dll", EntryPoint = "joint_move", ExactSpelling = false, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
  99. public static extern int joint_move(ref int handle, ref JKTYPE.JointValue joint_pos, JKTYPE.MoveMode move_mode, bool is_block, double speed);
  100. /// <summary>
  101. /// 机器人末端直线运动
  102. /// </summary>
  103. /// <param name="handle"></param>
  104. /// <param name="end_pos">机器人末端运动目标位置</param>
  105. /// <param name="move_mode">指定运动模式:增量运动(相对运动)或绝对运动</param>
  106. /// <param name="is_block">设置接口是否为阻塞接口,TRUE 为阻塞接口 FALSE 为非阻塞接口</param>
  107. /// <param name="speed">机器人直线运动速度,单位:mm/s</param>
  108. /// <returns></returns>
  109. [DllImport("jakaAPI.dll", EntryPoint = "linear_move", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  110. public static extern int linear_move(ref int handle, ref JKTYPE.CartesianPose end_pos, JKTYPE.MoveMode move_mode, bool is_block, double speed);
  111. /// <summary>
  112. /// 机器人SERVO MOVE模式使能
  113. /// </summary>
  114. /// <param name="handle"></param>
  115. /// <param name="enable">TRUE为进入SERVO MOVE模式,FALSE表示退出该模式</param>
  116. /// <returns></returns>
  117. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_enable", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  118. public static extern int servo_move_enable(ref int handle, bool enable);
  119. /// <summary>
  120. /// 机器人关节空间位置控制模式
  121. /// </summary>
  122. /// <param name="handle"></param>
  123. /// <param name="joint_pos">机器人关节运动目标位置</param>
  124. /// <param name="move_mode">指定运动模式:增量运动或绝对运动</param>
  125. /// <returns></returns>
  126. [DllImport("jakaAPI.dll", EntryPoint = "servo_j", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  127. public static extern int servo_j(ref int handle, ref JKTYPE.JointValue joint_pos, JKTYPE.MoveMode move_mode);
  128. /// <summary>
  129. /// 机器人关节空间位置控制模式
  130. /// </summary>
  131. /// <param name="handle"></param>
  132. /// <param name="joint_pos">机器人关节运动目标位置</param>
  133. /// <param name="move_mode">指定运动模式:增量运动或绝对运动</param>
  134. /// <param name="step_num">倍分周期,servo_j运动周期为step_num*8ms,其中step_num>=1</param>
  135. /// <returns></returns>
  136. [DllImport("jakaAPI.dll", EntryPoint = "servo_j_extend", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  137. public static extern int servo_j_extend(ref int handle, ref JKTYPE.JointValue joint_pos, JKTYPE.MoveMode move_mode, int step_num);
  138. /// <summary>
  139. /// 机器人笛卡尔空间位置控制模式
  140. /// </summary>
  141. /// <param name="handle"></param>
  142. /// <param name="cartesian_pose">机器人笛卡尔空间运动目标位置</param>
  143. /// <param name="move_mode">指定运动模式:增量运动或绝对运动</param>
  144. /// <returns></returns>
  145. [DllImport("jakaAPI.dll", EntryPoint = "servo_p", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  146. public static extern int servo_p(ref int handle, ref JKTYPE.CartesianPose cartesian_pose, JKTYPE.MoveMode move_mode);
  147. /// <summary>
  148. /// 机器人笛卡尔空间位置控制模式
  149. /// </summary>
  150. /// <param name="handle"></param>
  151. /// <param name="cartesian_pose">机器人笛卡尔空间运动目标位置</param>
  152. /// <param name="move_mode">指定运动模式:增量运动或绝对运动</param>
  153. /// <param name="step_num">倍分周期,servo_p运动周期为step_num*8ms,其中step_num>=1</param>
  154. /// <returns></returns>
  155. [DllImport("jakaAPI.dll", EntryPoint = "servo_p_extend", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  156. public static extern int servo_p_extend(ref int handle, ref JKTYPE.CartesianPose cartesian_pose, JKTYPE.MoveMode move_mode, int step_num);
  157. /// <summary>
  158. /// 设置数字输出变量(DO)的值
  159. /// </summary>
  160. /// <param name="handle"></param>
  161. /// <param name="type">type DO类型</param>
  162. /// <param name="index">index DO索引</param>
  163. /// <param name="value">value DO设置值</param>
  164. /// <returns></returns>
  165. [DllImport("jakaAPI.dll", EntryPoint = "set_digital_output", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  166. public static extern int set_digital_output(ref int handle, JKTYPE.IOType type, int index, bool value);
  167. /// <summary>
  168. /// 设置模拟输出变量的值(AO)的值
  169. /// </summary>
  170. /// <param name="handle"></param>
  171. /// <param name="type"> AO类型</param>
  172. /// <param name="index">AO索引</param>
  173. /// <param name="value">AO设置值</param>
  174. /// <returns></returns>
  175. [DllImport("jakaAPI.dll", EntryPoint = "set_analog_output", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  176. public static extern int set_analog_output(ref int handle, JKTYPE.IOType type, int index, float value);
  177. /// <summary>
  178. /// 查询数字输入(DI)状态
  179. /// </summary>
  180. /// <param name="handle"></param>
  181. /// <param name="type">DI类型</param>
  182. /// <param name="index">DI索引</param>
  183. /// <param name="result">DI状态查询结果</param>
  184. /// <returns></returns>
  185. [DllImport("jakaAPI.dll", EntryPoint = "get_digital_input", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  186. public static extern int get_digital_input(ref int handle, JKTYPE.IOType type, int index, ref bool result);
  187. /// <summary>
  188. /// 查询数字输出(DO)状态
  189. /// </summary>
  190. /// <param name="handle"></param>
  191. /// <param name="type">DO类型</param>
  192. /// <param name="index">DO索引</param>
  193. /// <param name="result">DO状态查询结果</param>
  194. /// <returns></returns>
  195. [DllImport("jakaAPI.dll", EntryPoint = "get_digital_output", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  196. public static extern int get_digital_output(ref int handle, JKTYPE.IOType type, int index, ref bool result);
  197. /// <summary>
  198. /// 获取模拟量输入变量(AI)的值
  199. /// </summary>
  200. /// <param name="handle"></param>
  201. /// <param name="type">AI的类型</param>
  202. /// <param name="index">AI索引</param>
  203. /// <param name="result">指定AI状态查询结果</param>
  204. /// <returns></returns>
  205. [DllImport("jakaAPI.dll", EntryPoint = "get_analog_input", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  206. public static extern int get_analog_input(ref int handle, JKTYPE.IOType type, int index, ref float result);
  207. /// <summary>
  208. /// 获取模拟量输出变量(AO)的值
  209. /// </summary>
  210. /// <param name="handle"></param>
  211. /// <param name="type">AO的类型</param>
  212. /// <param name="index">AO索引</param>
  213. /// <param name="result">指定AO状态查询结果</param>
  214. /// <returns></returns>
  215. [DllImport("jakaAPI.dll", EntryPoint = "get_analog_output", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  216. public static extern int get_analog_output(ref int handle, JKTYPE.IOType type, int index, ref float result);
  217. /// <summary>
  218. /// 查询扩展IO模块是否运行
  219. /// </summary>
  220. /// <param name="handle"></param>
  221. /// <param name="is_running"></param>
  222. /// <returns></returns>
  223. [DllImport("jakaAPI.dll", EntryPoint = "is_extio_running", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  224. public static extern int is_extio_running(ref int handle, ref bool is_running);
  225. /// <summary>
  226. /// 运行当前加载的作业程序
  227. /// </summary>
  228. /// <param name="handle"></param>
  229. /// <returns></returns>
  230. [DllImport("jakaAPI.dll", EntryPoint = "program_run", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  231. public static extern int program_run(ref int handle);
  232. /// <summary>
  233. /// 暂停当前运行的作业程序
  234. /// </summary>
  235. /// <param name="handle"></param>
  236. /// <returns></returns>
  237. [DllImport("jakaAPI.dll", EntryPoint = "program_pause", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  238. public static extern int program_pause(ref int handle);
  239. /// <summary>
  240. /// 继续运行当前暂停的作业程序
  241. /// </summary>
  242. /// <param name="handle"></param>
  243. /// <returns></returns>
  244. [DllImport("jakaAPI.dll", EntryPoint = "program_resume", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  245. public static extern int program_resume(ref int handle);
  246. /// <summary>
  247. /// 终止当前执行的作业程序
  248. /// </summary>
  249. /// <param name="handle"></param>
  250. /// <returns></returns>
  251. [DllImport("jakaAPI.dll", EntryPoint = "program_abort", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  252. public static extern int program_abort(ref int handle);
  253. /// <summary>
  254. /// 加载指定的作业程序
  255. /// </summary>
  256. /// <param name="handle"></param>
  257. /// <param name="file">程序文件路径</param>
  258. /// <returns></returns>
  259. [DllImport("jakaAPI.dll", EntryPoint = "program_load", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  260. public static extern int program_load(ref int handle, char[] file);
  261. /// <summary>
  262. /// 获取已加载的作业程序名字
  263. /// </summary>
  264. /// <param name="handle"></param>
  265. /// <param name="file"></param>
  266. /// <returns></returns>
  267. [DllImport("jakaAPI.dll", EntryPoint = "get_loaded_program", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  268. public static extern int get_loaded_program(ref int handle, StringBuilder file);
  269. /// <summary>
  270. /// 获取当前机器人作业程序的执行行号
  271. /// </summary>
  272. /// <param name="handle"></param>
  273. /// <param name="curr_line">当前行号查询结果</param>
  274. /// <returns></returns>
  275. [DllImport("jakaAPI.dll", EntryPoint = "get_current_line", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  276. public static extern int get_current_line(ref int handle, ref int curr_line);
  277. /// <summary>
  278. /// 获取机器人作业程序执行状态
  279. /// </summary>
  280. /// <param name="handle"></param>
  281. /// <param name="status">作业程序执行状态查询结果</param>
  282. /// <returns></returns>
  283. [DllImport("jakaAPI.dll", EntryPoint = "get_program_state", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  284. public static extern int get_program_state(ref int handle, ref JKTYPE.ProgramState status);
  285. /// <summary>
  286. /// 设置机器人运行倍率
  287. /// </summary>
  288. /// <param name="handle"></param>
  289. /// <param name="rapid_rate">是程序运行倍率,设置范围为[0,1]</param>
  290. /// <returns></returns>
  291. [DllImport("jakaAPI.dll", EntryPoint = "set_rapidrate", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  292. public static extern int set_rapidrate(ref int handle, double rapid_rate);
  293. /// <summary>
  294. /// 获取机器人运行倍率
  295. /// </summary>
  296. /// <param name="handle"></param>
  297. /// <param name="rapid_rate">当前控制系统倍率</param>
  298. /// <returns></returns>
  299. [DllImport("jakaAPI.dll", EntryPoint = "get_rapidrate", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  300. public static extern int get_rapidrate(ref int handle, ref double rapid_rate);
  301. /// <summary>
  302. /// 设置指定编号的工具信息
  303. /// </summary>
  304. /// <param name="handle"></param>
  305. /// <param name="id">工具编号</param>
  306. /// <param name="tcp">工具坐标系相对法兰坐标系偏置</param>
  307. /// <param name="name">指定工具的别名</param>
  308. /// <returns></returns>
  309. [DllImport("jakaAPI.dll", EntryPoint = "set_tool_data", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  310. public static extern int set_tool_data(ref int handle, int id, ref JKTYPE.CartesianPose tcp, char[] name);
  311. /// <summary>
  312. /// 查询使用的工具信息
  313. /// </summary>
  314. /// <param name="handle"></param>
  315. /// <param name="id">工具ID查询结果</param>
  316. /// <param name="tcp">工具坐标系相对法兰坐标系偏置</param>
  317. /// <returns></returns>
  318. [DllImport("jakaAPI.dll", EntryPoint = "get_tool_data", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  319. public static extern int get_tool_data(ref int handle, ref int id, ref JKTYPE.CartesianPose tcp);
  320. /// <summary>
  321. /// 设置当前使用的工具ID
  322. /// </summary>
  323. /// <param name="handle"></param>
  324. /// <param name="id">工具坐标系ID</param>
  325. /// <returns></returns>
  326. [DllImport("jakaAPI.dll", EntryPoint = "set_tool_id", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  327. public static extern int set_tool_id(ref int handle, int id);
  328. /// <summary>
  329. /// 查询当前使用的工具ID
  330. /// </summary>
  331. /// <param name="handle"></param>
  332. /// <param name="id">工具ID查询结果</param>
  333. /// <returns></returns>
  334. [DllImport("jakaAPI.dll", EntryPoint = "get_tool_id", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  335. public static extern int get_tool_id(ref int handle, ref int id);
  336. /// <summary>
  337. /// 设置指定编号的用户坐标系信息
  338. /// </summary>
  339. /// <param name="handle"></param>
  340. /// <param name="id">用户坐标系编号</param>
  341. /// <param name="user_frame">用户坐标系偏置值</param>
  342. /// <param name="name">用户坐标系别名</param>
  343. /// <returns></returns>
  344. [DllImport("jakaAPI.dll", EntryPoint = "set_user_frame_data", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  345. public static extern int set_user_frame_data(ref int handle, int id, ref JKTYPE.CartesianPose user_frame, char[] name);
  346. /// <summary>
  347. ///
  348. /// </summary>
  349. /// <param name="handle"></param>
  350. /// <param name="id"></param>
  351. /// <param name="user_frame"></param>
  352. /// <returns></returns>
  353. [DllImport("jakaAPI.dll", EntryPoint = "get_user_frame_data", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  354. public static extern int get_user_frame_data(ref int handle, ref int id, ref JKTYPE.CartesianPose user_frame);
  355. /// <summary>
  356. ///
  357. /// </summary>
  358. /// <param name="handle"></param>
  359. /// <param name="id"></param>
  360. /// <returns></returns>
  361. [DllImport("jakaAPI.dll", EntryPoint = "set_user_frame_id", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  362. public static extern int set_user_frame_id(ref int handle, int id);
  363. /// <summary>
  364. /// 查询当前使用的用户坐标系ID
  365. /// </summary>
  366. /// <param name="handle"></param>
  367. /// <param name="id">获取的结果</param>
  368. /// <returns></returns>
  369. [DllImport("jakaAPI.dll", EntryPoint = "get_user_frame_id", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  370. public static extern int get_user_frame_id(ref int handle, ref int id);
  371. /// <summary>
  372. /// 控制机器人进入或退出拖拽模式
  373. /// </summary>
  374. /// <param name="handle"></param>
  375. /// <param name="enable">TRUE为进入拖拽模式,FALSE为退出拖拽模式</param>
  376. /// <returns></returns>
  377. [DllImport("jakaAPI.dll", EntryPoint = "drag_mode_enable", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  378. public static extern int drag_mode_enable(ref int handle, bool enable);
  379. /// <summary>
  380. /// 查询机器人是否处于拖拽模式
  381. /// </summary>
  382. /// <param name="handle"></param>
  383. /// <param name="in_drag"></param>
  384. /// <returns></returns>
  385. [DllImport("jakaAPI.dll", EntryPoint = "is_in_drag_mode", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  386. public static extern int is_in_drag_mode(ref int handle, ref bool in_drag);
  387. /// <summary>
  388. /// 获取机器人状态
  389. /// </summary>
  390. /// <param name="handle"></param>
  391. /// <param name="state">机器人状态查询结果</param>
  392. /// <returns></returns>
  393. [DllImport("jakaAPI.dll", EntryPoint = "get_robot_state", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  394. public static extern int get_robot_state(ref int handle, ref JKTYPE.RobotState state);
  395. /// <summary>
  396. /// 获取当前设置下工具末端的位姿
  397. /// </summary>
  398. /// <param name="handle"></param>
  399. /// <param name="tcp_position">工具末端位置查询结果</param>
  400. /// <returns></returns>
  401. [DllImport("jakaAPI.dll", EntryPoint = "get_tcp_position", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  402. public static extern int get_tcp_position(ref int handle, ref JKTYPE.CartesianPose tcp_position);
  403. /// <summary>
  404. /// 获取当前机器人关节角度
  405. /// </summary>
  406. /// <param name="handle"></param>
  407. /// <param name="joint_position">关节角度查询结果</param>
  408. /// <returns></returns>
  409. [DllImport("jakaAPI.dll", EntryPoint = "get_joint_position", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  410. public static extern int get_joint_position(ref int handle, ref JKTYPE.JointValue joint_position);
  411. /// <summary>
  412. /// 查询机器人是否处于碰撞保护模式
  413. /// </summary>
  414. /// <param name="handle"></param>
  415. /// <param name="in_collision">查询结果</param>
  416. /// <returns></returns>
  417. [DllImport("jakaAPI.dll", EntryPoint = "is_in_collision", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  418. public static extern int is_in_collision(ref int handle, ref bool in_collision);
  419. /// <summary>
  420. /// 查询机器人是否超出限位
  421. /// </summary>
  422. /// <param name="handle"></param>
  423. /// <param name="on_limit">查询结果</param>
  424. /// <returns></returns>
  425. [DllImport("jakaAPI.dll", EntryPoint = "is_on_limit", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  426. public static extern int is_on_limit(ref int handle, ref bool on_limit);
  427. /// <summary>
  428. /// 查询机器人运动是否停止
  429. /// </summary>
  430. /// <param name="handle"></param>
  431. /// <param name="in_pos"></param>
  432. /// <returns></returns>
  433. [DllImport("jakaAPI.dll", EntryPoint = "is_in_pos", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  434. public static extern int is_in_pos(ref int handle, ref bool in_pos);
  435. /// <summary>
  436. ///
  437. /// </summary>
  438. /// <param name="handle"></param>
  439. /// <returns></returns>
  440. [DllImport("jakaAPI.dll", EntryPoint = "collision_recover", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  441. public static extern int collision_recover(ref int handle);
  442. /// <summary>
  443. /// 设置机器人碰撞等级
  444. /// </summary>
  445. /// <param name="handle"></param>
  446. /// <param name="level">碰撞等级,等级0-5 ,0为关闭碰撞,1为碰撞阈值25N,2为碰撞阈值50N,3为碰撞阈值75N,4为碰撞阈值100N,5为碰撞阈值125N</param>
  447. /// <returns></returns>
  448. [DllImport("jakaAPI.dll", EntryPoint = "set_collision_level", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  449. public static extern int set_collision_level(ref int handle, int level);
  450. /// <summary>
  451. /// 获取机器人设置的碰撞等级
  452. /// </summary>
  453. /// <param name="handle"></param>
  454. /// <param name="level">碰撞等级,等级0-5 ,0为关闭碰撞,1为碰撞阈值25N,2为碰撞阈值50N,3为碰撞阈值75N,4为碰撞阈值100N,5为碰撞阈值125N</param>
  455. /// <returns></returns>
  456. [DllImport("jakaAPI.dll", EntryPoint = "get_collision_level", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  457. public static extern int get_collision_level(ref int handle, ref int level);
  458. /// <summary>
  459. /// 计算指定位姿在当前工具、当前安装角度以及当前用户坐标系设置下的逆解
  460. /// </summary>
  461. /// <param name="handle"></param>
  462. /// <param name="ref_pos"></param>
  463. /// <param name="cartesian_pose"></param>
  464. /// <param name="joint_pos"></param>
  465. /// <returns></returns>
  466. [DllImport("jakaAPI.dll", EntryPoint = "kine_inverse", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  467. public static extern int kine_inverse(ref int handle, ref JKTYPE.JointValue ref_pos, ref JKTYPE.CartesianPose cartesian_pose, ref JKTYPE.JointValue joint_pos);
  468. /// <summary>
  469. /// 计算指定关节位置在当前工具、当前安装角度以及当前用户坐标系设置下的位姿值
  470. /// </summary>
  471. /// <param name="handle"></param>
  472. /// <param name="joint_pos">关节空间位置</param>
  473. /// <param name="cartesian_pose">笛卡尔空间位姿计算结果</param>
  474. /// <returns></returns>
  475. [DllImport("jakaAPI.dll", EntryPoint = "kine_forward", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  476. public static extern int kine_forward(ref int handle, ref JKTYPE.JointValue joint_pos, ref JKTYPE.CartesianPose cartesian_pose);
  477. /// <summary>
  478. /// 欧拉角到旋转矩阵的转换
  479. /// </summary>
  480. /// <param name="handle"></param>
  481. /// <param name="rpy">待转换的欧拉角数据</param>
  482. /// <param name="rot_matrix">转换后的旋转矩阵</param>
  483. /// <returns></returns>
  484. [DllImport("jakaAPI.dll", EntryPoint = "rpy_to_rot_matrix", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  485. public static extern int rpy_to_rot_matrix(ref int handle, ref JKTYPE.Rpy rpy, ref JKTYPE.RotMatrix rot_matrix);
  486. /// <summary>
  487. /// 旋转矩阵到欧拉角的转换
  488. /// </summary>
  489. /// <param name="handle"></param>
  490. /// <param name="rot_matrix">待转换的旋转矩阵数据</param>
  491. /// <param name="rpy">转换后的RPY欧拉角结果</param>
  492. /// <returns></returns>
  493. [DllImport("jakaAPI.dll", EntryPoint = "rot_matrix_to_rpy", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  494. public static extern int rot_matrix_to_rpy(ref int handle, ref JKTYPE.RotMatrix rot_matrix, ref JKTYPE.Rpy rpy);
  495. /// <summary>
  496. /// 四元数到旋转矩阵的转换
  497. /// </summary>
  498. /// <param name="handle"></param>
  499. /// <param name="quaternion">待转换的四元数数据</param>
  500. /// <param name="rot_matrix">转换后的旋转矩阵结果</param>
  501. /// <returns></returns>
  502. [DllImport("jakaAPI.dll", EntryPoint = "quaternion_to_rot_matrix", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  503. public static extern int quaternion_to_rot_matrix(ref int handle, ref JKTYPE.Quaternion quaternion, ref JKTYPE.RotMatrix rot_matrix);
  504. /// <summary>
  505. /// 旋转矩阵到四元数的转换
  506. /// </summary>
  507. /// <param name="handle"></param>
  508. /// <param name="rot_matrix">待转换的旋转矩阵</param>
  509. /// <param name="quaternion">转换后的四元数结果</param>
  510. /// <returns></returns>
  511. [DllImport("jakaAPI.dll", EntryPoint = "rot_matrix_to_quaternion", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  512. public static extern int rot_matrix_to_quaternion(ref int handle, ref JKTYPE.RotMatrix rot_matrix, ref JKTYPE.Quaternion quaternion);
  513. /// <summary>
  514. ///
  515. /// </summary>
  516. /// <param name="handle"></param>
  517. /// <param name="enable"></param>
  518. /// <returns></returns>
  519. [DllImport("jakaAPI.dll", EntryPoint = "torque_control_enable", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  520. public static extern int torque_control_enable(ref int handle, bool enable);
  521. /// <summary>
  522. ///
  523. /// </summary>
  524. /// <param name="handle"></param>
  525. /// <param name="tor_val"></param>
  526. /// <param name="grv_flag"></param>
  527. /// <returns></returns>
  528. [DllImport("jakaAPI.dll", EntryPoint = "torque_feedforward", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  529. public static extern int torque_feedforward(ref int handle, JKTYPE.TorqueValue tor_val, int grv_flag);
  530. /// <summary>
  531. /// 机器人负载设置
  532. /// </summary>
  533. /// <param name="handle"></param>
  534. /// <param name="payload">负载质心、质量数据</param>
  535. /// <returns></returns>
  536. [DllImport("jakaAPI.dll", EntryPoint = "set_payload", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  537. public static extern int set_payload(ref int handle, ref JKTYPE.PayLoad payload);
  538. /// <summary>
  539. /// 获取机器人负载数据
  540. /// </summary>
  541. /// <param name="handle"></param>
  542. /// <param name="payload">负载查询结果</param>
  543. /// <returns></returns>
  544. [DllImport("jakaAPI.dll", EntryPoint = "get_payload", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  545. public static extern int get_payload(ref int handle, ref JKTYPE.PayLoad payload);
  546. /// <summary>
  547. /// 注册机器人出现错误时的回调函数
  548. /// </summary>
  549. /// <param name="i"></param>
  550. /// <param name="func">指向用户定义的函数的函数指针</param>
  551. /// <returns></returns>
  552. [DllImport("jakaAPI.dll", EntryPoint = "set_error_handler", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  553. public static extern int set_error_handler(ref int i, CallBackFuncType func);
  554. /// <summary>
  555. /// 获取SDK版本号
  556. /// </summary>
  557. /// <param name="i"></param>
  558. /// <param name="version">SDK版本号</param>
  559. /// <returns></returns>
  560. [DllImport("jakaAPI.dll", EntryPoint = "get_sdk_version", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  561. public static extern int get_sdk_version(ref int i, StringBuilder version);
  562. /// <summary>
  563. /// 获取机器人状态数据
  564. /// </summary>
  565. /// <param name="i"></param>
  566. /// <param name="status">机器人状态</param>
  567. /// <returns></returns>
  568. [DllImport("jakaAPI.dll", EntryPoint = "get_robot_status", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  569. public static extern int get_robot_status(ref int i, ref JKTYPE.RobotStatus status);
  570. /// <summary>
  571. /// 终止当前机械臂运动
  572. /// </summary>
  573. /// <param name="i"></param>
  574. /// <returns></returns>
  575. [DllImport("jakaAPI.dll", EntryPoint = "motion_abort", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  576. public static extern int motion_abort(ref int i);
  577. /// <summary>
  578. /// 设置错误码文件路径,需要使用get_last_error接口时需要设置错误码文件路径,如果不使用get_last_error接口,则不需要设置该接口
  579. /// </summary>
  580. /// <param name="i"></param>
  581. /// <param name="path"></param>
  582. /// <returns></returns>
  583. [DllImport("jakaAPI.dll", EntryPoint = "set_errorcode_file_path", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  584. public static extern int set_errorcode_file_path(ref int i, StringBuilder path);
  585. /// <summary>
  586. /// 获取机器人运行过程中最后一个错误码,当调用clear_error时,最后一个错误码会清零
  587. /// </summary>
  588. /// <param name="i"></param>
  589. /// <param name="code"></param>
  590. /// <returns></returns>
  591. [DllImport("jakaAPI.dll", EntryPoint = "get_last_error", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  592. public static extern int get_last_error(ref int i, ref JKTYPE.ErrorCode code);
  593. /// <summary>
  594. ///
  595. /// </summary>
  596. /// <param name="i"></param>
  597. /// <param name="mode"></param>
  598. /// <returns></returns>
  599. [DllImport("jakaAPI.dll", EntryPoint = "set_debug_mode", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  600. public static extern int set_debug_mode(ref int i, bool mode);
  601. /// <summary>
  602. /// 设置是否开启调试模式,选择TRUE时,开始调试模式,此时会在标准输出流中输出调试信息,选择FALSE时,不输出调试信息
  603. /// </summary>
  604. /// <param name="i"></param>
  605. /// <param name="para"></param>
  606. /// <returns></returns>
  607. [DllImport("jakaAPI.dll", EntryPoint = "set_traj_config", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  608. public static extern int set_traj_config(ref int i, ref JKTYPE.TrajTrackPara para);
  609. /// <summary>
  610. /// 获取轨迹复现配置参数
  611. /// </summary>
  612. /// <param name="i"></param>
  613. /// <param name="para">轨迹复现配置参数</param>
  614. /// <returns></returns>
  615. [DllImport("jakaAPI.dll", EntryPoint = "get_traj_config", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  616. public static extern int get_traj_config(ref int i, ref JKTYPE.TrajTrackPara para);
  617. /// <summary>
  618. /// 采集轨迹复现数据控制开关
  619. /// </summary>
  620. /// <param name="i"></param>
  621. /// <param name="mode">选择TRUE时,开始数据采集,选择FALSE时,结束数据采集</param>
  622. /// <param name="filename">采集数据的存储文件名,当filename为空指针时,存储文件以当前日期命名</param>
  623. /// <returns></returns>
  624. [DllImport("jakaAPI.dll", EntryPoint = "set_traj_sample_mode", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  625. public static extern int set_traj_sample_mode(ref int i, bool mode, char[] filename);
  626. /// <summary>
  627. /// 采集轨迹复现数据状态查询
  628. /// </summary>
  629. /// <param name="i"></param>
  630. /// <param name="sample_statuse">为TRUE时,数据正在采集,为FALSE时,数据采集结束,在数据采集状态时不允许再次开启数据采集开关</param>
  631. /// <returns></returns>
  632. [DllImport("jakaAPI.dll", EntryPoint = "get_traj_sample_status", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  633. public static extern int get_traj_sample_status(ref int i, ref bool sample_statuse);
  634. /// <summary>
  635. /// 查询控制器中已经存在的轨迹复现数据的文件名
  636. /// </summary>
  637. /// <param name="i"></param>
  638. /// <param name="filename">控制器中已经存在的轨迹复现数据的文件名</param>
  639. /// <returns></returns>
  640. [DllImport("jakaAPI.dll", EntryPoint = "get_exist_traj_file_name", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  641. public static extern int get_exist_traj_file_name(ref int i, ref JKTYPE.MultStrStorType filename);
  642. /// <summary>
  643. /// 重命名轨迹复现数据的文件名
  644. /// </summary>
  645. /// <param name="i"></param>
  646. /// <param name="src">原文件名</param>
  647. /// <param name="dest">目标文件名,文件名长度不能超过100个字符,文件名不能为空,目标文件名不支持中文</param>
  648. /// <returns></returns>
  649. [DllImport("jakaAPI.dll", EntryPoint = "rename_traj_file_name", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  650. public static extern int rename_traj_file_name(ref int i, ref char[] src, ref char[] dest);
  651. /// <summary>
  652. /// 删除控制器中轨迹复现数据文件
  653. /// </summary>
  654. /// <param name="i"></param>
  655. /// <param name="filename">要删除的文件的文件名,文件名为数据文件名字</param>
  656. /// <returns></returns>
  657. [DllImport("jakaAPI.dll", EntryPoint = "remove_traj_file", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  658. public static extern int remove_traj_file(ref int i, char[] filename);
  659. /// <summary>
  660. ///
  661. /// </summary>
  662. /// <param name="i"></param>
  663. /// <param name="filename"></param>
  664. /// <returns></returns>
  665. [DllImport("jakaAPI.dll", EntryPoint = "generate_traj_exe_file", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  666. public static extern int generate_traj_exe_file(ref int i, char[] filename);
  667. /// <summary>
  668. ///
  669. /// </summary>
  670. /// <param name="i"></param>
  671. /// <param name="joint_pos"></param>
  672. /// <param name="move_mode"></param>
  673. /// <param name="is_block"></param>
  674. /// <param name="speed"></param>
  675. /// <param name="acc"></param>
  676. /// <param name="tol"></param>
  677. /// <param name="option_cond"></param>
  678. /// <returns></returns>
  679. [DllImport("jakaAPI.dll", EntryPoint = "joint_move_extend", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  680. public static extern int joint_move_extend(ref int i, ref JKTYPE.JointValue joint_pos, JKTYPE.MoveMode move_mode, bool is_block, double speed, double acc, double tol, ref JKTYPE.OptionalCond option_cond);
  681. /// <summary>
  682. ///
  683. /// </summary>
  684. /// <param name="i"></param>
  685. /// <param name="cart_pos"></param>
  686. /// <param name="move_mode"></param>
  687. /// <param name="is_block"></param>
  688. /// <param name="speed"></param>
  689. /// <param name="acc"></param>
  690. /// <param name="tol"></param>
  691. /// <param name="option_cond"></param>
  692. /// <returns></returns>
  693. [DllImport("jakaAPI.dll", EntryPoint = "linear_move_extend", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  694. public static extern int linear_move_extend(ref int i, ref JKTYPE.CartesianPose cart_pos, JKTYPE.MoveMode move_mode, bool is_block, double speed, double acc, double tol, ref JKTYPE.OptionalCond option_cond);
  695. /// <summary>
  696. /// 机器人末端圆弧运动
  697. /// </summary>
  698. /// <param name="i"></param>
  699. /// <param name="end_pos">机器人末端运动目标位置</param>
  700. /// <param name="mid_pos">机器人末端运中间点</param>
  701. /// <param name="move_mode">指定运动模式:增量运动(相对运动)或绝对运动</param>
  702. /// <param name="is_block">设置接口是否为阻塞接口,TRUE 为阻塞接口 FALSE 为非阻塞接口</param>
  703. /// <param name="speed">机器人圆弧运动速度,单位:rad/s</param>
  704. /// <param name="acc">机器人圆弧运动加速度,单位:rad/s^2</param>
  705. /// <param name="tol">机器人圆弧运动终点误差, 单位mm</param>
  706. /// <param name="option_cond">机器人关节可选参数,如果不需要,该值可不赋值,填入空指针就可</param>
  707. /// <returns></returns>
  708. [DllImport("jakaAPI.dll", EntryPoint = "circular_move", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  709. public static extern int circular_move(ref int i, ref JKTYPE.CartesianPose end_pos, ref JKTYPE.CartesianPose mid_pos, JKTYPE.MoveMode move_mode, bool is_block, double speed, double acc, double tol, ref JKTYPE.OptionalCond option_cond);
  710. /// <summary>
  711. /// SERVO模式下不使用滤波器,该指令在SERVO模式下不可设置,退出SERVO后可设置
  712. /// </summary>
  713. /// <param name="i"></param>
  714. /// <returns></returns>
  715. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_use_none_filter", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  716. public static extern int servo_move_use_none_filter(ref int i);
  717. /// <summary>
  718. /// SERVO模式下关节空间一阶低通滤波,该指令在SERVO模式下不可设置,退出SERVO后可设置
  719. /// </summary>
  720. /// <param name="i"></param>
  721. /// <param name="cutoffFreq">一阶低通滤波器截止频率</param>
  722. /// <returns></returns>
  723. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_use_joint_LPF", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  724. public static extern int servo_move_use_joint_LPF(ref int i, double cutoffFreq);
  725. /// <summary>
  726. /// SERVO模式下关节空间非线性滤波,该指令在SERVO模式下不可设置,退出SERVO后可设置
  727. /// </summary>
  728. /// <param name="i"></param>
  729. /// <param name="max_vr">笛卡尔空间姿态变化速度的速度上限值(绝对值)°/s</param>
  730. /// <param name="max_ar">笛卡尔空间姿态变化速度的加速度上限值(绝对值)°/s^2</param>
  731. /// <param name="max_jr">笛卡尔空间姿态变化速度的加加速度上限值(绝对值)°/s^3</param>
  732. /// <returns></returns>
  733. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_use_joint_NLF", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  734. public static extern int servo_move_use_joint_NLF(ref int i, double max_vr, double max_ar, double max_jr);
  735. /// <summary>
  736. /// SERVO模式下笛卡尔空间非线性滤波,该指令在SERVO模式下不可设置,退出SERVO后可设置
  737. /// </summary>
  738. /// <param name="i"></param>
  739. /// <param name="max_vp">笛卡尔空间下移动指令速度的上限值(绝对值)。单位:mm/s</param>
  740. /// <param name="max_ap">笛卡尔空间下移动指令加速度的上限值(绝对值)。单位:mm/s^2</param>
  741. /// <param name="max_jp">笛卡尔空间下移动指令加加速度的上限值(绝对值)单位:mm/s^3</param>
  742. /// <param name="max_vr">笛卡尔空间姿态变化速度的速度上限值(绝对值)°/s</param>
  743. /// <param name="max_ar">笛卡尔空间姿态变化速度的加速度上限值(绝对值)°/s^2</param>
  744. /// <param name="max_jr">笛卡尔空间姿态变化速度的加加速度上限值(绝对值)°/s^3</param>
  745. /// <returns></returns>
  746. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_use_carte_NLF", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  747. public static extern int servo_move_use_carte_NLF(ref int i, double max_vp, double max_ap, double max_jp, double max_vr, double max_ar, double max_jr);
  748. /// <summary>
  749. /// SERVO模式下关节空间多阶均值滤波器,该指令在SERVO模式下不可设置,退出SERVO后可设置
  750. /// </summary>
  751. /// <param name="i"></param>
  752. /// <param name="max_buf">均值滤波器缓冲区的大小</param>
  753. /// <param name="kp">加速度滤波系数</param>
  754. /// <param name="kv">速度滤波系数</param>
  755. /// <param name="ka">位置滤波系数</param>
  756. /// <returns></returns>
  757. [DllImport("jakaAPI.dll", EntryPoint = "servo_move_use_joint_MMF", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  758. public static extern int servo_move_use_joint_MMF(ref int i, int max_buf, double kp, double kv, double ka);
  759. /// <summary>
  760. /// SERVO模式下速度前瞻参数设置
  761. /// </summary>
  762. /// <param name="i"></param>
  763. /// <param name="max_buf">缓冲区的大小</param>
  764. /// <param name="kp">加速度滤波系数</param>
  765. /// <returns></returns>
  766. [DllImport("jakaAPI.dll", EntryPoint = "servo_speed_foresight", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  767. public static extern int servo_speed_foresight(ref int i, int max_buf, double kp);
  768. /// <summary>
  769. /// 设置SDK日志路径
  770. /// </summary>
  771. /// <param name="i"></param>
  772. /// <param name="filepath">SDK日志路径</param>
  773. /// <returns></returns>
  774. [DllImport("jakaAPI.dll", EntryPoint = "set_SDK_filepath", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  775. public static extern int set_SDK_filepath(ref int i, ref char[] filepath);
  776. /// <summary>
  777. /// 设置传感器品牌
  778. /// </summary>
  779. /// <param name="i"></param>
  780. /// <param name="sensor_brand">传感器品牌,可选值为1,2,3 分别代表不同品牌力矩传感器</param>
  781. /// <returns></returns>
  782. [DllImport("jakaAPI.dll", EntryPoint = "set_torsenosr_brand", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  783. public static extern int set_torsenosr_brand(ref int i, int sensor_brand);
  784. /// <summary>
  785. /// 获取传感器品牌
  786. /// </summary>
  787. /// <param name="i"></param>
  788. /// <param name="sensor_brand">传感器品牌,可选值为1,2,3 分别代表不同品牌力矩传感器</param>
  789. /// <returns></returns>
  790. [DllImport("jakaAPI.dll", EntryPoint = "get_torsenosr_brand", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  791. public static extern int get_torsenosr_brand(ref int i, ref int sensor_brand);
  792. /// <summary>
  793. /// 开启或关闭力矩传感器
  794. /// </summary>
  795. /// <param name="i"></param>
  796. /// <param name="sensor_mode">0代表关闭传感器,1代表开启力矩传感器</param>
  797. /// <returns></returns>
  798. [DllImport("jakaAPI.dll", EntryPoint = "set_torque_sensor_mode", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  799. public static extern int set_torque_sensor_mode(ref int i, int sensor_mode);
  800. /// <summary>
  801. /// 设置柔顺控制参数
  802. /// </summary>
  803. /// <param name="i"></param>
  804. /// <param name="axis">代表配置哪一轴,可选值为0~5</param>
  805. /// <param name="opt">柔顺方向,可选值为 1 2 3 4 5 6分别对应 fx fy fz mx my mz 0代表没有勾选</param>
  806. /// <param name="ftUser">阻尼力,表示用户用多大的力才能让机器人的沿着某个方向以最大速度进行运动</param>
  807. /// <param name="ftConstant">回弹力,表示机器人回到初始状态的能力</param>
  808. /// <param name="ftNnormalTrack">代表恒力,手动操作时全部设置为0</param>
  809. /// <param name="ftReboundFK">法向跟踪,手动操作时全部设置为0,</param>
  810. /// <returns></returns>
  811. [DllImport("jakaAPI.dll", EntryPoint = "set_admit_ctrl_config", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  812. public static extern int set_admit_ctrl_config(ref int i, int axis, int opt, int ftUser, int ftConstant, int ftNnormalTrack, int ftReboundFK);
  813. /// <summary>
  814. /// 开始辨识工具末端负载
  815. /// </summary>
  816. /// <param name="i"></param>
  817. /// <param name="joint_pos">使用力矩传感器进行自动负载辨识时的结束位置</param>
  818. /// <returns></returns>
  819. [DllImport("jakaAPI.dll", EntryPoint = "start_torq_sensor_payload_identify", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  820. public static extern int start_torq_sensor_payload_identify(ref int i, ref JKTYPE.JointValue joint_pos);
  821. /// <summary>
  822. ///
  823. /// </summary>
  824. /// <param name="i"></param>
  825. /// <param name="identify_status"></param>
  826. /// <returns></returns>
  827. [DllImport("jakaAPI.dll", EntryPoint = "get_torq_sensor_identify_staus", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  828. public static extern int get_torq_sensor_identify_staus(ref int i, ref int identify_status);
  829. /// <summary>
  830. /// 获取末端负载辨识结果
  831. /// </summary>
  832. /// <param name="i"></param>
  833. /// <param name="payload">末端负载</param>
  834. /// <returns></returns>
  835. [DllImport("jakaAPI.dll", EntryPoint = "get_torq_sensor_payload_identify_result", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  836. public static extern int get_torq_sensor_payload_identify_result(ref int i, ref JKTYPE.PayLoad payload);
  837. /// <summary>
  838. /// 设置传感器末端负载
  839. /// </summary>
  840. /// <param name="i"></param>
  841. /// <param name="payload">末端负载</param>
  842. /// <returns></returns>
  843. [DllImport("jakaAPI.dll", EntryPoint = "set_torq_sensor_tool_payload", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  844. public static extern int set_torq_sensor_tool_payload(ref int i, ref JKTYPE.PayLoad payload);
  845. /// <summary>
  846. /// 获取传感器末端负载
  847. /// </summary>
  848. /// <param name="i"></param>
  849. /// <param name="payload">末端负载</param>
  850. /// <returns></returns>
  851. [DllImport("jakaAPI.dll", EntryPoint = "get_torq_sensor_tool_payload", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  852. public static extern int get_torq_sensor_tool_payload(ref int i, ref JKTYPE.PayLoad payload);
  853. /// <summary>
  854. /// 力控拖拽使能
  855. /// </summary>
  856. /// <param name="i"></param>
  857. /// <param name="enable_flag">0为关闭力控拖拽使能,1为开启</param>
  858. /// <returns></returns>
  859. [DllImport("jakaAPI.dll", EntryPoint = "enable_admittance_ctrl", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  860. public static extern int enable_admittance_ctrl(ref int i, int enable_flag);
  861. /// <summary>
  862. /// 设置力控类型和传感器初始化状态
  863. /// </summary>
  864. /// <param name="i"></param>
  865. /// <param name="sensor_compensation">是否开启传感器补偿,1代表开启即初始化,0代表不初始化</param>
  866. /// <param name="compliance_type">0 代表不使用任何一种柔顺控制方法 1 代表恒力柔顺控制,2 代表速度柔顺控制</param>
  867. /// <returns></returns>
  868. [DllImport("jakaAPI.dll", EntryPoint = "set_compliant_type", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  869. public static extern int set_compliant_type(ref int i, int sensor_compensation, int compliance_type);
  870. /// <summary>
  871. /// 获取力控类型和传感器初始化状态
  872. /// </summary>
  873. /// <param name="i"></param>
  874. /// <param name="sensor_compensation">是否开启传感器补偿,1代表开启即初始化,0代表不初始化</param>
  875. /// <param name="compliance_type">0 代表不使用任何一种柔顺控制方法 1 代表恒力柔顺控制,2 代表速度柔顺控制</param>
  876. /// <returns></returns>
  877. [DllImport("jakaAPI.dll", EntryPoint = "get_compliant_type", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  878. public static extern int get_compliant_type(ref int i, ref int sensor_compensation, ref int compliance_type);
  879. /// <summary>
  880. /// 错误状态清除
  881. /// </summary>
  882. /// <param name="i"></param>
  883. /// <returns></returns>
  884. [DllImport("jakaAPI.dll", EntryPoint = "clear_error", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  885. public static extern int clear_error(ref int i);
  886. /// <summary>
  887. /// 获取力控柔顺控制参数
  888. /// </summary>
  889. /// <param name="i"></param>
  890. /// <param name="admit_ctrl_cfg">机器人力控柔顺控制参数存储地址</param>
  891. /// <returns></returns>
  892. [DllImport("jakaAPI.dll", EntryPoint = "get_admit_ctrl_config", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  893. public static extern int get_admit_ctrl_config(ref int i, ref JKTYPE.RobotAdmitCtrl admit_ctrl_cfg);
  894. /// <summary>
  895. /// 设置力控传感器ip地址
  896. /// </summary>
  897. /// <param name="i"></param>
  898. /// <param name="type"> 0为使用tcp/ip协议,1为使用RS485协议</param>
  899. /// <param name="ip_addr">为力控传感器地址</param>
  900. /// <param name="port">为使用tcp/ip协议时力控传感器端口号</param>
  901. /// <returns></returns>
  902. [DllImport("jakaAPI.dll", EntryPoint = "set_torque_sensor_comm", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  903. public static extern int set_torque_sensor_comm(ref int i, int type, ref char[] ip_addr, int port);
  904. /// <summary>
  905. /// 获取力控传感器ip地址
  906. /// </summary>
  907. /// <param name="i"></param>
  908. /// <param name="type">0为使用tcp/ip协议,1为使用RS485协议</param>
  909. /// <param name="ip_addr">力控传感器地址</param>
  910. /// <param name="port">使用tcp/ip协议时力控传感器端口号</param>
  911. /// <returns></returns>
  912. [DllImport("jakaAPI.dll", EntryPoint = "get_torque_sensor_comm", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  913. public static extern int get_torque_sensor_comm(ref int i, ref int type, ref byte ip_addr, ref int port);
  914. /// <summary>
  915. /// 关闭力控
  916. /// </summary>
  917. /// <param name="i"></param>
  918. /// <returns></returns>
  919. [DllImport("jakaAPI.dll", EntryPoint = "disable_force_control", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  920. public static extern int disable_force_control(ref int i);
  921. /// <summary>
  922. /// 设置速度柔顺控制参数
  923. /// </summary>
  924. /// <param name="i"></param>
  925. /// <param name="vel">速度柔顺控制参数</param>
  926. /// <returns></returns>
  927. [DllImport("jakaAPI.dll", EntryPoint = "set_vel_compliant_ctrl", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  928. public static extern int set_vel_compliant_ctrl(ref int i, ref JKTYPE.VelCom vel);
  929. /// <summary>
  930. /// 设置柔顺控制力矩条件
  931. /// </summary>
  932. /// <param name="i"></param>
  933. /// <param name="ft">ft为柔顺控制力矩条件</param>
  934. /// <returns></returns>
  935. [DllImport("jakaAPI.dll", EntryPoint = "set_compliance_condition", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  936. public static extern int set_compliance_condition(ref int i, ref JKTYPE.FTxyz ft);
  937. /// <summary>
  938. /// 设置网络异常,SDK与机器人控制器失去连接后多长时间机器人控制器终止机械臂当前运动
  939. /// </summary>
  940. /// <param name="i"></param>
  941. /// <param name="millisecond"> 时间参数,单位毫秒</param>
  942. /// <param name="mnt">网络异常时机器人需要进行的动作类型</param>
  943. /// <returns></returns>
  944. [DllImport("jakaAPI.dll", EntryPoint = "set_network_exception_handle", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  945. public static extern int set_network_exception_handle(ref int i, float millisecond, JKTYPE.ProcessType mnt);
  946. /// <summary>
  947. /// 设置机器人状态数据自动更新时间间隔
  948. /// </summary>
  949. /// <param name="i"></param>
  950. /// <param name="millisecond">时间参数,单位毫秒</param>
  951. /// <returns></returns>
  952. [DllImport("jakaAPI.dll", EntryPoint = "set_status_data_update_time_interval", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
  953. public static extern int set_status_data_update_time_interval(ref int i, float millisecond);
  954. }
  955. }