I’ve run into an issue before trying to control one specific motor from multiple states and I’m now having the same problem controlling a servo so I figured this same concept may apply to many different types of hardware…thus the new thread. For the motor I worked with nkrkv to make a new library and work some hacks to make it work and it did. For the servo I’m trying to do it myself using what I learned from the creating nodes in c++ documentation. I think I’m close but it is still a little buggy. The issue comes from having multiple states trying to control the same hardware and I’ve ended up with conflicting values and unpredictable results. My solution is to have each state attach the servo on “SET” and then detach the servo on “DONE”. I modified the standard servo hardware c++ code to have a pulse input for “ATTACH” and another for “DETACH”. I’ve uploaded a picture showing the stock servo code on the left and my modified version on the right.
This seems to work well for a program that has no feedback loops. The issue is when I try to implement a feedback loop using the “defer-pulse” node the program only runs one time and never repeats. In the 2nd picture the left main function works properly but the right one never repeats. The rightmost picture shows the structure of my “lookleft”, “lookright”, and “lookstraight” patches with the only difference being the number bound to the gate.
I’ve also attached the .xodball file.
sharedResourceServo.xodball (52.3 KB)
Please help me to understand why this program is not repeating and how to fix it.