Go to Post Indeed, the more ways you fail, the more ways you know something doesn't work.:) - Steven Sigley [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 12-02-2007, 22:56
Ianuser Ianuser is offline
Registered User
FRC #0570
 
Join Date: Feb 2007
Location: new york
Posts: 64
Ianuser is an unknown quantity at this point
I'm having trouble with this camera stuff

Ok, I want to make a button turn off the camera and then the same button turn on the camera. THis is what I have. (This is in the Default_Routine())

Code:
             int now4; //for mapping p3_sw_aux2 to ON or OFF (reset CAMERA)
	int last4;	//for mapping p3_sw_aux2 to ON or OFF (reset CAMERA)

	last4 = now4;
	now3 = p3_sw_aux2;
some joystick stuff...then..

Code:
if((Get_Camera_State() == 0) && (now4 == 1) && (last4 == 0))
  {
   	  Restart_Camera(); //Sets Camera in Recieving Mode so it can be used.
  }
  
  if((Get_Camera_State() == 1) && (now4 == 1) && (last4 == 0))
  {
	  Camera_Idle(); //Sets Camera in OFF Mode in case we need to stop chasing the light and go into manual mode to go back to home base or something
  }
Will Camera_Idle() stop the Camera from functioning so the robot will no longer track the light? It does, right? Cuz it stops the initialization of it. So, doesn't Restart_Camera() do the opposite of Camera_Idle()? If not, please tell me if there's a way in which I can do this? Maybe I'm mapping the button incorrectly, but its not working, I know that.

p.s. The camera works fine (sorta, thats another story though), it just doesn't stop searching when I press the button. I want it to stop searching when I press the button.
  #2   Spotlight this post!  
Unread 12-02-2007, 23:35
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: I'm having trouble with this camera stuff

If you want the camera to stop searching, just stop calling Servo_Track().
  #3   Spotlight this post!  
Unread 13-02-2007, 04:08
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: I'm having trouble with this camera stuff

How exactly do you stop calling a function? Unless you use an if code to define that once something happens, move on with the code, not going over Servo_Track() again, how can you stop calling it?
  #4   Spotlight this post!  
Unread 13-02-2007, 09:42
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: I'm having trouble with this camera stuff

Quote:
Originally Posted by Bomberofdoom View Post
How exactly do you stop calling a function? Unless you use an if code to define that once something happens, move on with the code, not going over Servo_Track() again, how can you stop calling it?
That is exactly how you do it.
Code:
  if(I_want_to_search)
    Servo_Track();
Just make "I_want_to_search" true to begin with, and make it false when you don't want to call Servo_Track() anymore.
  #5   Spotlight this post!  
Unread 13-02-2007, 10:28
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,183
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: I'm having trouble with this camera stuff

Quote:
Originally Posted by Ianuser View Post
Will Camera_Idle() stop the Camera from functioning so the robot will no longer track the light? It does, right? Cuz it stops the initialization of it. So, doesn't Restart_Camera() do the opposite of Camera_Idle()? If not, please tell me if there's a way in which I can do this? Maybe I'm mapping the button incorrectly, but its not working, I know that.

p.s. The camera works fine (sorta, thats another story though), it just doesn't stop searching when I press the button. I want it to stop searching when I press the button.
When the camera has a green color blob in its view, it sends T packets over the serial port to the RC.

Servo_track() looks to see if there are new t packets in the input buffer. If there are, the RC knows that the camera sees a color blob and locks on to it. If there are no new t packets, the camera will go into its search routine (as it does not see any color blobs..)

Camera_Idle() writes a "\r" to the camera serial port. This tells the camera to stop what its doing, and to stop sending t packets.

Restart_camera() simply sets an initialization flag to 0, so when the Initialize_Camera() function is called, it will return all of the internal workings of the camera back to their default (this is probably for users who want to mess around with polling mode, virtual windows, gains, etc..)

The problem you are having is you are Initializing the camera (default in user_routines.c from the camera workspace), stopping the camera from sending t packets, and then clearing the init flag. You are never telling the camera to turn back on. You can do this in one of two ways.
A) Call Initialize_Camera() again.
B) Call Track_Color() with the default stuff as arguments.
I would do the latter as re-initializing the camera will cause it to go through a bunch of code that isnt going to do anything. Also, you don't need to call Reset_Camera() ever.
  #6   Spotlight this post!  
Unread 13-02-2007, 10:45
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: I'm having trouble with this camera stuff

Code:
if(p3_sw_top)
    {
          Servo_Track();
    }
else
    {
          (Whatever, set servos to 127 or something)
    }
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
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
Having trouble with your camera mount? Chriszuma Programming 7 01-02-2005 22:12
Anyone else having trouble keeping up with work? D. Gregory General Forum 36 28-03-2004 16:55
Having trouble with TTL port Gene F Programming 12 10-02-2004 15:23
Im am having trouble with the MPLAB hedgehogger Programming 7 19-01-2004 17:37
I'm having trouble sleeping!! archiver 1999 5 23-06-2002 22:38


All times are GMT -5. The time now is 02:31.

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