Self-collision avoidance API

NAOqi Motion - Overview | API


Method list

class ALMotionProxy
bool ALMotionProxy:: setCollisionProtectionEnabled ( const std::string& ChainName , const bool& Enable )

Enable/Disable Anti-collision protection of the arms of the robot.

Parameters:
  • ChainName – The chain name {“Arms”, “LArm” or “RArm”}.
  • Enable – Activate or deactivate the anti-collision of the desired Chain.
Returns:

A bool which return always true.

almotion_setCollisionProtectionEnabled.py


              
               #! /usr/bin/env python
# -*- encoding: UTF-8 -*-

"""Example: Use setCollisionProtectionEnabled Method"""

import qi
import argparse
import sys


def main(session):
    """
    This example uses the setCollisionProtectionEnabled method.
    """
    # Get the service ALMotion.

    motion_service  = session.service("ALMotion")

    # Example showing how to activate "Arms" anticollision
    chainName = "Arms"
    enable  = True
    isSuccess = motion_service.setCollisionProtectionEnabled(chainName, enable)
    print "Anticollision activation on arms: " + str(isSuccess)

    # Example showing how to deactivate "LArm" anticollision
    chainName = "LArm"
    enable = False
    isSuccess = motion_service.setCollisionProtectionEnabled(chainName, enable)
    print "isSuccess: ", isSuccess


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="127.0.0.1",
                        help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
    parser.add_argument("--port", type=int, default=9559,
                        help="Naoqi port number")

    args = parser.parse_args()
    session = qi.Session()
    try:
        session.connect("tcp://" + args.ip + ":" + str(args.port))
    except RuntimeError:
        print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
               "Please check your script arguments. Run with -h option for help.")
        sys.exit(1)
    main(session)

              
             
bool ALMotionProxy:: getCollisionProtectionEnabled ( const std::string& ChainName )

Allow to know if the collision protection is activated on the given chain.

Parameters:
  • ChainName – The chain name {“LArm” or “RArm”}.
Returns:

Return true is the collision protection of the given Arm is activated.