Machine Vision Localization System
Overview
This is a machine vision system that tracks multiple targets and can send out the positions via the serial port. It was developed specifically for the Swarm Robotics project, but can be adapted for other uses. It is based upon the Indoor_Localization_System, but has several enhancements and bug fixes. Refer to Indoor_Localization_System for a basic overview of the setup of the system and the workings of the patter identification algorithm.
Major Enhancements/Changes
- The system will now mark the targets with an overlay and display coordinate data onscreen.
- The serial output is now formatted for the XBee radio using the XBee's API mode with escape characters.
- The calibration routine has been improved, and only needs to be performed once.
- A command interface for sending out commands via the serial port has been added.
- The system will discard targets too close to the edge of the camera frame to prevent misidentification due to clipping.
- The origin of the world coordinate is now in the middle, not the lower left corner.
- The GUI displaying the camera frames is now full sized instead of a thumbnail. However, if your monitor isn't big enough, you can resize them.
Major Bug Fixes
- Two major memory leaks fixed.
- Calibration matricies are now calculated correctly.
- File handling bug that causes an off-by-one error in LoadTargetData() fixed.
Camera Calibration Routine
The camera calibration routine used is explained in the document Image_Formation_and Camera_Calibration.pdf by Professor Ying Wu.
Target Patterns
The target patterns and preprocessor can be downloaded at Indoor_Localization_System#Pre-processing_program_source_with_final_patterns:.
Operation
Setting up the Cameras
The cameras should be set up according to Indoor_Localization_System with one caveat: targets at the edge of the camera frame will now be discarded. This prevents misidentification of patterns if one or more dots in the pattern fall off the screen, but it also means that there must be enough overlap that when the target is in the dead-zone of one camera, it is picked up by another camera.
Starting the Program
- When you first run the program, it will open up a console window and ask you to enter a COM port number. This is the number of the serial port that will be used to send out data. Enter the number, and press Enter. (e.g. Enter COM number: 4<enter>)
- The program should now connect to the cameras, and will open two new windows: one with numbered quadrants (the GUI window), and one displaying the view of one of the cameras. Use you mouse to click on the quadrant that corresponds to the camera view. Repeat until all four cameras have been matched to the quadrants.
- Make sure the GUI window is selected, and press Enter.
- Go back to the console window, and you should now see a message asking you if you want to recalibrate your cameras. Press y for yes and n for no, then press Enter. To recalibrate your cameras, see the calibration section.
- The GUI window should now show a thresholded image, and the console will display how many dots the camera sees. Adjust the thresholding parameters (+ and - for black/white, z and x for area) until you are satisfied with the thresholded image.
- Make sure the GUI window is selected, then hit Enter.
- Remove any calibration patterns, and hit Enter. The program should now be running.
Pausing
Hit 'p' to pause the program, and hit 'p' again to resume.
Using the Command Console
To enter the command mode, hit 'c'. When in the command mode, the main loop is not running; the command mode must be exited to resume. Type 'exit' to exit the command mode and resume the main loop.
Enter commands in the following syntax:
<command name> <target ID> <parameter 1> <parameter 2> ... <parameter N>
To broadcast the message, use ID 0.
You can also enter multiple commands at a time:
sleep 0 sleep 1 sleep 2 goto 0 100 -100 deadb 0 150
Commands
Command | Description | Parameters | Example |
---|---|---|---|
sleep | The robot will stop moving and stop sending data | sleep <ID> | sleep 0 |
wake | The robot will wake from sleep and resume moving and sending data | wake <ID> | wake 0 |
goal | Update the robot's goal state. | goal <ID> <Ix> <Iy> <Ixx> <Ixy> <Iyy> | goal 0 100 300 160000 40000 40000 |
sleep 1.0 sleep wake 2.0 wake (resets x_i consensus values) goal 3.0 change goal parameters goto 4.0 change goal position only (formation is the same) deadb 5.0 change motor low-velocity deadband egain 6.0 change estimator gains KP,KI,GAMMA cgain 7.0 change controller gains commr 8.0 change COMMR speed 9.0 change MAX_WHEEL_V_TICKS safed 10.0 change obstacle avoidance theshold SAFEDIST
Exiting the Program
Press ESC to quit the program.