Go to Post I just think that if we are going to have rules intended to level the playing field, they shouldn't hurt teams that put the effort in to go the extra mile. - Dave Scheck [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 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,077
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).
  #2   Spotlight this post!  
Unread 24-03-2015, 15:50
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,357
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Anti-tipping algorithm

As Jared mentioned, a pure accelerometer solution is going to have noise and accelerations in it. Filtering can clean it up some what to give an estimation of gravity but the robot acceleration is still there. The advantage to the Navx MXP is that the chip handles the fusion of 3 a axis accelerometer and a 3 axis gyro.
It also can fuse a 3 axis magnetometer also but we do not use the mag. Pitch and roll are very solid and excellent for this use. Yaw is another subject. In it's current form the Navx MXP does need to be horizontal.
  #3   Spotlight this post!  
Unread 24-03-2015, 16:03
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: Anti-tipping algorithm

Quote:
Originally Posted by Jared Russell View Post
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).
That is very true... the induced acceleration due to robot motion will appear as high frequency noise on each signal. The great thing about that, is that it is easy to determine which acceleration is legitimate, and which acceleration is induced due to robot motion. Simple Low pass filters, will allow for more stable readings... but will increase delay. There is a happy medium to allow for reliable tilt measurements.

A simple Euler linear filter can be used if one desires. It is a autoregressive infinite impulse response moving average.

Code:
accelX = (accelX * alpha) + (Robot.accel.getX() * (1.0 - alpha));
Where alpha is a value from 0 to 1. as you increase alpha from 0 towards 1, the filtering gets more aggressive, and the delay increases. If alpha is 0, its easy to see that there is no filtering at all.

This is the most basic filter you can implement in my book, and it does a pretty good job. There are more robust filters if you ever wanted to experiment with them. Two popular filters to try to smooth acceleration data out would be a median filter, or a Butterworth filter. They are popular because they are relatively easy to implement in code.

If you have the means to use a Gyro to measure the axis of rotation you care about, that is the sensor I would recommend for this application... if you don't, or want to experiment otherwise, it shouldn't take too much effort to use an accelerometer to have a similar implementation.
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner

Last edited by NotInControl : 24-03-2015 at 16:18.
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


All times are GMT -5. The time now is 04:34.

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