stop a cog while it's busy?
xanadu
Posts: 3,347
I'm using coginit and cogstop. Inside the new cog is a timer, and while the timer is running the cog won't shut off using cogstop. Is there a way to make the cog stop even though it is executing an instruction or can the new cog only stop between instructions?
Thanks!
Thanks!
Comments
-Phil
The above code listens for z or c character on XBee.
The above code moves the pan tilt servos to predefined positions.
Thanks a lot!
That way it's not waiting until the end like below?
[Edit] Am I mistaken or is that my servo object (jm_servo8_adv) you're using? That would explain why the servo doesn't stop -- the movement to destination is still in progress. Maybe I should add a halt method that will stop the servo where it is.
I thought that without the pause the cog has to stop instantly because it's going line to line fast.
Here is how I'm stopping the cog:
Hey JM thanks, I'm using your servo object. Working great again on yet another project. What you said makes sense I hadn't even thought about the servo object. I'm still really confused about why shutting down my cog that calls your object wouldn't stop the servo though. I'm trying to write a demo code not involving servos just LEDs and timers to work it out.
Add these to methods to your copy of the object:
Then you can update you patrol method to look like this -- it's more work, but it allows the method to stop the servos before committing on-demand hari-kari:
There may be a way to make this more elegant but without the full listing and understanding the intent, I'm taking the easy route. Of course, killpatrol is a global variable. You need to set this back to false before relaunching patrol.
I'm adding in the method, by your example so I can keep the vars in sync for coming out of patrol into manual, otherwise I'd probably just do the above only.
Thanks!!
Or I'll just use this... hehe thanks!