Go to Post I am a FRC Coach/Mentor I don't know the meaning of the words "days off" or "rest". At least not from January to May. - Bob Steele [more]
Home
Go Back   Chief Delphi > Technical > Control System > Sensors
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
  #1   Spotlight this post!  
Unread 22-02-2015, 19:06
FlyOldPlanes FlyOldPlanes is offline
Registered User
FRC #1592
 
Join Date: Feb 2015
Location: Titusville, FL
Posts: 6
FlyOldPlanes is an unknown quantity at this point
Smile LIDAR

Hello,

We have a couple of the PulsedLight LIDAR units. First off they are great, but they were a pain for us to get to work. We've browsed a bunch of the threads here without much luck. Here is what we found to get it working.

The MXP pins don't talk well to the LIDAR. The onboard not at all, which is previously documented. We kept thinking we were making an I2C mistake, but we weren't. We eventually noticed that if the connectors were mashed, we would get good comm. Odd since it always worked with the Arduino. To make a long story short, what we ended up having to do was put a 10k pull up resistor between the clock wire and the 5v. BINGO. 100% comm all the time. Here is a java example of using the LIDAR. I used the bit-math from tech2077's LIDAR.java post, thanks.

Here is a simple sensor example, no variables to make it obvious what address goes where. Sorry if it doesn't cut and paste well. Its my first post.

package org.usfirst.frc.PUT_YOUR_TEAM_HERE.robot;

import edu.wpi.first.wpilibj.SensorBase;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.Timer;

/**
*
*/
public class LidarSubsystem extends SensorBase{

I2C m_i2c;

public LidarSubsystem() {
m_i2c = new I2C(I2C.Port.kMXP,0x62);
initLidar();
}

public void initLidar(){
// nothing to do
}

public int getDistance() {

byte[] buffer;
buffer = new byte[2];

m_i2c.write(0x00, 0x04);
Timer.delay(0.04);
m_i2c.read(0x8f, 2, buffer);


return (int)Integer.toUnsignedLong(buffer[0] << 8) + Byte.toUnsignedInt(buffer[1]);
}


public void initDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
}


}

Here is a simple robot code to demonstrate:

package org.usfirst.frc.PUT_YOUR_TEAM_HERE.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot{

LidarSubsystem lidar1;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

lidar1=new LidarSubsystem();

}

/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {

int distance;

distance = lidar1.getDistance();
System.out.println(distance); // this prints to the console window.

}

/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {

}

/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}

}

Hope it helps somebody. We sure could have used the info earlier.

Lennie
First time mentor.
Attached Files
File Type: java LidarSubsystem.java (838 Bytes, 30 views)
File Type: java Robot.java (1.6 KB, 21 views)
Reply With Quote
 


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 08:04.

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