执行器控制
启用一个执行器的全身笛卡尔控制是一个简便易用的API:
- Head Orientation(头部的方向);
- LArm/RArm Position(LArm/RArm的位置)。
这对反应性行为非常有用。用户可以更新目标(Head Orientation、Arm Position),动作使用一个SE3插值,安全而流畅,。
注释: |
以前的笛卡尔动作受到限制,这是因为逆运动学仅基于链的关节。例如,LArm控制仅使用LArm的自由度,因而其可达区域受到LArm长度的限制。 Whole Body motion(全身动作)使用所有的关节来调动执行器。因此也极大地扩大了可达区域。 |
---|
如何工作
遵循下面的条件,达到执行器目标:
- 双足稳固地保持在地面上;
- 保持平衡;
- 冗余度:通过尽可能地保持一个初始姿势来达到目标。
如何使用
首先,通过API“wbEnableEffectorControl”,选择您想控制的执行器。这会隐含地激活Whole Body Balancer(全身平衡器)。
# Example showing how to active Head tracking. effectorName = 'Head' isEnabled = True proxy.wbEnableEffectorControl(effectorName, isEnabled)
通过API“wbSetEffectorControl”,随时更新目标:
- 头部在旋转里控制(WX, WY, WZ)(弧度)。
- LArm和RArm在位置里控制(X, Y, Z)(米)。
TargetCoordinate必须是绝对的,并显示在SPACE_NAO里。
如果预定位置/方向不可行,就会重新调整目标,以达到最接近的可行动作。
# Example showing how to set orientation target for Head tracking. effectorName = "Head" targetCoordinate = [0.1, 0.0, 0.0] proxy.wbSetEffectorControl(effectorName, targetCoordinate)
最后,不要忘记解除执行器控制。
# Example showing how to disactivate Head tracking. effectorName = 'Head' isEnabled = False proxy.wbEnableEffectorControl(effectorName, isEnabled)
注释: |
使用这个API之前,先做好一个初始姿势。 |
---|
Head Orientation Control(头部方向控制)
# Example of a whole body head orientation control # Warning: Needs a PoseInit before executing # Whole body balancer must be disactivated at the end of the script # Example available: path/to/aldebaran-sdk/modules/src/examples/ # python/motion_wbEffectorControl_Head.py effectorName = "Head" # Active Head tracking. isEnabled = True proxy.wbEnableEffectorControl(effectorName, isEnabled) # Example showing how to set orientation target for Head tracking. # The 3 coordinates are absolute head orientation in NAO_SPACE. # Rotation in RAD in x, y and z axis. # X Axis Head Orientation feasible movement = [-20.0, +20.0] degree # Y Axis Head Orientation feasible movement = [-75.0, +70.0] degree # Z Axis Head Orientation feasible movement = [-30.0, +30.0] degree targetCoordinateList = [ [+20.0, 00.0, 00.0], # target 0 [-20.0, 00.0, 00.0], # target 1 [ 00.0, +70.0, 00.0], # target 2 [ 00.0, +70.0, +30.0], # target 3 [ 00.0, +70.0, -30.0], # target 4 [ 00.0, -75.0, 00.0], # target 5 [ 00.0, -75.0, +30.0], # target 6 [ 00.0, -75.0, -30.0], # target 7 [ 00.0, 00.0, 00.0], # target 8 ] # wbSetEffectorControl is a non blocking function. # time.sleep allow head go to his target. # The minimum period advised between two successive set commands is 0.2 s. for targetCoordinate in targetCoordinateList: targetCoordinate = [target*math.pi/180.0 for target in targetCoordinate] proxy.wbSetEffectorControl(effectorName, targetCoordinate) time.sleep(3.0) # Disactivate Head tracking. isEnabled = False proxy.wbEnableEffectorControl(effectorName, isEnabled)
Arm Position Control(手臂位置控制)
# Example of a whole body Left Arm position control # Warning: Needs a PoseInit before executing # Whole body balancer must be disactivated at the end of the script # Example available: path/to/aldebaran-sdk/modules/src/examples/ # python/motion_wbEffectorControl_LArm.py effectorName = "LArm" space = motion.SPACE_NAO useSensor = False effectorInit = proxy.getPosition(effectorName, space, useSensor) # Active LArm tracking. isEnabled = True proxy.wbEnableEffectorControl(effectorName, isEnabled) # Example showing how to set position target for LArm. # The 3 coordinates are absolute LArm position in NAO_SPACE. # Position in meter in x, y and z axis. # X Axis LArm Position feasible movement = [ +0.00, +0.18] meter # Y Axis LArm Position feasible movement = [ -0.04, +0.15] meter # Z Axis LArm Position feasible movement = [ -0.10, +0.10] meter targetCoordinateList = [ [ +0.18, +0.00, +0.00], # target 0 [ +0.18, +0.00, -0.10], # target 1 [ +0.18, +0.15, -0.10], # target 1 [ +0.18, +0.15, +0.10], # target 2 [ +0.18, -0.04, +0.10], # target 3 [ +0.18, -0.04, -0.10], # target 4 [ +0.18, +0.00, -0.10], # target 5 [ +0.18, +0.00, +0.00], # target 6 [ +0.00, +0.00, +0.00], # target 7 ] # wbSetEffectorControl is a non blocking function. # time.sleep allow head go to his target. # The minimum period advised between two successive set commands is 0.2 s. for targetCoordinate in targetCoordinateList: targetCoordinate = [targetCoordinate[i] + effectorInit[i] for i in range(3)] proxy.wbSetEffectorControl(effectorName, targetCoordinate) time.sleep(4.0) # Disactivate Head tracking. isEnabled = False proxy.wbEnableEffectorControl(effectorName, isEnabled)