25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

606 satır
16 KiB

  1. /**
  2. * Copyright © 2017-2018 Shanghai Lebai Robotic Co., Ltd. All rights reserved.
  3. *
  4. * FileName: robot_controller.proto
  5. *
  6. * Author: Yonnie Lu
  7. * Email: zhangyong.lu@lebai.ltd
  8. * Date: 2019-10-31 10:20:01
  9. * Description:
  10. * History:
  11. * <Author> <Time> <version> <desc>
  12. * YonnieLu 2019-10-31 10:20:01 1.0 Create
  13. *
  14. * compile methods:
  15. * 1. c++
  16. * protoc --grpc_out=./ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` *.proto
  17. * protoc --cpp_out=. *.proto
  18. *
  19. * 2. golang
  20. * protoc *.proto --go_out=plugins=grpc:../
  21. *
  22. * 3. python
  23. */
  24. syntax = "proto3";
  25. import "google/protobuf/empty.proto";
  26. import "messages.proto";
  27. package robotc;
  28. service RobotPrivateController {
  29. // 初始化配置
  30. rpc Init(Configuration) returns (Response);
  31. // 获取机器人基础信息
  32. rpc GetRobotInfo(google.protobuf.Empty) returns (RobotInfo);
  33. // 设置机器人安装方向
  34. rpc SetInstallDirection(InstallDirection) returns (Response);
  35. // 设置碰撞检测
  36. rpc SetCollisionDetector(CollisionDetector) returns (Response);
  37. // 设置关节配置
  38. rpc SetJointConfig(JointConfigs) returns (Response);
  39. // 设置笛卡尔空间的配置
  40. rpc SetCartesianConfig(CartesianConfig) returns (Response);
  41. // 开启DDS
  42. rpc EnableDDS(TrueOrFalse) returns (Response);
  43. // 设置碰撞检测力矩差阈值
  44. rpc SetCollisionTorqueDiff(CollisionTorqueDiff) returns(Response);
  45. // 注册通知事件
  46. rpc RegisterNotification(google.protobuf.Empty) returns (stream Notification);
  47. rpc RobotDriverInfo(google.protobuf.Empty) returns (DriverInfo);
  48. // 机器人OTA单个设备更新接口
  49. rpc RobotOTA(OTAData) returns (stream OTAResult);
  50. // 通知灯板、法兰、关节切换分区
  51. rpc SwitchOtaPartition(OTACmd) returns (Response);
  52. // 机器人OTA批量更新接口
  53. rpc RobotOTABatch(OTADatas) returns (stream OTAResults);
  54. // 重置
  55. rpc Reset(google.protobuf.Empty) returns(Response);
  56. // 以给定角度置零
  57. rpc InitZero(Zero) returns (Response);
  58. // 以零位置零
  59. rpc SetZero(google.protobuf.Empty) returns (Response);
  60. // 获取机器人电压V
  61. rpc GetVoltage(google.protobuf.Empty) returns (CurrentVoltage);
  62. // 设置单关节伺服参数
  63. rpc SetServoParam(JointServoParam) returns (JointServoParams);
  64. // 获取当前所有关节伺服参数
  65. rpc GetServoParams(google.protobuf.Empty) returns (JointServoParams);
  66. // 调试设置
  67. rpc SetDebugParams(DebugParams) returns (DebugParams);
  68. // 更改DH参数(三轴平行6参数)
  69. rpc FixDHParams(FixDHRequest) returns (FixDHResult);
  70. // 设置LED样式
  71. rpc SetLEDStyle(LEDStyle) returns (LEDStyles);
  72. // 获取LED样式
  73. rpc GetLEDStyles(google.protobuf.Empty) returns (LEDStyles);
  74. // 注册命令状态事件
  75. rpc RegisterLuaEvent(google.protobuf.Empty) returns (stream LuaEvent);
  76. // 当推送 ALERT/CONFIRM/INPUT/SELECT,用户在前端确定后调用该接口
  77. rpc ConfirmCallback(ConfirmInput) returns (Response);
  78. // 获取 Lua 上次执行到的机器人位置
  79. rpc GetLastPose(google.protobuf.Empty) returns (PoseRes);
  80. //配置Modbus外部IO设备
  81. rpc SetModbusExternalIO(ModbusExternalIOs) returns (Response);
  82. // 修改按钮配置
  83. rpc SetButtonConfig(ButtonConfig) returns (Response);
  84. // 设置绑定设备开关, true: 不限制设备绑定; false:限制设备绑定逻辑
  85. rpc SetBreakACup(TrueOrFalse) returns (Response);
  86. // PVAT数据记录接口,用户记录pvat数据
  87. rpc RecordPVAT(RecordPVATRequest) returns (stream RecordPVATResponse);
  88. rpc StopRecordPVAT(google.protobuf.Empty) returns (Response);
  89. // 语音升级
  90. rpc UpgradeVoiceFile(VoiceFile) returns (stream VoiceResult);//yvoice
  91. // 获取当前 DH 参数
  92. rpc GetDHParams(DHRequest) returns (DHParams);
  93. // 设置 DH 参数并返回设置后的结果
  94. rpc SetDHParams(DHParams) returns (DHParams);
  95. // 伺服控制参数
  96. rpc WriteExtraServoParam(ExtraServoParam) returns (ExtraServoParam);
  97. rpc ReadExtraServoParam(ExtraServoParam) returns (ExtraServoParam);
  98. rpc WriteExtraServoParams(ExtraServoParam) returns (ExtraServoParams);
  99. rpc ReadExtraServoParams(google.protobuf.Empty) returns (ExtraServoParams);
  100. rpc ResetExtraServoParams(google.protobuf.Empty) returns (ExtraServoParams);
  101. // “主动消回差”参数
  102. rpc WriteJointBacklash(JointBacklash) returns (JointBacklash);
  103. rpc ReadJointBacklash(JointBacklash) returns (JointBacklash);
  104. rpc WriteJointBacklashes(JointBacklash) returns (JointBacklashes);
  105. rpc ReadJointBacklashes(google.protobuf.Empty) returns (JointBacklashes);
  106. rpc ResetJointBacklashes(google.protobuf.Empty) returns (JointBacklashes);
  107. // 启用主动消回差
  108. rpc WriteEnableJointBacklashes(EnableJointBacklash) returns (EnableJointBacklashes);
  109. rpc ReadEnableJointBacklashes(google.protobuf.Empty) returns (EnableJointBacklashes);
  110. rpc ResetEnableJointBacklashes(google.protobuf.Empty) returns (EnableJointBacklashes);
  111. // 关节回差参数
  112. rpc WriteJointBacklashParam(JointBacklashParam) returns (JointBacklashParam);
  113. rpc ReadJointBacklashParam(JointBacklashParam) returns (JointBacklashParam);
  114. rpc WriteJointBacklashParams(JointBacklashParam) returns (JointBacklashParams);
  115. rpc ReadJointBacklashParams(google.protobuf.Empty) returns (JointBacklashParams);
  116. rpc ResetJointBacklashParams(google.protobuf.Empty) returns (JointBacklashParams);
  117. // 关节限位检测
  118. rpc EnableJointLimit(TrueOrFalse) returns (Response);
  119. rpc SwitchSimulate(TrueOrFalse) returns (Response);
  120. // 连接/断开 MODBUS 设备
  121. rpc ConnectExternalIO(ExternalIOState) returns (Response);
  122. }
  123. message EnableJointBacklash {
  124. int32 joint = 1;
  125. bool enable = 2;
  126. }
  127. message EnableJointBacklashes {
  128. repeated EnableJointBacklash joints = 1;
  129. }
  130. message ExtraServoParam {
  131. int32 joint = 1; // 当 Read、Enable/Disable 时仅该值生效, 0 代表关节 1
  132. double acc_position_kp = 2;
  133. double acc_speed_kp = 3;
  134. double acc_speed_it = 4;
  135. double uni_position_kp = 5;
  136. double uni_speed_kp = 6;
  137. double uni_speed_it = 7;
  138. double dec_position_kp = 8;
  139. double dec_speed_kp = 9;
  140. double dec_speed_it = 10;
  141. }
  142. message ExtraServoParams {
  143. repeated ExtraServoParam joints = 1;
  144. }
  145. message JointBacklash {
  146. int32 joint = 1;
  147. uint32 k = 2;
  148. double iq = 3;
  149. double iq_final = 4;
  150. uint32 iq_count = 5;
  151. }
  152. message JointBacklashes {
  153. repeated JointBacklash joints = 1;
  154. }
  155. message JointBacklashParam {
  156. int32 joint = 1;
  157. int32 encoder_data_offset = 2;
  158. uint32 on = 3;
  159. uint32 over = 4;
  160. uint32 leave = 5;
  161. uint32 max = 6;
  162. }
  163. message JointBacklashParams {
  164. repeated JointBacklashParam joints = 1;
  165. }
  166. message VoiceFile {//yvoice
  167. int32 id = 1;
  168. string file = 2;
  169. string md5 = 3;
  170. }
  171. message VoiceResult {//yvoice
  172. int32 id = 1;
  173. int32 step = 2;// 0: not begin, 1: downloading, 2: flashing, 3: done, 4:fail
  174. int32 stepProgress = 3;// 0-100, currently only downloading step has progress, other steps need show pending progress
  175. }
  176. //0: all joints 1-7:joint1-7 8:flan 9:claw 10:lamp
  177. enum BootloaderId {
  178. ALL_JOINTS = 0;
  179. JOINT_1 = 1;
  180. JOINT_2 = 2;
  181. JOINT_3 = 3;
  182. JOINT_4 = 4;
  183. JOINT_5 = 5;
  184. JOINT_6 = 6;
  185. JOINT_7 = 7;
  186. FLANGE = 8;
  187. CLAW = 9;
  188. LAMP = 10;
  189. COMBOARD = 14;
  190. }
  191. enum BootPartition {
  192. A = 0;
  193. B = 1;
  194. C = 2;
  195. PART_UNKNOWN = 3;
  196. }
  197. // Message definition
  198. message TrueOrFalse {
  199. bool val = 1;
  200. }
  201. message InstallDirection {
  202. int32 direction = 1; // 安装方式: 0: up; 1: down; 2: side, default: UP
  203. }
  204. message JointConfig {
  205. double maxAngle = 1;
  206. double minAngle = 2;
  207. double maxV = 3; // 用户端设定的全局速度拆分到每个关节的maxV上
  208. double maxAcc = 4;
  209. }
  210. message JointConfigs {
  211. repeated JointConfig configs = 1;
  212. }
  213. message CartesianConfig {
  214. double maxV = 1;
  215. double maxAcc = 2;
  216. }
  217. message SafetyPlat { // 安全平面,点为平面四个角的顶点,非示教的三个点
  218. repeated Coordinate points = 1;
  219. }
  220. message SafetyPlats {
  221. repeated SafetyPlat plats = 1; // default: empty
  222. }
  223. message CollisionTorqueDiff { // 每个关节碰撞检测的扭矩差值
  224. repeated double diffs = 1;
  225. }
  226. message CollisionDetector {
  227. bool enable = 1; // 是否启用碰撞检测, default: false
  228. int32 action = 2; // 碰撞检测后动作, 0: estop, 1: pause default: ESTOP
  229. int32 pauseTime = 3; // 碰撞检测暂停时间, default: 0
  230. int32 sensitivity = 4; // 碰撞检测灵敏度, , default: 50
  231. }
  232. message LEDStyle {
  233. int32 mode = 3;
  234. int32 speed = 4;
  235. repeated int32 color = 5;
  236. int32 voice = 1;
  237. int32 volume = 2;
  238. int32 robotMode = 6; // robot-mode
  239. }
  240. message LEDStyles {
  241. repeated LEDStyle styles = 16; // 机器人状态对应的LED样式,下标为robot-mode
  242. }
  243. message ButtonConfig {
  244. bool btn_flan_1 = 1; //
  245. bool btn_flan_2 = 2;
  246. bool btn_shoulder_0 = 3;
  247. }
  248. message Configuration {
  249. InstallDirection installDirection = 1;
  250. CollisionDetector collisionDetector = 2;
  251. JointConfigs jointConfigs = 3; // 0-6 关节配置
  252. SafetyPlats safetyPlats = 4; // 安全平面列表
  253. PR tcp = 5; // tcp配置
  254. Payload payload = 6; // 负载
  255. bool enableDDS = 7; // 是否开启内部数据调试服务(Data Debug Service),默认关闭
  256. CollisionTorqueDiff collisionTorqueDiff = 8;
  257. int32 robotDIOInNum = 9;
  258. int32 robotDIOOutNum = 10;
  259. repeated AIO robotAIOInConfig = 11;
  260. repeated AIO robotAIOOutConfig = 12;
  261. int32 tcpDIOInNum = 13;
  262. int32 tcpDIOOutNum = 14;
  263. repeated double zeros = 15; // 关节归零角度 (弃用)
  264. repeated LEDStyle styles = 16; // 机器人状态对应的LED样式
  265. bool break_a_cup = 17; // true: 不校验启动验证绑定设备hash逻辑; false: 默认值,校验
  266. ButtonConfig button_config = 18;
  267. CartesianConfig cartesianConfig = 19;
  268. int32 extra_robotDIOInNum = 20;
  269. int32 extra_robotDIOOutNum = 21;
  270. repeated AIO extra_robotAIOInConfig = 22;
  271. repeated AIO extra_robotAIOOutConfig = 23;
  272. }
  273. message Zero {
  274. repeated double zeros = 1;
  275. }
  276. message Notice {
  277. // 通知类型
  278. enum NoticeType {
  279. NOTICE_STATE = 0; // 机器人状态变更;机器人状态和急停状态位等
  280. NOTICE_ERROR = 1; // 错误:错误类型
  281. NOTICE_BUTTON = 2; // 按钮事件;
  282. }
  283. // 按钮类型的nId定义
  284. enum NoticeId {
  285. NOTICE_ID_STATE_ROBOT_STATE = 0; // 机器人状态
  286. NOTICE_ID_STATE_E_STOP = 1; // 机器人状态
  287. NOTICE_ID_STATE_DATA_UPDATE = 2; // 机器人数据有更新
  288. NOTICE_ID_ERROR = 3; // 机器人错误
  289. NOTICE_ID_BUTTON_SHOULDER = 4; // 肩部按钮
  290. NOTICE_ID_BUTTON_FLANGE_1 = 5; // 末端按钮1
  291. NOTICE_ID_BUTTON_FLANGE_2 = 6; // 末端按钮1
  292. }
  293. NoticeType type = 1; // 通知类型
  294. /**
  295. * type = 1 按钮事件
  296. * value: 按钮模式:1: 按钮空闲;2:长按;3:单击;4: 双击
  297. */
  298. NoticeId id = 2;
  299. int32 value = 3; // when there ERROR, value represent the LEVEL
  300. int32 code = 4;
  301. // some fucking boring and important data need return back to front end
  302. repeated double lol = 5;
  303. int32 count = 6; // 肩部按钮按下时,按该按钮的次数
  304. }
  305. message Notification {
  306. repeated Notice items = 1;
  307. }
  308. message Driver {
  309. // 驱动器基本信息
  310. Hardware hardware = 1;
  311. // 当前运行分区情况
  312. BootPartition curPartition = 2;
  313. }
  314. message DriverInfo {
  315. Driver flange = 1;
  316. Driver led = 2;
  317. repeated Driver joints = 3;
  318. Driver comboard = 4;
  319. }
  320. message OTAFile {
  321. string file = 1; // 文件完整路径
  322. string md5 = 2; // 文件原始md5,前端计算
  323. // version string: XX.YY.ZZ.20200608
  324. string version = 3;
  325. }
  326. message OTACmd {
  327. BootloaderId bootloaderId = 1;
  328. // 0: B分区;1: C分区
  329. BootPartition targetPartition = 2;
  330. }
  331. message OTAData {
  332. OTACmd cmd = 1;
  333. OTAFile file = 2;
  334. }
  335. message OTAJoints {
  336. repeated OTACmd cmds = 1;
  337. OTAFile file = 2;
  338. }
  339. message OTADatas {
  340. // 所有关节更新描述
  341. OTAJoints joints = 1;
  342. // 非关节更新描述: 灯板,法兰
  343. repeated OTAData notJoints = 2;
  344. }
  345. message OTAResult {
  346. BootloaderId bootloaderId = 1;
  347. int32 step = 2; // 0: not begin, 1: downloading, 2: flashing, 3: done, 4:fail
  348. int32 stepProgress = 3; // 0-100, currently only downloading step has progress, other steps need show pending progress
  349. string version = 4;
  350. BootPartition partition = 5;
  351. }
  352. message OTAResults {
  353. repeated OTAResult results = 1;
  354. }
  355. message CurrentVoltage {
  356. double power = 1; // 电源电压V/电流mA
  357. double flan = 2; // 法兰电压/电流
  358. repeated double joint = 3; // 关节电压/电流
  359. double io_power = 4; // IO板
  360. }
  361. message JointServoParam {
  362. uint32 index = 1; // 0代表关节一
  363. double position_kp = 2;
  364. double speed_kp = 3;
  365. double speed_it = 4;
  366. double torque_cmd_filter = 5;
  367. }
  368. message JointServoParams {
  369. repeated JointServoParam joints = 1;
  370. }
  371. message DebugParams {
  372. repeated double d = 1;
  373. }
  374. message FixDHRequest {
  375. repeated double delta_theta = 1;
  376. bool plus_theta = 2; // true则走到theta位再置零,false则走到-theta位再置零
  377. repeated double delta_l = 3;
  378. bool plus_l = 4; // true则加,false则减
  379. }
  380. message DHRequest {
  381. bool get_theoretical = 1; // 是否获取理论dh参数
  382. }
  383. message DHt {
  384. double d = 1;
  385. double a = 2;
  386. double alpha = 3;
  387. double theta = 4;
  388. }
  389. message DHParams {
  390. repeated DHt params = 1;
  391. }
  392. message FixDHResult {
  393. repeated DHt origin = 1;
  394. repeated DHt before = 2;
  395. repeated DHt after = 3;
  396. }
  397. message Option {
  398. string value = 1;
  399. string label = 2;
  400. }
  401. message LuaEvent {
  402. enum Type {
  403. ECHO = 0;
  404. LUA = 1;
  405. SIGNAL = 2;
  406. LOOP = 3;
  407. ALERT = 4;
  408. CONFIRM = 5;
  409. INPUT = 6;
  410. SELECT = 7;
  411. }
  412. enum CmdState {
  413. INIT = 0;
  414. RUNNING = 1;
  415. SUCCESS = 2;
  416. FAILED = 3;
  417. }
  418. Type type = 1;
  419. // type: ECHO
  420. int32 cmd_id = 2;
  421. CmdState cmd_state = 3;
  422. // echo_key
  423. // 当type=Lua时,该字段表示错误消息;
  424. // 当type=LOOP 时表示loopid
  425. // 当type=ALERT/CONFIRM/INPUT/SELECT时,该字段表示提示语
  426. string echo_key = 4;
  427. // index
  428. // 当type=LOOP时,表示进行到了第几个循环
  429. // 当type=LUA时,表示对应的任务ID
  430. int32 index = 8;
  431. // type: LUA
  432. LuaState lua_state = 5;
  433. // type: SIGNAL
  434. int32 signal_id = 6;
  435. double signal_value = 7;
  436. // type: SELECT
  437. repeated Option options = 9;
  438. }
  439. message ConfirmInput {
  440. string input = 1; // CONFIRM时为"true"|"false", INPUT为用户输入字符串, SELECT为用户选择的value
  441. }
  442. message PoseRes {
  443. PR cart = 1; // 笛卡尔位置
  444. JPose joint = 2; // 关节位置
  445. }
  446. message ModbusDio {
  447. int32 pin = 1;
  448. //对应modbus内部地址
  449. int32 addr = 2;
  450. }
  451. message ModbusDioGroup {
  452. repeated ModbusDio pins = 1;
  453. int32 addr = 2;
  454. }
  455. message ModbusAio {
  456. int32 pin = 1;
  457. // 0: 电压型 1: 电流型
  458. int32 mode = 2;
  459. //对应Modbus内部地址
  460. // 一个addr占用2bytes=16bits
  461. int32 addr = 3;
  462. }
  463. message AIORange {
  464. double min = 1;
  465. double max = 2;
  466. }
  467. message Range {
  468. AIORange V = 1;
  469. AIORange A = 2;
  470. }
  471. message ModbusAioGroup {
  472. repeated ModbusAio pins = 1;
  473. // modbus base address
  474. int32 addr = 2;
  475. //大小端
  476. int32 isLsb = 3;
  477. Range range = 4;
  478. // number of 16 bit words for one pin
  479. int32 size = 5;
  480. }
  481. message ModbusExternalIOMapping {
  482. // 所有数字量的输入值
  483. ModbusDioGroup di = 1;
  484. // 所有数字量的输出值
  485. ModbusDioGroup do = 2;
  486. // 所有模拟量输入值
  487. ModbusAioGroup ai = 3;
  488. // 所有模拟量输出值
  489. ModbusAioGroup ao = 4;
  490. }
  491. message ExternalIOState {
  492. int32 id = 1;
  493. bool enable = 2; // true 连接 false 断开
  494. }
  495. message ModbusExternalIO {
  496. int32 id = 1;
  497. string ip = 2;
  498. int32 port = 3;
  499. int32 timeout = 4;
  500. int32 slaveId = 5;
  501. int32 cmdHoldTime = 6;
  502. int32 version = 7;
  503. ModbusExternalIOMapping ioMap = 8;
  504. }
  505. message ModbusExternalIOs {
  506. repeated ModbusExternalIO ios= 1;
  507. }
  508. message RecordPVATRequest {
  509. enum PVATType {
  510. PT = 0;
  511. PVT = 1;
  512. PVAT = 2;
  513. }
  514. message VZeroGap {
  515. double threshold = 1; // v zero gap threshold should be > 0 and < 0.01
  516. bool remove_gap = 2; // whether to remove zero gap during teaching
  517. }
  518. PVATType type = 1;
  519. double duration = 2; // duration in microseconds
  520. VZeroGap vZeroGap = 3;
  521. bool use_duration_ts = 4;
  522. bool save_file = 5;
  523. }
  524. message RecordPVATResponse {
  525. repeated double p = 1;
  526. repeated double v = 2;
  527. repeated double acc = 3;
  528. double t = 4;
  529. bool end = 5; // is pvat end
  530. string f = 6; // data save file path, local
  531. }