Closed dfarrell07 closed 11 years ago
@dfarrell07 Yes, the way SI works has changed a little, in order to properly do multiprocessing (it also doesn't break anymore if port is unavailable, so testing is easy). It's easiest for me to do this in code, so I am going to modify controller.py now and do it there. I haven't seen any updates to controller.py in the last few days, so I'm hoping no conflicts arise. Either way, my changes will be minimal, and git is there for managing conflicts.
Essentially, in controller.py (I've discussed this with Srinath):
si = comm.SerialInterface()
si.start()
scPlanner = SerialCommand(si.commands, si.responses) # si.commands and si.responses are process-safe shared structures
pPlanner = Process(target=planner.run, args=(bot_loc, blocks, zones, waypoints, scPlanner, bot_state, qMove_nav))
scNav = SerialCommand(si.commands, si.responses)
pNav = Process(target=nav.run, args=(bot_loc, course_map, waypoints, qNav_loc, scNav, bot_state, qMove_nav))
pNav.start()
scPlanner.quit()
While I'm in controller.py, as discussed with Srinath, I'm also going to add a shared blobs list that we need between vision and planner.
I've committed my changes to controller. I also modified vision to accept the changed set of arguments. Other processes also need to change their run method to accept all shared variables properly.
Note that SerialCommand exposes the same high-level methods that SerialInterface did earlier, so they may not need to modify anything on that front.
During my unit tests, I create a comm.SerialInterface object and start it. When my tests complete, I need its threads to terminate, so that my tests will actually return. @napratin's latest updates seem to have changed SIs behavior in such a way that keeps it from terminating at the end of my tests (nothing bad implied, updates are good, lol).
I see that there's a quit command that I should be using to terminate the send and receive threads. So, I guess this boils down to a more general question about how I should send a command to SI, specifically a quit command. How do I do that, @napratin? Thanks!