• 重构VCR项目,能够输出设备清单,扩展设备

思路

  • 参考 ```cpp

class c d;

struct a { int type; int cmd; void *func; void *op; }b = 1;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void ToolOpen(ServerMessage_t &sm, ServerReply_t &sr,void *op)
{

}

static Sucker g_Sucker; #ifdef BEIJING_ROBOT
    static Robot g_Robot; #else 
     static Robot g_RobotCob; #endif
    // m_camera = new Camera();
    // m_detector = new Detector();
static struct _funcs
{
    int type;
    int subtype;
    int cmd;
    void *func;
    void *op;
}funcs[] = {
    {1,1,1,ToolOpen,&g_Sucker},
    {1,1,1,ToolOpen,&g_Sucker}
};

void process(ServerMessage_t &sm, ServerReply_t &sr)
{

} ```
  • 目标结构
    • url 格式 : /请求方式/设备类型/命令
      • 请求方式:
        • api, 发送请求数据,获取响应数据
        • 待定,后续可能要获取图片
      • 设备类型
        • camera, 相机设备类型
        • robot, 机械臂设备类型
        • detector,检测器设备类型
        • tool, 末端工具设备类型
        • platform, 工作平台设备类型
        • common, 通用设备类型
      • 命令
        • 各个设备的控制命令
  • 固定字段
    1
    2
    3
    4
    
    {
      "?sn":"设备序列号,作为某个设备的全局唯一标识",
      "sn":"string"
    }
    

设备清单

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
    "code":0,
    "data":{
        "camera":[
            "ty",
            "mkmd"
        ],
        "detector":[
            "gh",
            "aaa"
        ],
        "robot":[
            "beijing",
            "cob"
        ],
        "tool":[
            "sucker",
            "jaw"
        ]
    },
    "message":"成功"
}

moveTo

  • 关节空间
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    {
      "space": "joint",
      "speedPercent": 80,
      "target": [
          0,
          0,
          0,
          0,
          0,
          0
      ]
    }
    
  • 关节空间 版本二
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    {
      "space": "joint",
      "speedPercent": 80,
      "joint_flag":1,
      "target": [
          0,
          0,
          0,
          0,
          0,
          0
      ]
    }
    
  • 笛卡尔空间 对下层发送的数据结构
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    {
      "space": "cartBase",
      "cartVel": 0.3,
      "rotVel": 0.3,
      "target":[
          -0.3107980,
          0.00547460,
          0.26607365,
          0.14187905,
          -3.0985265,
          0.07320095
      ]
    }
    
  • 笛卡尔空间 上层下发的数据结构
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    {
      "?space":"运动空间类型: joint, 关节空间; cartBase, 笛卡尔空间",
      "space":"cartBase",
      "?cartVel":"笛卡尔空间下位置移动速度,单位为 m/s",
      "cartVel":1.0,
      "?rotVel":"笛卡尔空间下旋转速度,单位为 rad/s",
      "rotVel":1.0,
      "?cart_flag":"位置标志: 1, 绝对位置; 2, 相对位置",
      "cart_flag":1,
      "?rot_flag":"姿态标志: 1, 绝对姿态; 2, 相对姿态",
      "rot_flag":1,
      "?cart":"位置数据,单位为 m(米)",
      "cart":[
          1,2,3
      ],
      "?rot":"姿态数据,单位为 rad(弧度)",
      "rot":[
          4,5,6
      ]
    }
    
  • 笛卡尔空间 对上层提供的数据结构
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    {
      "?code":"状态码,0为成功;其他的为失败",
      "code" : 0,
      "?message":"状态消息",
      "message":"成功",
      "?space":"空间",
      "space":"cartBase",
      "cartVel":1.0,
      "rotVel":1.0,
      "cart_flag":1,
      "rot_flag":1,
      "cart":[
          1,2,3
      ],
      "rot":[
          4,5,6
      ]
    }
    

get point

  • 第一版
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    {
      "code":0,
      "data":{
          "CartInfo":[
              0.06573017199841043,
              -0.18093039602297886,
              0.6714999842590678,
              1.5707963497743604,
              3.1413529690927877,
              0.34917237684522284
          ],
          "JointInfo":[
              0.34907650304322624,
              0.000335558297349984,
              0.00023968449810713143,
              0.00014381069886427886,
              0.00009587379924285257,
              0
          ],
          "STATUS":"SUCCESS"
      },
      "message":"成功"
    }
    
  • 第二版
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    {
      "code":0,
      "data":{
          "CartInfo":{
              "cart":[
                  1,2,3
              ],
              "rot":[
                  4,5,6
              ]
          },
          "JointInfo":[
              1,2,3,4,5,6
          ]
      },
      "message":"成功"
    }
    

detect

  • 检测目标,返回的中心点坐标
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    
    {
      "code":0,
      "data":{
          "point_array":[
              {
                  "rx":-0.01703958989179134,
                  "ry":2.861906422352928,
                  "rz":-0.19738513912341824,
                  "x":0.012879030038020094,
                  "y":-0.43891458463458,
                  "z":0.0841377863535
              }
          ]
      },
      "message":"成功"
    }
    
  • 第二版 数据结构
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    {
      "code":0,
      "message":"",
      "data":{
          "point_array":[
              {
                  "cart":[
                      1,2,3
                  ],
                  "rot":[
                      4,5,6
                  ]
              },
              {
                  "cart":[
                      1,2,3
                  ],
                  "rot":[
                      4,5,6
                  ]
              }
          ]
      }
    }