4
$\begingroup$

I have a robot arm in an environment. How can I check for collision between this robot arm and the environment?

$\endgroup$

2 Answers 2

3
$\begingroup$

It's really easy.

env = openravepy.Environment()
env.StopSimulation()
env.Load('_ArmFileName'_.xml') #Whatever .xml file you're using
robot = env.GetRobots()[0]
manip = robot.SetActiveManipulator('left_arm') #whatever arm you're using
robot.SetDOFValues(joint_values, manip.GetArmIndices())
env.CheckCollision(robot)

where joint_values is the an array of the joint values that you want. For example, if I was working on the Baxter robot, then I'd make an array of length 7 (7 DOF arm) with each value being values within Baxter's min/max joint values. Also note that you need to specify in the xml that your robot has the appropriate arm.

$\endgroup$
1
  • $\begingroup$ Ohh yes.... It was really simple I thought it would be like env.CheckCollision(robot,environment). Thanks a lot for your reply. $\endgroup$
    – vacky
    Commented Feb 16, 2016 at 2:00
2
$\begingroup$

This is how I do it:

# return True if in collision, False if no collision
# pass in joint angles q to test configuration other than current
def inCollision(q=None):
    with env:
        if q == None:
            return env.CheckCollision(robot) or robot.CheckSelfCollision()
        else:
            initq = robot.GetDOFValues()
            robot.SetDOFValues(q)
            ret = env.CheckCollision(robot) or robot.CheckSelfCollision()
            robot.SetDOFValues(initq)
            return ret

NOTE: OpenRave uses ODE as its collision checker by default. And for some reason, the default build of ODE for Ubuntu does not enable cylinder-cylinder collision checking. You can use Bullet instead if you like, but I have found it to be slower than ODE. Use these lines to change which collision checker OpenRave uses:

collisionChecker = RaveCreateCollisionChecker(env, 'bullet')
env.SetCollisionChecker(collisionChecker)

Or you can just download the ODE source and recompile. These are the steps I follow:

  1. Download the latest ODE (https://bitbucket.org/odedevs/ode/downloads/ode-0.13.1.tar.gz)
  2. ./configure --enable-double-precision --enable-libccd --disable-demos --disable-asserts --enable-shared
  3. make -j8
  4. sudo make install
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.