Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   MOving toward a circle with camera code (http://www.chiefdelphi.com/forums/showthread.php?t=87184)

Robototes2412 18-10-2010 21:02

MOving toward a circle with camera code
 
Hello all,

I am trying to make a robot move toward a circle, then when it's close enough, it kicks, shooting a ball into the goal.

How do I do this?

Thanks

(I'm the new guy)

Dustin Shadbolt 18-10-2010 21:53

Re: MOving toward a circle with camera code
 
I'm interested in this as well. Our team is thinking about switching over to JAVA and I was wondering how that would look like.


-Dustin Shadbolt

EHaskins 18-10-2010 22:52

Re: MOving toward a circle with camera code
 
I don't have the FRC Java tools installed to confirm this, but I believe there is a sample you can find in the new project dialog which shows this using the gyro and camera.

Robototes2412 19-10-2010 22:16

Re: MOving toward a circle with camera code
 
it doesn't go autonomously

EHaskins 19-10-2010 23:35

Re: MOving toward a circle with camera code
 
Quote:

Originally Posted by Robototes2412 (Post 977784)
it doesn't go autonomously

I'm looking at the sample, and it appears it should track the target left to right, but not produce any forward movment.

The first thing to do is make it drive forward. The simplest way to do this is to change line 48 of CircleTrackerDemo to, where forward_speed is a constant representing the forward speed.
Code:

drive.arcadeDrive(forward_speed, output);
Once that works you need to make it stop. There are a few ways to do that, one way is to do something like this at line 127 of the same file:

Code:

if (targets[0].m_yPos > someValueToIndicateHeightOfTheTarget)
...
OR

if (targets[0].m_majorRadius > someValueToIndicateTheSizeOfTheTarget)
...

when ... is
{
    //do stuff other than drive.
}
else {
    turnController.setSetpoint(gyroAngle + targets[0].getHorizontalAngle());
}

You could expand this to use PID to slow down as approaching the target distance, back away if too close, etc, but that is more advanced.


Once you have this working you could make it run in autonomous mode by moving the contents of the else, starting at line 99 in the sample, into the autonomousPeriodic function at line 73.


All times are GMT -5. The time now is 09:35.

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