Dexter IMU sensor

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

Re: Dexter IMU sensor

Postby gazcrowbar » Tue Dec 06, 2011 11:18 am

Perhaps an obvious question but how do I get the compiler to know that it should look to the IMU folder? I am using Netbeans and tried adding the IMU folder to the project as a library. But it wont recognise:
Code: Select all
MMA7455L accel = new MMA7455L(SensorPort.S4);
I am not that experienced with using other code.
gazcrowbar
New User
 
Posts: 10
Joined: Mon Jul 25, 2011 4:29 pm

Re: Dexter IMU sensor

Postby skoehler » Tue Dec 06, 2011 11:24 am

Use the import statement:
import nl.totan.sensors.MMA7455L;
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Dexter IMU sensor

Postby gazcrowbar » Tue Dec 06, 2011 11:36 am

skoehler wrote:Use the import statement:
import nl.totan.sensors.MMA7455L;

It says that package does not exist, am I not adding the folder to my program correctly? I right click on my project -> properties -> libraries -> addJar/folder -> browse to folder IMU and add it

EDIT: Figured it out - added the IMU folder to the source not as a library and the import statement worked. Thanks for the help!
gazcrowbar
New User
 
Posts: 10
Joined: Mon Jul 25, 2011 4:29 pm

Re: Dexter IMU sensor

Postby skoehler » Tue Dec 06, 2011 12:34 pm

gazcrowbar wrote:EDIT: Figured it out - added the IMU folder to the source not as a library and the import statement worked. Thanks for the help!


Yes, that's was correct. A Library consists of a folder or a JAR (which is basically a ZIP) which contains *.class files. *.class files are basically compiled *.java files. Since you only have *.java files, they have to be added as source.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Dexter IMU sensor

Postby gazcrowbar » Tue Dec 06, 2011 7:48 pm

Quick Update, been busy all day - Successfully created a segway robot using the dIMU sensor. Combined the design of the robot from "Intelligence Unleashed" book, the code posted above and altered the lejos source for the segway to work with the sensor, and extending the Gyroscope class. Will post a video and source code for it all (if thats allowed) through the week. Just a few little things - as mentioned on the blog from the guy who created the drivers - the logger part of the filter needs to be commented out for now with version 0.9.

Also this
Code: Select all
while (Button.ESCAPE.isDown());

needs to be changed to

Code: Select all
while (Button.ESCAPE.isPressed());
in a few files in order for Netbeans to compile.

Thanks for all the help, now that I have the basics down it will be fun playing around. :)
gazcrowbar
New User
 
Posts: 10
Joined: Mon Jul 25, 2011 4:29 pm

Re: Dexter IMU sensor

Postby Aswin » Tue Dec 06, 2011 10:47 pm

I'll change the code and add the interfaces that are potentialy sopported. I'll also try to reduce the number of files.
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Dexter IMU sensor

Postby gazcrowbar » Fri Dec 09, 2011 6:31 pm

Heres the code I created to act as a single axis gyro, using the constructor to select an axis and whether it should be inverted. Code may be redundant and not great but it helped me learn some basics by making it, maybe it may help someone else.

Code: Select all
//IMUGyro.java Created by Gary Stanton 09 December 2011

//uses the dIMU drivers cereated by aswin, found on http://nxttime.wordpress.com/2011/11/22/imu-sensor-software/
//extends the gyrocope class to make the IMU to act a as a single axis gyro
//axis options: 0,1,2
//inverted - inverts the axis
//maybe in future allow rate setting, calculate offset correct to do so?


import nl.totan.sensors.*;
import lejos.robotics.Gyroscope;
import lejos.nxt.*;

public abstract class IMUGyro implements Gyroscope {

    private float vel = 0;
    private float[] rate = new float[3];
    private L3G4200D gyro;
    private int axis;
    private boolean inverted = false;

    public IMUGyro(int axis, boolean inverted) {
        SensorPort.S4.i2cEnable(I2CPort.HIGH_SPEED);
        this.inverted = inverted;
        gyro = new L3G4200D(SensorPort.S4);
        gyro.setRateUnit(RateData.RateUnits.DPS);
        this.axis = axis;
    }

    //retrieve data from chosen axis
    public float getAngularVelocity() {
        //get results
        gyro.fetchAllRate(rate);
        vel = (float) rate[axis];
        //invert gyro data if told by constructor
        if (inverted == true){
            vel = -(vel);
        }
        return vel;
    }

    public void recalibrateOffset() {
        gyro.calculateOffset();
    }
}
Last edited by gazcrowbar on Sat Dec 24, 2011 9:56 pm, edited 1 time in total.
gazcrowbar
New User
 
Posts: 10
Joined: Mon Jul 25, 2011 4:29 pm

Re: Dexter IMU sensor

Postby trebronics » Wed Dec 14, 2011 3:35 am

Where are the classes DIMUAccel and DIMUGyro? Everything in sensors, filters, and util compiles without error, but testDIMU in sample does not compile because it is unable to find those two classes.
trebronics
New User
 
Posts: 1
Joined: Wed Dec 14, 2011 3:29 am

Re: Dexter IMU sensor

Postby gazcrowbar » Fri Dec 16, 2011 12:04 am

trebronics wrote:Where are the classes DIMUAccel and DIMUGyro? Everything in sensors, filters, and util compiles without error, but testDIMU in sample does not compile because it is unable to find those two classes.

I just deleted the samples folder, and kept a copy. It would seem the testDIMU was probrably just a test(obviously) and the author hasnt removed it, or perhaps just renamed the driver or interface files from DIMUAccel to MMA7455L for example?
gazcrowbar
New User
 
Posts: 10
Joined: Mon Jul 25, 2011 4:29 pm

Re: Dexter IMU sensor

Postby Aswin » Fri Dec 16, 2011 7:34 am

Hi,

By accident I renamed the two drivers. I'll try to correct this later. For now testDIMU can be repaired by initializing the drivers this way:
Code: Select all
      MMA7455L_E accel = new MMA7455L_E(SensorPort.S2);
      L3G4200D_E gyro = new L3G4200D_E(SensorPort.S2);
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Dexter IMU sensor

Postby mescalinum » Fri Sep 14, 2012 3:44 pm

Aswin wrote:You can download drivers for the Dexter IMU sensor here.


that link doesn't work.

I found alternate link here. I hope it is the same stuff...
mescalinum
New User
 
Posts: 14
Joined: Sat Jul 30, 2011 12:38 pm

Previous

Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff