xarm_set_suction_cup
1. Introduction
Open/Close the xArm vacuum gripper.
Button: [Blockly] - [End effector] - [xArm vacuum gripper] - open/close
2. Request & Response
```
{
"cmd": "xarm_set_suction_cup",
"data": {
"on": false,
"wait": true
},
"id": "close_Vgripper"
}
```
Name | Type | Required fields | Description |
---|---|---|---|
on | bool | Yes | True: Open False: Close |
wait | bool | Yes | wait or not |
delay | int | No | delay time; 0: set it immediately |
code=0->success;
code!=0->Failed, refer to xarm_api_code;
3. Code Example
background
yield self._wait_until_not_pause()
if self.is_simulation_robot:
return response(client, cmd_id, 0)
ret = yield self._wait_until_cmdnum_lt_max()
if ret is not None:
return response(client, cmd_id, ret)
on = data.get('on')
wait = data.get('wait', True)
delay = data.get('delay', 0)
timeout = 3
code = GLOBAL.XArm.xarm.set_suction_cup(on, wait=False, delay_sec=delay)
if code == 0 and wait:
start = time.monotonic()
code = APIState.SUCTION_CUP_TOUT
if delay is not None and delay > 0:
timeout += delay
while time.monotonic() - start < timeout:
ret = GLOBAL.XArm.xarm.get_suction_cup()
if ret[0] == XCONF.UxbusState.ERR_CODE:
code = XCONF.UxbusState.ERR_CODE
break
if ret[0] == 0:
if on and ret[1] == 1:
code = 0
break
if not on and ret[1] == 0:
code = 0
break
if not GLOBAL.XArm.xarm_connected or GLOBAL.XArm.xarm.state == 4:
code = APIState.EMERGENCY_STOP
break
yield gen.sleep(0.2)
response(client, cmd_id, code)
front_end
self.setSuctionCup = (on, wait, callback, delay) => {
const params = window.GlobalConstant.INIT_CMD_PARAMS_COMMON_DATA();
Object.assign(params.data, {
on: on,
wait: wait,
delay: delay,
});
self.sendCmd(window.GlobalConstant.SET_SUCTION_CUP, params, (dict) => {
// self.codeHandle(dict, 'set suction cup', true);
if (callback) {
callback(dict);
}
});
};
Last updated