Difference between revisions of "Talk:Circular Targeting"

From Robowiki
Jump to navigation Jump to search
m (Using <syntaxhighlight>.)
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
 
The problem is that it's useful to have scans on consecutive ticks for that.  You could either stop your bot and try and get two consecutive scans, or if the other bot is really moving in a roughly even curve, you can find the change in heading and divide it by the number of ticks between observations.
 
The problem is that it's useful to have scans on consecutive ticks for that.  You could either stop your bot and try and get two consecutive scans, or if the other bot is really moving in a roughly even curve, you can find the change in heading and divide it by the number of ticks between observations.
  
Of course, you should probably just use an AdvancedRobot, or not do circular targeting - if you're trying to enter it into a competition where only [[ExtendsRobot]] is allowed, none of your opponents will be moving in curves. -- [[Kawigi]]
+
Of course, you should probably just use an AdvancedRobot, or not do circular targeting - if you're trying to enter it into a competition where only [[ExtendsRobot]] is allowed, none of your opponents will be moving in curves. -- [[User:Kawigi|Kawigi]]
  
<pre>double TurnRate = (Math.abs(Heading1-Heading2))/(Math.abs(TimeOfHeading1-TimeOfHeading2));</pre>
+
<syntaxhighlight>double TurnRate = (Math.abs(Heading1-Heading2))/(Math.abs(TimeOfHeading1-TimeOfHeading2));</syntaxhighlight>
 
Hope this helps --[[UnderDark]]
 
Hope this helps --[[UnderDark]]
  
Line 17: Line 17:
  
 
Orbit's Gun
 
Orbit's Gun
<pre>
+
<syntaxhighlight>
 
double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
double lateralVelocity = e.getVelocity() * Math.sin(e.getHeadingRadians() - absoluteBearing);
 
double lateralVelocity = e.getVelocity() * Math.sin(e.getHeadingRadians() - absoluteBearing);
Line 25: Line 25:
 
double aimAngle = Math.atan2(distance * Math.sin(circularTravel), distance * Math.cos(circularTravel));
 
double aimAngle = Math.atan2(distance * Math.sin(circularTravel), distance * Math.cos(circularTravel));
 
turnGunRightRadians(Utils.normalRelativeAngle(-getGunHeadingRadians() + aimAngle));
 
turnGunRightRadians(Utils.normalRelativeAngle(-getGunHeadingRadians() + aimAngle));
</pre>
+
</syntaxhighlight>
  
* I'm pretty sure this is just linear targeting.  In this equation, aimAngle will always equal circularTravel.  -- [[Simonton]]
+
* I'm pretty sure this is just linear targeting.  In this equation, aimAngle will always equal circularTravel.  -- [[User:Simonton|Simonton]]
** Hrm dang, I reversed a equation of a circle to help get that. There must be a way to deloop the loop in a circle gun, its just math! But again simonton is far better at delooping things then I am. --[[Chase-san]]
+
** Hrm dang, I reversed a equation of a circle to help get that. There must be a way to deloop the loop in a circle gun, its just math! But again simonton is far better at delooping things then I am. --[[User:Chase-san|Chase-san]]
  
 
Are there any super-small noniterative nanobotish circular targeting methods?  [[User:Awesomeness|Awesomeness]] 00:26, 2 May 2009 (UTC)
 
Are there any super-small noniterative nanobotish circular targeting methods?  [[User:Awesomeness|Awesomeness]] 00:26, 2 May 2009 (UTC)
  
 
: Sort of.  With a little care, you can get circle like aim off a linear cannon if you nudge the lead value based on distance and a sin/cos value.  Not 100% accurate, but should hit fairly often.  This was done way long ago when we had a nano challenge to hit spinbot.  Turns out pattern matching makes it obsolete anyways. --[[User:Miked0801|Miked0801]] 04:54, 2 May 2009 (UTC)
 
: Sort of.  With a little care, you can get circle like aim off a linear cannon if you nudge the lead value based on distance and a sin/cos value.  Not 100% accurate, but should hit fairly often.  This was done way long ago when we had a nano challenge to hit spinbot.  Turns out pattern matching makes it obsolete anyways. --[[User:Miked0801|Miked0801]] 04:54, 2 May 2009 (UTC)

Latest revision as of 09:33, 1 July 2010

General discussion

Does anyone have a good way to put the iterative predicitive stuff (ala the NCLP) into an ExtendsRobot bot? --Alphax

FOR loops --UnderDark

Thank you, Captain Obvious.

The problem is that it's useful to have scans on consecutive ticks for that. You could either stop your bot and try and get two consecutive scans, or if the other bot is really moving in a roughly even curve, you can find the change in heading and divide it by the number of ticks between observations.

Of course, you should probably just use an AdvancedRobot, or not do circular targeting - if you're trying to enter it into a competition where only ExtendsRobot is allowed, none of your opponents will be moving in curves. -- Kawigi

double TurnRate = (Math.abs(Heading1-Heading2))/(Math.abs(TimeOfHeading1-TimeOfHeading2));

Hope this helps --UnderDark

Here is a play on Circular Targeting, it uses math only, its the Orbit gun from my nanobot Orbit (expanded of course, which wasn't an easy task). This piece of code could maybe be changed into a circle gun by putting something into the aimAngle calculation. (and calculating where that center is).

Orbit's Gun

double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
double lateralVelocity = e.getVelocity() * Math.sin(e.getHeadingRadians() - absoluteBearing);
double bulletSpeed = (20 - 3 * bulletPower);
double distance = e.getDistance();
double circularTravel = absoluteBearing + lateralVelocity / bulletSpeed;
double aimAngle = Math.atan2(distance * Math.sin(circularTravel), distance * Math.cos(circularTravel));
turnGunRightRadians(Utils.normalRelativeAngle(-getGunHeadingRadians() + aimAngle));
  • I'm pretty sure this is just linear targeting. In this equation, aimAngle will always equal circularTravel. -- Simonton
    • Hrm dang, I reversed a equation of a circle to help get that. There must be a way to deloop the loop in a circle gun, its just math! But again simonton is far better at delooping things then I am. --Chase-san

Are there any super-small noniterative nanobotish circular targeting methods? Awesomeness 00:26, 2 May 2009 (UTC)

Sort of. With a little care, you can get circle like aim off a linear cannon if you nudge the lead value based on distance and a sin/cos value. Not 100% accurate, but should hit fairly often. This was done way long ago when we had a nano challenge to hit spinbot. Turns out pattern matching makes it obsolete anyways. --Miked0801 04:54, 2 May 2009 (UTC)