Go to Post I survived the Great CD Spamming of 2006. - Michelle Celio [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Spotlight this post!  
Unread 24-03-2015, 15:25
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,078
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: Anti-tipping algorithm

Quote:
Originally Posted by NotInControl View Post
Cool idea. For anyone that wants to try this. You don't need to buy any additional sensors, the RoboRio has a built in accelerometer, and you can use that alone to sense pitch and roll angles, depending on how the RoboRio is mounted with relation to your Robot.

Here is some code to get you started:

Code:
public static double getAccPitch() {
	
	double Y = Robot.accel.getY();
	double Z = Robot.accel.getZ();
	

	return Math.atan2(Y,Z) *180 /Math.PI;
}

public static double getAccRoll()
{
	
	double X = Robot.accel.getX();
	double Y = Robot.accel.getY();
	double Z = Robot.accel.getZ();
	
return Math.atan2(-X, Math.sqrt(Y*Y + Z*Z)) * 180/Math.PI;

}

You will need to switch the methods if you mount your RoboRio vertically.

To access the built-in accelerometer in the RoboRio simply do this:

Code:
public static BuiltInAccelerometer accel;
accel = new BuiltInAccelerometer();
The above code assumes you instantiated the accelerometer in Robot.java, but you can do it anywhere you like.

Hope this helps,

Regards,
Kevin
This approach will make it appear that your robot is pitching or rolling any time you have acceleration due to any force other than gravity (such as the reactive force exerted by the carpet against the tractive force of your wheels).
 


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


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

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