I’ve now got the camera working in human operated mode but when we switch over to autonomous nothing happens. I’ve also included tracking.h in user_routines_fast.c, Our code currently looks something like this:
Kevin’s camera state handler (Camera_Handler(), I believe) wants to be called in the “slow loop” (every 26.2 ms). It counts how many times it has been called to determine how long it has been to determine if a time-out condition has occurred. Make sure your code is calling Camera_Handler() only when there is new data:
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
Camera_Handler();
Servo_Track();
///////////////////////////////////////////
//Add whatever code you want here.//
///////////////////////////////////////////
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
Also, uncomment the #define for _DEBUG in camera.h and see what you get in the terminal window when you turn on auton. You should see either the initialization like you would in user mode, or tracking packets (that might only apply to Kevin’s “Bells and Whistles” version; not sure).
I have the Camera_Handler() and Servo_Track() functions where you said to put them. I am using Kevin’s bells and whistles code but when i enable debugging one of motors goes full forward and one goes full reverse (but that just could be because of how we have them mounted).
Enabling _DEBUG mode should not change how your 'bot reacts to anything (but it might; I’ve proven that with code, physical impossibilities become totally possible and what was extraordinary becomes a common occurance…:yikes: ). Just for now, comment any code that deals with the motors during auton. Look in the terminal window and see what you get. You need to know if the camera is still getting initialized like normal. If it is, the problem is with your drive code.
My guess is that the camera is initializing fine, and as soon as it sees a target, it gives both motors 170, which, depending on your setup, motor polarity, transmissions, etc. might look like a full power spin. Try reversing one of the motors (it would be pwm15 = 84; I think).
It says Camera: Initialized abnormally with code. Unfortunatly I’ve had to leave our work area and won’t be able to get back to the robot until monday so I won’t be able to do any more testing.
I would suggest you probably don’t look at this thread until Monday–you’ll drive yourself nuts between now and Monday if you keep thinking about it. However: Do you remember what code it was? Was it 131? That’s the common timeout code. Why it would occur in auton and not in user mode baffles me; I hope Kevin Watson sees this and responds. His posts are usually better than mine.
Yes, there is a reason. Kevin didn’t modify the autonomous function to use the interrupt-based PWM generation he included with the camera code. You need to replace the Generate_Pwms() call with PWM(pwm13,pwm14,pwm15,pwm16) instead.