Go to Post Ah, drills & motors. Brings back old memories of FIRST - nparikh [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, 23:02
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
Where do I begin to get the robot to move using the camera?

This is what I have? I haven't done anything with turning the robot to the correct degree, I'm not very good at this stuff and I'm the only programmer and electrician on the whole team of 5, so i'd really like some help. Here is what I have for this:

Code:
if(Get_Camera_State() == 1)
	{
		if((Get_Tracking_State() == CAMERA_ON_TARGET) && (Find_Distance > set closest range)
		{
			pwm01 = desired forward velocity;
			pwm02 = same forward velocity;
			Switch3_LED = 1;
		}
		else if((Get_Tracking_State() == CAMERA_ON_TARGET) && (Find_Distance() <= set closest range))
		{
			pwm01 = 127;
			pwm02 = 127;
			Camera_Idle(); //Sets Camera in OFF mode so manual mode can continue.
			Switch3_LED = 0;
		}
		else
		{
			Switch3_LED = 0;
		}
Does any of this make sense? I think that Camera_Idle() will stop the whole process of moving the camera around, right? Later I have a button that I press that calls the Restart_Camera funciton which I think undoes the Camera_Idle() process, right? wrong? some help would be great. Also, will this work with moving the robot forward while the CAMERA is on target and the range (Find_Distance) is greater than the range that we want to be at when the robot stops. It looks to me like it would make sense but I realyl don't know what I'm doing. Thanks a bunch everybody.
  #2   Spotlight this post!  
Unread 13-02-2007, 10:47
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: Where do I begin to get the robot to move using the camera?

I know what it feels like to work so many roles. I'm the eletriction, programming, and website guy on our team. Let's see if I can help you any:

Have you tested your code at all or are you just trying this out?

I have found that the CAMERA_ON_TARGET state doesn't work to well. Even if the camera has located the target and its pointing directly at the target, it will modulate and will toggle off and on within state which won't even turn on a relay. Do something like:

Code:
if(Get_Camera_State()) 
{  // You don't need the 1. Anything positive will trigger it.

if((Get_Tracking_State() != SEARCHING && (Find_Distance() > set closest range))
 {
			pwm01 = desired forward velocity;
			pwm02 = same forward velocity;
			Switch3_LED = 1;
}else if((Get_Tracking_State() != SEARCHING) && (Find_Distance() <= set closest range)) {
			pwm01 = 127;
			pwm02 = 127;
			Camera_Idle(); //Sets Camera in OFF mode so manual mode can continue.
			Switch3_LED = 0;
		} else {
			Switch3_LED = 0;
		}
}
This routine is running continously so the camera will update its distance and will stop once in the proper range. I'm not sure how to answer your CAMERA_IDLE and reset questions. Atonomous mode is only 15 seconds so I'm not going to bother with disabling the camera. If you have it running during gameplay that's another story..

The switch leds are really unessicary. Those turn on LEDs on the OI when the camera is on target. I took then out because we won't be looking down too much during the game.

When you start getting down to coding the specifics of the routine, post again and we'll help.
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/

Last edited by pheadxdll : 13-02-2007 at 10:52.
  #3   Spotlight this post!  
Unread 13-02-2007, 15:46
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
Re: Where do I begin to get the robot to move using the camera?

Thanks. I'm getting an error report though
Code:
if(Get_Camera_State())
	{
		if((Get_Tracking_State() != SEARCHING) && (Find_Distance() > 20) && (I_Want_To_Search == 1)) //(errored line)
		{
			pwm01 = 150; //Desired Forward Velocity
			pwm02 = 150;
			Switch3_LED = 1;
		}
		else if((Get_Tracking_State() != SEARCHING) && (Find_Distance() <= 20)) //(errored line)
		{
			pwm01 = 127;
			pwm02 = 127;
			I_Want_To_Search = 0; //Stops calling Servo_Track().
			Switch3_LED = 0;
		}
		else
		{
			Switch3_LED = 0;
		}
	}
The Find_Distance() function is this:
Code:
unsigned int Find_Distance(void)
{
	return(targetRange[pwm07-67]);
}
The error I get is this:
Code:
C:\USFIRST\frc_camera_s_21\CAMERA CODE\user_routines.c:254:Warning [2058] call of function without prototype
C:\USFIRST\frc_camera_s_21\CAMERA CODE\user_routines.c:260:Warning [2058] call of function without prototype
On the lines that I commented "//(errored line)"

What's wrong?
  #4   Spotlight this post!  
Unread 13-02-2007, 16:47
jdejoannis jdejoannis is offline
Registered User
FRC #1845
 
Join Date: Feb 2006
Location: Atlanta,GA
Posts: 48
jdejoannis will become famous soon enoughjdejoannis will become famous soon enough
Re: Where do I begin to get the robot to move using the camera?

Quote:
Originally Posted by Ianuser View Post
What's wrong?
I believe you are missing tracking.h in your #includes and therefore it does not find the prototype for Get_Tracking_State() which was called on lines 254 and 260.
  #5   Spotlight this post!  
Unread 13-02-2007, 17:07
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
Re: Where do I begin to get the robot to move using the camera?

Tracking.h is already in there. It still says the prototype error thing on those lines.
  #6   Spotlight this post!  
Unread 13-02-2007, 19:14
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: Where do I begin to get the robot to move using the camera?

Here's your problem you need to add a declaration of the function at the top of your user_routines_fast.c (or what ever file is running the camera code).

At the top below the includes add:

unsigned int Find_Distance;

and you should be fine. If that errors out just incase try this:

unsigned int Find_Distance(void);
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/

Last edited by pheadxdll : 13-02-2007 at 19:16.
  #7   Spotlight this post!  
Unread 13-02-2007, 23:44
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
Re: Where do I begin to get the robot to move using the camera?

It compiles now, I've changed some things here and there, but the robot wont move. I think I'm doing something completely wrong with the code. Check out this forum if you can help me out. http://www.chiefdelphi.com/forums/sh...t=53916&page=2
  #8   Spotlight this post!  
Unread 14-02-2007, 04:09
Idaman323 Idaman323 is offline
In Theory, Our Robot Would Own.
FRC #1706
Team Role: Driver
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Wentzville, MO
Posts: 116
Idaman323 is an unknown quantity at this point
Re: Where do I begin to get the robot to move using the camera?

Make sure there isn't a call to the joystick values after the code. The default code calls Default_Routine(). So make sure that is still commented out, and any mapping of the joystick values is done before the camera tracking.

It all goes in order, so if you set a value for the motor speed after locking on, and then later in the function, go and overwrite the value with your joystick, its going to be assigned the joystick in the end of the loop.

Yes, no?
__________________
TEAM 1706
2007 Judges Award, St. Louis (For our amazing ability to have bad luck)
2005 Rookie Inspiration Award, St. Louis
  #9   Spotlight this post!  
Unread 14-02-2007, 13:06
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
Re: Where do I begin to get the robot to move using the camera?

Thanks. I made these changes, hopefully it will work:

At the top of user_Routines.c I declared this
Code:
int pwm03_On_Off = 1;
Then in the Default_Routine() where I map to the joysticks I put this
Code:
if(pwm03_On_Off == 1)
  {
	pwm03 = p3_y; //ForkLift
  }
An example of my switch-case statements (for a metal sensor that increments the 'count' variable each time it passes...and there each time it passes certain things happen in the CASE...) is this
Code:
if((pwm03 < 125) || (pwm03 > 129))  //if py_3 is being used (forklift going up or down)
 	{
		if((now == 1) && (last == 0)) //If sensor, which connects to Dig In/Out port 4, sends a signal...
		{
			count++; //Number of times tape passes through the sensor.
			Switch1_LED = 1; //Switch01 goes on when the tape passes the sensor.
		}
		else
		{
			Switch1_LED = 0;
		}

		switch(count) //for sensor module
		{
			case 1:			//if count = 1 then that just means that it passed through the first piece of tape which will be used to show that it is in full DOWN position.

				Relay2_green = 1;
				Relay2_red = 0;
				printf("count = 1");
				break;

			case 2:
		
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 != p3_y;
				pwm03_On_Off = 0;
				pwm03 = 127; //Motor stops when it reaches 1st level of rack.
				printf("count = 2");
				break;
There are more cases, but those are the basic formats of the others anyway. Basically for case 2: I want to have he motor pwm03 stop and the joystick not mapped to pwm03 anymore. I have this in my code that allows me to reset the counter and to remap pwm03 to the joystick (so we can move it again):
This is all still in Default_Routine()
Code:
             last = now;
	now = rc_dig_in04;

	last2 = now2;
	now2 = p3_sw_trig;

	last3 = now3;
	now3 = p3_sw_aux1;

//some other stuff, but then:

if((now3 == 1) && (last3 == 0)) //p3_sw_aux1 sets counter to 0 in case forklift needs to be reset.
	{
		count = 0;
	}


	if((now2 == 1) && (last2 == 0)) //p3_sw_trig sets joystick 3 y-axis to forklift motor. Use after each level.
	{
		pwm03_On_Off = 1;
	}
So, think this will work? there is a snowday at my school today and they wont let us in to work on the robot, so I have to wait another day before I can test any of this. Thanks
  #10   Spotlight this post!  
Unread 14-02-2007, 19:54
jdejoannis jdejoannis is offline
Registered User
FRC #1845
 
Join Date: Feb 2006
Location: Atlanta,GA
Posts: 48
jdejoannis will become famous soon enoughjdejoannis will become famous soon enough
Re: Where do I begin to get the robot to move using the camera?

That won't work because the next time around the fork lift is going to be reconnected to the joystick.

This does not do what you think it does:
pwm03 != p1_y;

Lets say p1_y is equal to 200 at the moment, so we have
pwm03 != 200;

Which means pwm03 is going to be set to 0 (for the moment). You will need an if or switch statement for your joystick.

Also you might want to put a \r\n in your print statements. Keep up the good work!!

Jason
  #11   Spotlight this post!  
Unread 16-02-2007, 17:55
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
Re: Where do I begin to get the robot to move using the camera?

Please help me, I can't figure out how to use the camera to actually MOVE the robot. I have the camera code working along with the camera itself, but how do I move pwm01 (left drive wheel) and pwm02 (right drive wheel) individually according to the pan of the camera? I have no idea where to begin with this code. (I just got the code to work for the camera and I've been trying for weeks. Now I only have 2 days, Please help if you can)



Code:
		
int I_Want_To_Search = 1;
int pwm01_On_Off = 1;
int pwm02_On_Off = 1;
int pwm03_On_Off = 1; //these are all at the top of user_routines.c Everything else is in Processfrom master UP (except TARGETRANGE[] and FIND_DISTANCE())



                          if(I_Want_To_Search == 1)
	{
		Servo_Track();
	}


                          if((Get_Tracking_State() == CAMERA_ON_TARGET) || (Get_Tracking_State() == TARGET_IN_VIEW))
		{
			pwm01_On_Off = 0;
			pwm02_On_Off = 0;
			pwm01 = 230; //Desired Forward Velocity
			pwm02 = 230;
			Switch3_LED = 1;
			
			//printf("2"); //these statements are just to see if it worked
		}
		else
		{
			Switch3_LED = 0;
			pwm01_On_Off = 1;
			pwm02_On_Off = 1;
			//printf("4"); //these statements are just to see if it worked
		}
		/*
		if(Find_Distance() <= 50) //THIS DOESN"T WORK!! WHY NOT?
		{
			pwm01 = 127;
			pwm02 = 127;
			pwm01_On_Off = 1;
			pwm02_On_Off = 1;
			I_Want_To_Search = 0; //Stops calling Servo_Track(). THEN CALL ANOTHER THING
			Switch3_LED = 0;
			//printf("3"); //these statements are just to see if it worked
		}
		*/

		if(p1_y > 129 || p2_y > 129)
		{
			pwm01_On_Off = 1;
			pwm02_On_Off = 1;
		}
		else if(p1_y < 125 || p2_y < 125)
		{
			pwm01_On_Off = 1;
			pwm02_On_Off = 1;
		}
The Find_Distance() function is this:
Code:
unsigned int Find_Distance(void)
{	
	return(targetRange[pwm07-144]);
}
and target range is this:
Code:
const rom unsigned int targetRange[] =
	{
3355,
1676,
1116,
835,
666,
553,
472,
411,
363,
325, //place 10
293,
267,
244,
225, 
208,
193,
179,
167,
156,
146, //place 20
137,
128,
121, 
113, 
107,
100,
94,
89,
83,
78, //place 30
73,
68, 
64,
60,
56,
51,
48,
44,
40,
36, //place 40
33, 
29, 
26,
23,
19,
16,
13,
10,
6,
3, //place 50
0, //place 51
};
So I would like to know why my distance thing isn't working (Max tilt is 194 and min is 94, center at 144. My degree per pwm step was 1.7647 (50/90? is that right?) Then I multiplied that by the pwm index up to 51 and found the radian value and plugged it into TAN(x) and then did 116-12.625(my height)/tan(the radian value from before)) Assuming that's correct, what's wrong with the rest of the code? It's not working properly. Camera looks away from the light when I comment in the Find_Distance code (less than 50 or whatever). ALSO, how do I program the robot to move forward???
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
Building the field :: where can I get the carpet? Armando Gonzalez Technical Discussion 10 12-01-2007 14:14
Where in the world is the new 2007 cmu camera docs?!?!? xrabohrok Programming 13 08-01-2007 20:28
Where do we get more extention wires for the Vex robot? pbrules15 Technical Discussion 5 27-01-2006 07:48
how do u figure out the torque req'd to move a robot? Salik Syed Technical Discussion 11 03-11-2004 08:12
Using Robotics to get the girl necroprime Chit-Chat 66 21-03-2003 23:21


All times are GMT -5. The time now is 06:16.

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