Parameter definitions

 

Figure 1 Parameter definition

 

X,Y = ground fixed coordinates

¦§,¦Î = car body fixed coordinates

¦× = vehicle orientation (b_orient), 0¡ª360 degrees

¦È = vehicle angle to way point (angle_to_w_p_b) 0¡ª360 degrees

¦Ä = relative angle of way point with respect to the car body fixed system ¨C180¡ª180 degrees

¡ã = way point

 

 

We use the color camera to differentiate two cars that are same in size, shape but are different in color. The camera is set up outputting 16-bit RGB data. Since EDMA can take in 32-bits of data at one single time. We down sample the clock rate of the color camera by two and temporarily store the image data in 4 8-bit latches.

 

At the start of transfer of image data, interrupt 6 is triggered on DSP. The ISR initiates the EDMA transmission data such as starting address in memory and data length. When EDMA finishes transferring, it triggers and SWI, the SWI service routine sets the flag  ¡°picdma_done¡±. At the meanwhile, a period function ¡°processvisiondata¡± constantly checks the ¡°picdma_done¡± flag. If a image is successfully transmitted and the flag is set. ¡°processvisiondata¡± calls function ¡°compressImage¡±, where the main code of image processing and remote car control is at.

 

The vision processing can be divided into following steps:

1.      Compress the image to 1/16 of its original size and remove the Bayer pattern at the same time

2.      Threshold the image to get binary image. We chose colors that would appear very strong in one of the three channels.

3.      The cars have rectangular shape in the image. And tow cars don¡¯t appear in channel at the same time. The center of the bright pixels is calculated based on the average value of pixel coordinates. The orientation is calculated using an algorithm introduced in ¡°Intro. To Vision Processing¡±. The file can also be accessed here.

4.      Since rectangular is symmetric with respect both axis, the orientation algorithm tells only an angle between ¨C90 and 90 degrees. We need extra help to find out where the car is facing. In this case, we use a third color (a piece of yellow paper we stick to the hood of the car, which appears strong the camara¡¯s green channel) to highlight the front of the car. By getting the center of the third color, and compare its coordinates with the center of the car, we can assign signs to the orientation value we obtained above. After some conversion, we make the orientation angle lie in the range of 0 to 360 degrees. This angle is denoted by ¦× in Figure 1.

5.      We calculate the orientation of the vector pointing from the center of the car to the waypoint. This angle, ¦È in Figure 1, defined in the ground fixed coordinate system is used to derive the waypoint angle in the car body fixed coordinate system. After some conversion, the relative angle of the waypoint with respect to the car lies in the range from ¨C180 to 180 degrees. We define it in such a way that if the way point is to the right of the car, the angle value is positive.

6.      The car is driven by writing to 8 bits to the parallel port (GPIO), 4 bits to control each of the cars. The 4 bits are defined in the following way:

FWD

REV

LFT

RT

7.      Since the remote car can drive either at full speed or come to a complete stop, we use a PWM like scheme to control the forward and backward movements by drawing the corresponding control bit low every fourth cycle.

 

The code is well commented. The above functionalities can easily be found with the help the comments.

 

Since the image from the color camera appear to have a fake color, we also wrote some code to enable us to modify the individual camera register from our VB program. The VB sends a serial message consisting to integer values divided by a capital ¡°X¡±. The DSP receives the message and retrieve the integer values by identifying the ¡°X¡± in the message. The first integer value is the camera register address defined in the camera datasheet. The second integer is the register value. We set up I2C to transmit only two 8 bits data. The first 8 bits we transmit the register address (called camera sub-address in the datasheet), the second 8 bits carry the register value. This code can also be found in ¡°c6713color.c¡±

 

 

Back