IEEERobotics / high-level

CV, localization, mapping, planning, and generally anything that will run on the PandaBoard
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

Entry point for vision process spawn #4

Closed dfarrell07 closed 11 years ago

dfarrell07 commented 11 years ago

The controller, when spawning the vision process, needs to point the process at a target function that will be run first and will accept the shared memory objects (currently a dict of lists and dicts). This new function should kick off all vision things, not require being called as main and not require creating a vision object.

napratin commented 11 years ago

We can have a vision.py module within qwe.vision sub-package, and a run() method in it along the lines of what has been created in Planner.py (a similar convention can be applied for all packages, i.e. a .py file by the same name with a run method). On a related note, I suggest promoting the contents of qwe.vision.cv to qwe.vision - one reason being that an OpenCV namespace is also called 'cv' which may introduce confusion. If anyone has any strong reasons not to, please notify here, otherwise I'll go ahead and make these changes.

dfarrell07 commented 11 years ago

I'm not seeing that vision.py module - have you pushed it?

daniel:~/Robot/current/high-level/qwe/vision$ grep -rni "run" ./* ./cv/linedetection.py:127:# Run a LineDetector instance using pycv.main.main() ./cv/colorfilter.py:177:# Run a ColorFilter instance using main.main() ./cv/linewalking.py:35: # Run LineDetector for one iteration ./cv/linewalking.py:36: keepRunning, imageOut = self.detector.process(imageIn, timeNow) ./cv/linewalking.py:56: return keepRunning, imageOut ./cv/linewalking.py:70:# Run a LineWalker instance using pycv.main.main() ./cv/main.py:2:Driver program for running a FrameProcessor. ./cv/main.py:12: """Run a FrameProcessor on a static image (repeatedly) or on frames from a camera.""" ./cv/main.py:70: keepRunning, imageOut = processor.process(frame, timeNow) ./cv/main.py:73: if not keepRunning: ./cv/main.py:114:# Run main() function daniel:~/Robot/current/high-level/qwe/vision$ ls -R | grep -i vision daniel:~/Robot/current/high-level/qwe/vision$ git pull Already up-to-date. daniel:~/Robot/current/high-level/qwe/vision$

dfarrell07 commented 11 years ago

I don't know of a good reason not to do the package refactoring that you described.

dfarrell07 commented 11 years ago

I'm still not seeing the vision.py module or the run() function. Please go ahead and push it when you get a chance.

dfarrell07 commented 11 years ago

Wow, sorry, just noticed the wording is "can have" - I thought you were saying that this code already existed, and I was just waiting on you to push. Sorry for the confusion!

napratin commented 11 years ago

Yes, sorry about that - I'm still working on it.

napratin commented 11 years ago

Code pushed; qwe.vision.vision.run() will be the entry point. Some modification may be required (replace context argument with bot_loc, blocks, etc.).

dfarrell07 commented 11 years ago

I made the modifications you described above. Controller now spins up a vision process.

napratin commented 11 years ago

I noticed you commented out visManager.start() in vision.py -> run(). Was it not working properly? It should simply open an available camera and start the appropriate vision processors. I'm going to modify it to accept a single argument - filename for a static image or video, that should help in development.

dfarrell07 commented 11 years ago

I think it was crashing when I commented that out, but it seems to be working perfectly now. I'll let you uncomment it, since you're making other changes and I don't want to cause you to have to deal with a manual merge.

napratin commented 11 years ago

I somehow feel it might be better to have each module's entry point be an instance of a subclass of multiprocessing.Process (overriding the run() method), than using a generic Process object and calling start(target=...). E.g. if vision.VisionManager inherited from Process, you could simply do:

pVision = VisionManager(bot_loc, waypoints, ...)
pVision.start()

The advantage (I hope) is you could then do something like pVision.stop() (I actually have that method, so you could try), or even pVision.deactivateProcessors() (that too!). Not to mention, share the entire pVision object (this would be especially beneficial for Navigator and SerialInterface). But I don't know how multiprocessing works - is it even possible to call methods of a Process instance while it is running? Thoughts?