Go to Post when you think you are here to compete against other teams, thats when bad things start happening... - KenWittlief [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 18-01-2006, 19:57
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
Camera to motor setup

We got the camera to track the green, but now we've got another problem.


We've hooked up the servos on the camera directly to two motors so the camera tells the motors what to do. However, when the camera sees it, it sets the motor running in one direction and doesn't stop it. How are some of the other teams doing this? Are you guys modifying the code sent to the motors or will this setup work?
  #2   Spotlight this post!  
Unread 18-01-2006, 22:11
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Camera to motor setup

Servo values don't directly translate to motor values.
A servo value of say 175 could be off to the left or right of center. In terms of a motor, it is forward.

You need some translating code in there
  #3   Spotlight this post!  
Unread 18-01-2006, 22:22
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Camera to motor setup

Servos are position-commanded. A pwm value of 127 is center, 0 is one extreme, 254 is another.

Motors are velocity-commanded. Pwm 127 is neutral, 0 is full reverse, 254 is full forward.

You have to translate between the two. Using an encoder or pot and a feedback loop is one way.
  #4   Spotlight this post!  
Unread 18-01-2006, 22:57
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,188
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: Camera to motor setup

Quote:
Originally Posted by Abwehr
Servos are position-commanded. A pwm value of 127 is center, 0 is one extreme, 254 is another.

Motors are velocity-commanded. Pwm 127 is neutral, 0 is full reverse, 254 is full forward.

You have to translate between the two. Using an encoder or pot and a feedback loop is one way.
Better yet.. read back the "wanted" pan servo rate from the camera, convert that into an angle relative to the bot in radians, and either

a) Turn the bot until the pan servo reads 127 (0 degrees)

b) Use a gyro (It would be a shame if a team skimped out on using one of these, seeing as we got a pretty nice one in the kit!) and turn to the calculated angle.

c) Use a combination of both: Lock onto the target.. get the relative angle.. turn UBER fast using the gyro to slow down.. and reposition yourself by using choice A.
  #5   Spotlight this post!  
Unread 19-01-2006, 00:08
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Camera to motor setup

Quote:
Originally Posted by Windward
We got the camera to track the green, but now we've got another problem.


We've hooked up the servos on the camera directly to two motors so the camera tells the motors what to do. However, when the camera sees it, it sets the motor running in one direction and doesn't stop it. How are some of the other teams doing this? Are you guys modifying the code sent to the motors or will this setup work?
The servo PWM value commands position. The motor PWM value commands velocity and/or torque. These are not equivalent... You will have to do some math to make it work...


Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #6   Spotlight this post!  
Unread 19-01-2006, 17:24
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
Re: Camera to motor setup

Quote:
Originally Posted by Abwehr
Servos are position-commanded. A pwm value of 127 is center, 0 is one extreme, 254 is another.

Motors are velocity-commanded. Pwm 127 is neutral, 0 is full reverse, 254 is full forward.

You have to translate between the two. Using an encoder or pot and a feedback loop is one way.

We haven't gotten our encoders to work well yet. What do you mean by "pot and a feedback loop?"

Quote:
Originally Posted by Tom Bottiglieri
Better yet.. read back the "wanted" pan servo rate from the camera, convert that into an angle relative to the bot in radians, and either

a) Turn the bot until the pan servo reads 127 (0 degrees)

b) Use a gyro (It would be a shame if a team skimped out on using one of these, seeing as we got a pretty nice one in the kit!) and turn to the calculated angle.

c) Use a combination of both: Lock onto the target.. get the relative angle.. turn UBER fast using the gyro to slow down.. and reposition yourself by using choice A.
What is the encoder supposed to do? Our electrician says it is an "acceloromiter" but our head-programmer sayed that it detects whether a robot has been knocked off course (which would benifit autonomous.)
  #7   Spotlight this post!  
Unread 19-01-2006, 22:39
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Camera to motor setup

Quote:
Originally Posted by Windward
We haven't gotten our encoders to work well yet. What do you mean by "pot and a feedback loop?"
Closed loop

Quote:
Originally Posted by Windward
What is the encoder supposed to do? Our electrician says it is an "acceloromiter" but our head-programmer sayed that it detects whether a robot has been knocked off course (which would benifit autonomous.)
An encoder is a digital sensor that detects regular "ticks" on a wheel. The purpose of it is to detect either velocity or position. You count ticks and compare them to the time. In this case, an encoder can either be a tooth counter, the banner sensors, or the grayhill encoders.
  #8   Spotlight this post!  
Unread 20-01-2006, 03:53
SteveO SteveO is offline
Registered User
no team
 
Join Date: Jan 2003
Rookie Year: 2003
Location: NV
Posts: 122
SteveO will become famous soon enoughSteveO will become famous soon enough
Re: Camera to motor setup

Quote:
Originally Posted by Tom Bottiglieri
Better yet.. read back the "wanted" pan servo rate from the camera, convert that into an angle relative to the bot in radians, and either

a) Turn the bot until the pan servo reads 127 (0 degrees)

b) Use a gyro (It would be a shame if a team skimped out on using one of these, seeing as we got a pretty nice one in the kit!) and turn to the calculated angle.

c) Use a combination of both: Lock onto the target.. get the relative angle.. turn UBER fast using the gyro to slow down.. and reposition yourself by using choice A.
For some reason I am thinking I heard that 150 was the center value for the servos. Correct me if I'm wrong.

