Back to discussions page
How to trigger events along a Copilot Path
/ Most recent by bcastets
PierreOlivier_Proulx Beta Tester VIsion 1.1 Program, Vacuum Beta tester Posts: 69 Handy
Let's say you want to start a process at a certain point on a path recording and stop before the end of the path, how would you do that? Here is a clean technique that will allow you to do such a thing.
Here are the steps to build this program:
- Record a Path
- In the BeforeStart node, wrap a MoveL in an If False node. This trick defines waypoints without executing them.
- Move the robot along the path with the play button (▶️) and stop were you want to start the process.
- Record this pose in the start_process waypoint
- Do the same thing for the stop_process waypoint.
- In a thread, monitor the distance between the tool and the waypoint. If the robot passes close to the waypoint, execute some code.
When you play the program, the thread will monitor the robot pose. When the tool passes near the waypoints, it will execute the process code.
I see two caveats to this technique. First, if the robot moves close to the waypoint in another part of the program, the process will be executed. To solve this, you could guard the thread with a flag; set if before the path and clear it after. Second, the thread could execute the process many times if the robot does not leave the waypoint vicinity fast enough. If you only set an output, this is not a problem.