NAOqi Motion - Overview | API
Enable Anti-collision protection of the arms of the robot. Use api isCollision to know if a chain is in collision and can be inactivated.
Parameters: |
|
---|---|
Returns: | A bool which return always true. |
almotion_setcollisionprotectionenabled.py
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
def main(robotIP):
PORT = 9559
try:
motionProxy = ALProxy("ALMotion", robotIP, PORT)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: ",e
sys.exit(1)
# Example showing how to activate "Arms" anticollision
# Anticollision can be activated at every time
pChainName = "Arms"
pEnable = True
isSuccess = motionProxy.setCollisionProtectionEnabled(pChainName, pEnable)
print "Anticollision activation on arms: " + str(isSuccess)
# Example showing how to deactivate "LArm" anticollision
# Anticollision can be inactivated only if there is no collision in the desired chain
pChainName = "LArm"
collisionState = motionProxy.isCollision(pChainName)
pEnable = False
isSuccess = motionProxy.setCollisionProtectionEnabled(pChainName, pEnable)
print "isSuccess: ", isSuccess
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_setcollisionprotectionenabled.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
Allow to know if the collision protection is activated on the given chain.
Parameters: |
|
---|---|
Returns: | Return true is the collision protection of the given Arm is activated. |
Give the collision state of a chain. If a chain has a collision state “none” or “near”, it could be deactivates.
Parameters: |
|
---|---|
Returns: | A string which notice the collision state: “none” there are no collision, “near” the collision is taking in account in the anti-collision algorithm, “collision” the chain is in contact with an other body. If the chain asked is “Arms” the most unfavorable result is given. |
#include <iostream>
#include <alproxies/almotionproxy.h>
int main(int argc, char **argv)
{
std::string robotIp = "127.0.0.1";
if (argc < 2) {
std::cerr << "Usage: almotion_iscollision robotIp "
<< "(optional default \"127.0.0.1\")."<< std::endl;
}
else {
robotIp = argv[1];
}
AL::ALMotionProxy motion(robotIp);
// Example showing how to get the collision state
std::string pChainName = "LArm";
std::string collisionState = motion.isCollision(pChainName);
std::cout << pChainName << " collision state: " << collisionState << std::endl;
return 0;
}
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
def main(robotIP):
PORT = 9559
try:
motionProxy = ALProxy("ALMotion", robotIP, PORT)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: ",e
sys.exit(1)
# Example showing how to get the collision state
pChainName = "LArm"
collisionState = motionProxy.isCollision(pChainName)
print pChainName + " collision state is " + collisionState +"."
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python almotion_iscollision.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)