Go to Post The programmers tend to get less credit than they deserve, but the robot wouldn't run if we weren't there. :) - IMDWalrus [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-02-2007, 19:14
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Getting the camera to work in autonomous

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:
Code:
Getdata(&rxdata);  
Camera_Handler();
Servo_Track();

if (Get_Tracking_State == TARGET_IN_VIEW)
    {
      pwm13 = pwm15 = 170;
    }
else
    {
      pwm13 = pwm15 = 127;
     }

Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

Putdata(&txdata);
I was simply trying to see if i could get the motors to respond to what the camera was seeing. Is there some reason why this isn't working?
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #2   Spotlight this post!  
Unread 10-02-2007, 19:21
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Getting the camera to work in autonomous

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:
Code:
  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).

JBot
__________________
Aren't signatures a bit outdated?

Last edited by JBotAlan : 10-02-2007 at 19:23.
  #3   Spotlight this post!  
Unread 10-02-2007, 19:58
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Getting the camera to work in autonomous

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).
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #4   Spotlight this post!  
Unread 10-02-2007, 20:11
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Getting the camera to work in autonomous

Quote:
Originally Posted by dpick1055 View Post
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... ). 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).

JBot
__________________
Aren't signatures a bit outdated?
  #5   Spotlight this post!  
Unread 10-02-2007, 20:25
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Getting the camera to work in autonomous

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.
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #6   Spotlight this post!  
Unread 10-02-2007, 20:38
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Getting the camera to work in autonomous

Quote:
Originally Posted by dpick1055 View Post
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.

JBot
__________________
Aren't signatures a bit outdated?
  #7   Spotlight this post!  
Unread 10-02-2007, 20:54
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Getting the camera to work in autonomous

Quote:
Originally Posted by dpick1055 View Post
Code:
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
I was simply trying to see if i could get the motors to respond to what the camera was seeing. Is there some reason why this isn't working?
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.
  #8   Spotlight this post!  
Unread 10-02-2007, 20:56
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Getting the camera to work in autonomous

Sorry I don't remeber what the code was. Though would you get a timeout error if the camera never starts searching?
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #9   Spotlight this post!  
Unread 10-02-2007, 20:57
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Getting the camera to work in autonomous

When I first started playing with autonomous I just sent the motors full forward which only worked with generate_pwms and not PWM.
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the Camera out of Idle Eclipse Programming 2 13-02-2007 04:06
Camera did not work for well at the regionals, but worked great at home. Alan Ing Programming 12 17-04-2006 17:43
even simple autonomous code doesn't work?? colman77 Programming 4 17-02-2006 23:58
Getting the Camera and Default Code to Work nukem Programming 5 18-01-2006 11:48
Anyone get Autonomous mode to work? Larry Barello Control System 4 13-01-2004 15:15


All times are GMT -5. The time now is 11:00.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi