-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera_readme.txt
164 lines (111 loc) · 4.95 KB
/
camera_readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
****************************************************************
You are free to use this source code for any non-commercial
use. Please do not make copies of this source code, modified
or un-modified, publicly available on the internet or
elsewhere without permission. Thanks.
Copyright ©2005-2006 R. Kevin Watson. All rights are reserved.
****************************************************************
*** "Streamlined" version of the camera code ***
The source code in camera.c/.h contains software to configure
and parse the data stream of your CMUcam2 vision sensor.
Support can be had by visiting the Chief Delphi forums and
posting a question in the programming forum. You are encouraged
to report software and documentation bugs there too. The URL is
http://www.chiefdelphi.com
This source code will work with the PIC18F8520-based FRC robot
controller from 2004/2005 and the newer PIC18F8722-based FRC
robot controller. It will also work with the nifty EDU robot
controller.
The included project files were built with MPLAB version 7.20.
If your version of MPLAB complains about the project version,
the best thing to do is just create a new project with MPLAB's
project wizard. Include every file except: FRC_alltimers.lib
and ifi_alltimers.lib and you should be able to build the code.
****************************************************************
Six things must be done before this software will work
correctly with your robot controller:
1) Install the serial_ports.c/.h software using the
instructions found in serial_ports_readme.txt. This software
can be downloaded from http://kevin.org/frc.
2) You need to add camera.c and camera.h to your project.
Do this by copying the two files to your project directory
and then right clicking on "Source Files" in the project
tree, selecting "Add Files...", if necessary, navigate to
the project directory and then double click on camera.c.
Repeat the above procedure for camera.h under "Header Files".
3) A #include statement for the camera.h header file must be
included at the beginning of each source file that calls the
functions in camera.c. The statement should look like this:
#include "camera.h".
4) The function Camera_Handler() function must be called
from Process_Data_From_Master_uP() each time it executes.
5) The global variable "stdout_serial_port" must be set to
point to your terminal serial port. This can automatically
be done by inserting this code into User_Initialization():
#ifdef TERMINAL_SERIAL_PORT_1
stdout_serial_port = SERIAL_PORT_ONE;
#endif
#ifdef TERMINAL_SERIAL_PORT_2
stdout_serial_port = SERIAL_PORT_TWO;
#endif
6) Select the robot controller serial port that your camera
will communicate through by opening the camera.h file and
following the embedded instructions. By default, serial port
two (the TTL-level port) is used.
****************************************************************
Here's a description of the functions in camera.c:
Camera_Handler()
This function is responsable for camera initialization
and camera serial data interpretation. Once the camera
is initialized and starts sending tracking data, this
function will continuously update the T_Packet_Data data
structure with the received tracking information.
Camera_State_Machine()
This function parses the camera serial data stream looking
for data packets, ACKs and NCKS. When packets are complete
the individual packet counter variable is incremented and,
in the case of packets, the global data structure is
updated with the new data.
Initialize_Camera()
This function is responsable for initializing the camera.
Track_Color()
This function properly formats and sends a "Track Color"
command to the camera.
Camera_Idle()
If the camera is currently streaming data, this function
will stop the streaming and prepare it to receive commands.
Restart_Camera()
This function forces a camera reinitialization.
Get_Camera_State()
This function returns the operating state of the camera.
The two possibilities are initializing and initialized
and sending data packets.
Raw_Mode()
This function properly formats and sends a "Raw Mode"
command to the camera.
Noise_Filter()
This function properly formats and sends a "Noise Filter"
command to the camera.
Write_Camera_Module_Register()
This function properly formats and sends a "Camera Register"
command to the camera.
Camera_Serial_Port_Byte_Count()
This function returns the number of bytes in the camera
serial port's received data queue.
Read_Camera_Serial_Port()
This function reads a byte of data from the camera serial
port.
Write_Camera_Serial_Port()
This function sends a byte of data to the camera serial
port.
Terminal_Serial_Port_Byte_Count()
This function returns the number of bytes in the terminal
serial port's received data queue.
Read_Terminal_Serial_Port()
This function reads a byte of data from the terminal serial
port.
Write_Terminal_Serial_Port()
This function sends a byte of data to the terminal serial
port.
Kevin Watson