Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Capturing Simulation Collisions

#1
Hi,

I have a question regarding capturing a collision via the Python API. I want to run a master program in my simulation via the API and catch any collisions that may occur. I would like to print some information about the collision and then move on with the simulation program.

Code:
try:
    RDK.setSimulationSpeed(speed=1)
    RDK.setCollisionActive(check_state=COLLISION_ON)
    mstr_program.RunProgram()
    mstr_program.WaitFinished()
except Exception as error:
    print(error)

I was hoping that the code block above would catch collisions but it doesn't. Any suggestions?
#2
You can check if a program fails without executing it by calling Update on your program:
https://robodk.com/doc/en/PythonAPI/robo...tem.Update

Example:
Code:
# Update the program and retrieve updated information:
# https://robodk.com/doc/en/PythonAPI/robodk.html#robodk.robolink.Item.Update
result = program.Update()
instructions, time, travel, ok, error = result
#3
Thank you Albert. The program.Update() method works but takes significantly longer to execute than if I were to just run the simulation manually with collision checking turned on. Do you have any idea why this may be?
#4
Thank you for your feedback!

The discrepancy between the simulation speed and the Update function speed happens because the Update function checks for collisions at regular intervals (set to 4 mm and 4 deg by default), regardless of the simulation speed. You can configure the step used to check for collisions using the Update function in Tools-Options-Motion.
#5
Thank you Albert. I did some studies were I incremented the mm_step and deg_step parameters passed to the .Update() method. As I increased the step sizes, the method run time decreased significantly.
#6
Wonderful, thank you for letting us know.

To have faster collision detection I also recommend you to use the Simplify Mesh Add-in. This addin allows you to simplify the geometries of your objects. This will convert complex objects that have many triangles or complex shapes into simpler shapes, optimized for collision checking.

You can find the Simplify Mesh add-in here:
https://robodk.com/addin/com.robodk.app.simplifymesh
#7
Hi Albert,

I have a follow-up question for using the `program.Update()` method. If I call `Update` on a program, and that program includes instruction calls to other RoboDK programs, will those nested (called) programs also be checked by `Update`? How deeply nested will `Update` go?

Thank you,
Sammy
#8
Updating a program with the Update command will account for all subprograms that exist in the same RoboDK project.

A quick workaround if you want to avoid checking subprograms is to rename them so they are considered different and not accounted for while you trigger Update.
  




Users browsing this thread:
1 Guest(s)