How to stop and restart mc_run_motion()

Hi,
how to stop movement of robot after mc_run_motion()? I would like to do something like this (it’s a dump example just to show you the case):

thread mc_motion_thread():
    mc_run_motion()
end

mc_initialize(0, tcp, 6)

# motion from p1 to p2 takes much more than 5 seconds
mc_add_linear(p1, a, v, blend)
mc_add_linear(p2, a, v, blend)

thrd = run mc_motion_thread()

# wait 5 seconds
sleep(5)

STOP_MC_MOTION_HERE (how to?)

How to stop the movement of mc_run_motion()? And how to “restart” mc_run_motion daemon, so I could again: mc_initiaze(…), mc_add_linear(…) and mc_run_motion()?

You can stop his execution with a kill

So, in your exemple, you must replace your STOP_MC_MOTION_HERE by :

kill thrd