I am by no means a programmer, but with no encoders/gyros/etc. whatsoever (method A you are referring to) is it not possible to write some code kinda like this:
Code:
if(pwm01 > 155) //giving kind of an error range of 5
{
	 pwmX = 157; //or some value that isn't terribly fast
}

if(pwm01 < 145)
{
	pwmX = 97;
}


if(pwm02 > 155)
{
	 pwmY = 157;
}


if(pwm02 < 145)
{
	 pwmY = 97;
}
Assuming pwmX is your pan and pwmY is tilt for your "aiming" motors, 150 is the actual center value for they servos, and I don't know if there are some default variables for the pan and tilt servo values (I just thought they were pwm 1 and 2). Probably pretty inefficient code, but that basic idea?
  #9   Spotlight this post!  
Unread 20-01-2006, 08:31
iBheat's Avatar
iBheat iBheat is offline
Registered User
FRC #0418 (Lasa Robotics)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Austin, TX
Posts: 24
iBheat is on a distinguished road
Re: Camera to motor setup

The true center value for a servo is 127 but in Kevin's code he defines them in tracking.h!
  #10   Spotlight this post!  
Unread 20-01-2006, 16:44
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Camera to motor setup

There are 2 solutions available using proportional control if you are either

1) steering a gun turret using the pan and tilt output from the camera data packet; or
2) slaving the turret in the x-plane by fixing the camera to it

First, if you are using an optical encoder to measure the rotation of the turret and Tmid is the midpoint measurement of the turret and Cmid is the midpoint servo output for panning, then once the camera finds the target,
the desired turret position, or turret_dx, is given by Tmid*(1+((pan/Cmid)-1)). If we set error_x = turret_dx-OE, then the pwm output to the motor powering the turret is 127-Kp*error_x, where Kp is a proportionality constant.

Second, if the camera is afixed to the turret in the x-plane, then the error is simply Cmid-pan. The pwm output is then 127+Kp*error_x.

You can refine these equations to make a PID controller if needed. The math should be optimized for integer math by multiplying and dividing by 100 to avoid truncation error.

Post your own solutions!

Jon Mittelman
Team236 Programming Mentor
  #11   Spotlight this post!  
Unread 20-01-2006, 18:06
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Camera to motor setup

Quote:
Originally Posted by iBheat
The true center value for a servo is 127 but in Kevin's code he defines them in tracking.h!
The values in tracking.h define the calibrated servo PWM values when the camera is centered (i.e., pan and tilt angles of zero degrees).

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #12   Spotlight this post!  
Unread 20-01-2006, 18:59
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Camera to motor setup

so

pan ceter is 124
tilt center is 144

right, Kevin?

Jon
  #13   Spotlight this post!  
Unread 20-01-2006, 19:17
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
Re: Camera to motor setup

This is the basic outline that I came up with, where the camera is mounted on the cannon.

Quote:
// pwm1 = Camera Pan
// pwm2 = Camera Tilt
// pwm5 = cannon Pan
// pwm6 = cannon Tilt

if CamPanLeft
turn cannon right
if CamPanRight
turn cannon left
if CamTiltUp
rotate cannon down
if CamTiltDown
rotate cannon up
Also when a pwm > 125 is the motor/servo turning to the right or the left. Once I know that I can write more specific code.

Does the pan & tilt center change when you change the degrees of panning & tilting?
  #14   Spotlight this post!  
Unread 20-01-2006, 21:57
iBheat's Avatar
iBheat iBheat is offline
Registered User
FRC #0418 (Lasa Robotics)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Austin, TX
Posts: 24
iBheat is on a distinguished road
Re: Camera to motor setup

Quote:
Originally Posted by Kevin Watson
The values in tracking.h define the calibrated servo PWM values when the camera is centered (i.e., pan and tilt angles of zero degrees).

-Kevin
Yeah that is what I meant.
  #15   Spotlight this post!  
Unread 20-01-2006, 22:17
Validius's Avatar
Validius Validius is offline
There is a shadow following me.....
AKA: Mark Ratering
FRC #1549 (Washtenuts)
Team Role: College Student
 
Join Date: Feb 2005
Rookie Year: 2005
Location: South Lyon
Posts: 159
Validius will become famous soon enoughValidius will become famous soon enough
Send a message via AIM to Validius
Re: Camera to motor setup

Kevin: Would you recomend fixing the camera to the turret and slaving the pan (and a factoring in the tilt assuming the turret can tilt)? I am not an exrteemly versed programmer but i know i could pull it off. As is i figured that i would just keep them independant.

Also: is the confidance rating of the camera a good relfection of magnitude in the vector to the light (after all, vectors have direction & magnitude!). I could perhaps use this to throttle the shooter's wheels.
__________________
When a sociaty comes to believe that human life is not inherently worth living, it is a slippery slope to the gas chamber. You wind up on a low road that twists past Columbine and leads toward Auschwitz.

-Peggy Noonan
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
How To Use the Google Camera generalbrando Kit & Additional Hardware 2 07-02-2006 16:00
Camera pointing error? Craig Putnam Programming 14 21-01-2006 02:52
Scripting Setup and the Camera + Serial Port Drivers CJO Programming 22 11-01-2006 17:42
Unresponsive camera neilsonster Programming 9 17-02-2005 08:51
CMUCam2 Camera Code - Are important parts commented out? Mr. Lim Programming 4 14-01-2005 12:11


All times are GMT -5. The time now is 01:53.

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