OCCRA
Go to Post What's this about a robot that they speak of? Are we supposed to build one???? - ryan_f [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-07-2018, 08:50 PM
minisolarclown's Avatar
minisolarclown minisolarclown is offline
Registered User
FRC #3603 (Cyber Coyotes)
Team Role: Programmer
 
Join Date: Dec 2016
Rookie Year: 2015
Location: Reed City
Posts: 81
minisolarclown is just really niceminisolarclown is just really niceminisolarclown is just really niceminisolarclown is just really niceminisolarclown is just really nice
Lidar Lite v3 help needed

I'm doing some off-season learning and my focus right now is getting our Lidar to work. I've been able to get the Lidar working with an arduino, but the behavior is weird when trying to get it to work with the rio. For wiring, the Lidar is getting power and ground from DIO 0, and the I2C leads are hooked up to the "onboard" I2C port on the rio. They are able to communicate. I tested it by having the the rio tell the Lidar to take a measurement and then holding my phone camera up to the Lidar, and it shows the Lidar pulsing as the rio tells it to. The problem is receiving the measurement. It only returns "1285". I can wave my hand over it and move it around, but the value is unchanging.

For troubleshooting I've tried adding and removing pullup resistors as well as checking the registries that I'm writing to, but nothing changes. I've added and removed various delays in the code. I've scrolled through tons of other Chief Delphi posts, Lidar documentation, FRC I2C documentation, and Github repositories but nothing fixes it. I've only seen one other person with the exact same problem (here), but their only solution was to switch to PWM. I've had it work with PWM, but the values fluctuated substantially (3in).

Here is the code that I currently have:
Code:
package org.usfirst.frc.team3603.robot;

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

public class Robot extends IterativeRobot {
	I2C lidar = new I2C(I2C.Port.kOnboard, 0x62);//Create the I2C object with the onboard port and address 0x62
	
	@Override
	public void robotInit() {
	}

	@Override
	public void teleopPeriodic() {
		byte[] data = new byte[2];//Create a buffer to store the data
		lidar.write(0x00, 0x04);//Tell the LIDAR to take a measurement (write 0x04 to 0x00)
		Timer.delay(0.1);//Let the LIDAR take its measurement
		lidar.read(0x8f, 2, data);//Read the two measurement bytes
		
		System.out.println(data[0] + " " + data[1]);//Print the raw data
		
		System.out.println((int)Integer.toUnsignedLong(data[0] << 8) + Byte.toUnsignedInt(data[1]));//Print the processed data
		Timer.delay(1);//Wait 1 second
	}
}
Any help is appreciated!
Reply With Quote
Reply


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 03:18 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi