Only this pageAll pages
Powered by GitBook
1 of 8

LaserCAN

Loading...

Loading...

Loading...

Code Examples

Loading...

Loading...

Loading...

Loading...

About this Product

Use Cases:

  • Rangefinding and Obstacle Avoidance

  • Gamepiece / Object Presence and Range Detection

  • Absolute Elevator Height Detection

  • Contactless Limit Switch

Key Features

  • Input voltage range 4.5V – 16V

  • FRC CAN Ready!

  • 0-4000mm range (in IR-darkness)

  • Small (25x25mm, < 1inx1in) form-factor

  • Adjustable Region of Interest (RoI) and Field of View (FoV)

  • Configurable from robot code and/or from GrappleHook

  • Ambient light measurement

  • Adjustable 10-50Hz sample rate

The LaserCAN uses the VL53L1X Class-1 940nm laser ranging sensor, and exposes configuration of the 16×16 SPAD array, allowing you to target your region of interest (ROI) to suit your needs. Use a small ROI for detecting the height of your elevator, or a wide ROI for detecting gamepieces. Adjust your ranging mode (short vs long) to tune distance vs ambient light rejection, and adjust your timing budget to tune accuracy vs measurement frequency.

Configure with GrappleHook

LaserCAN comes with support for GrappleHook – our companion application allowing you to configure your Grapple devices. Adjust your Region of Interest, Timing Budget, Ranging Mode, and CAN ID with GrappleHook. Update your firmware, monitor sensor status, and more!

LaserCAN - FRC Example (C++)

Install the Vendor Library:

In VSCode, hit CTRL+SHIFT+P and select "WPILib: Manage Vendor Libraries". Select "Install new libraries (offline)" and paste the following URL: https://storage.googleapis.com/grapple-frc-maven/libgrapplefrc2024.json

Use it!

Robot.h

#pragma once

#include <frc/TimedRobot.h>
#include <grpl/LaserCan.h>

class Robot : public frc::TimedRobot {
 public:
  void RobotInit() override;
  void RobotPeriodic() override;

  void AutonomousInit() override;
  void AutonomousPeriodic() override;

  void TeleopInit() override;
  void TeleopPeriodic() override;

  void DisabledInit() override;
  void DisabledPeriodic() override;

  void TestInit() override;
  void TestPeriodic() override;
 private:
  grpl::LaserCan *lc;
};

Robot.cpp

#include "Robot.h"
#include <iostream>

void Robot::RobotInit() {
  lc = new grpl::LaserCan(0);
    // Optionally initialise the settings of the LaserCAN, if you haven't already done so in GrappleHook
  lc->set_ranging_mode(grpl::LaserCanRangingMode::Long);
  lc->set_timing_budget(grpl::LaserCanTimingBudget::TimingBudget100ms);
  lc->set_roi(grpl::LaserCanROI{ 8, 8, 16, 16 });
}

void Robot::RobotPeriodic() {
  std::optional<grpl::LaserCanMeasurement> measurement = lc->get_measurement();
  if (measurement.has_value() && measurement.value().status == grpl::LASERCAN_STATUS_VALID_MEASUREMENT) {
    std::cout << "The target is " << measurement.value().distance_mm << "mm away!" << std::endl;
  } else {
    std::cout << "Oh no! The target is out of range, or we can't get a reliable measurement!" << std::endl;
    // You can still use distance_mm in here, if you're ok tolerating a clamped value or an unreliable measurement.
  }
}

void Robot::AutonomousInit() {}
void Robot::AutonomousPeriodic() {}

void Robot::TeleopInit() {}
void Robot::TeleopPeriodic() {}

void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}

void Robot::TestInit() {}
void Robot::TestPeriodic() {}

#ifndef RUNNING_FRC_TESTS
int main() {
  return frc::StartRobot<Robot>();
}
#endif

LaserCAN - FRC Example (Java)

Install the Vendor Library:

In VSCode, hit CTRL+SHIFT+P and select "WPILib: Manage Vendor Libraries". Select "Install new libraries (offline)" and paste the following URL: https://storage.googleapis.com/grapple-frc-maven/libgrapplefrc2024.json

Use it!

package frc.robot;

import au.grapplerobotics.LaserCan;
import au.grapplerobotics.ConfigurationFailedException;
import edu.wpi.first.wpilibj.TimedRobot;

public class Robot extends TimedRobot {
  private LaserCan lc;

  @Override
  public void robotInit() {
    lc = new LaserCan(0);
    // Optionally initialise the settings of the LaserCAN, if you haven't already done so in GrappleHook
    try {
      lc.setRangingMode(LaserCan.RangingMode.SHORT);
      lc.setRegionOfInterest(new LaserCan.RegionOfInterest(8, 8, 16, 16));
      lc.setTimingBudget(LaserCan.TimingBudget.TIMING_BUDGET_33MS);
    } catch (ConfigurationFailedException e) {
      System.out.println("Configuration failed! " + e);
    }
  }

  @Override
  public void robotPeriodic() {
    LaserCan.Measurement measurement = lc.getMeasurement();
    if (measurement != null && measurement.status == LaserCan.LASERCAN_STATUS_VALID_MEASUREMENT) {
      System.out.println("The target is " + measurement.distance_mm + "mm away!");
    } else {
      System.out.println("Oh no! The target is out of range, or we can't get a reliable measurement!");
      // You can still use distance_mm in here, if you're ok tolerating a clamped value or an unreliable measurement.
    }
  }

  @Override
  public void autonomousInit() {}

  @Override
  public void autonomousPeriodic() {}

  @Override
  public void teleopInit() {}

  @Override
  public void teleopPeriodic() {}

  @Override
  public void disabledInit() {}

  @Override
  public void disabledPeriodic() {}

  @Override
  public void testInit() {}

  @Override
  public void testPeriodic() {}
}

Configure with Thrifty Config

Coming soon!

Mechanical Interface

With an injection molded locking, keyed case, we have designed the LaserCAN to be clean and easy to mount without fear of damaging any of the electrical components.

The case also has silkscreen printing on it to show the user which wire goes where for ease of wiring.

There are also holes for the LEDs to shine through.

Simply snap the two halves together and mount to the hole pattern as shown below.

Download the drawing below.

Onshape Link to Assembly
Users can change the Field of View per their requirements
69KB
TTB-112 LaserCAN.pdf
pdf

Getting Started

Getting Started with LaserCAN

Getting Started with LaserCAN is easy! Follow this guide and you'll be using your sensor in no time!

1. Connect Power

IMPORTANT: Double check the FRC Rule Manual for wire gauges, PDP/PDH output selection, etc.

Direct

To wire up your LaserCAN, connect V+ to the 6V (PWM) or 5V (DIO) source on your RoboRIO, and GND to any Ground pin on the RoboRIO. You can also use a VRM or other voltage source, but ensure voltage source is within the range of 4.5-16V. You can use either V+ and GND pad.

Daisy-Chain

Alternatively, you can power the LaserCAN from another LaserCAN by connecting the V+ pads together, and likewise for the GND pads. DO NOT Daisy-Chain more than 8 LaserCANs in one chain!

2. Connect CAN

Next, connect the CANH and CANL pads of the LaserCAN to your robot's CAN bus. This can be done in one of three ways:

Pass-Through

Insert the LaserCAN in an existing CAN line by connecting both sides of the LaserCAN's CAN pads, "passing through" the connection to downstream devices.

Star

Alternatively, branch off from an existing CAN connection, forming a new branch that can be connected to one side of the LaserCAN. If connecting in this manner, ensure the stub length is short (i.e. a short branch).

Star + Pass-Through

If you have more than one LaserCAN, you can use the Star method to connect the first LaserCAN, and connect the rest through passthrough, starting at the first LaserCAN's unoccupied pads. Ensure the total stub length is also short, less than 2 meters for 1Mbps CAN 2.0B.

3. Power on your LaserCAN

Power on your robot to power on the LaserCAN. The orange LED should blink rapidly for 2-3 seconds before turning off. If the orange LED remains on, your LaserCAN may require a firmware update.

4. Download and Install GrappleHook

Download the latest version of GrappleHook for your platform here: https://github.com/GrappleRobotics/GrappleHook/releases

Tip: If you're on windows, select the asset ending in .msi

5. Run GrappleHook

Connect your RoboRIO over a USB cable, and open GrappleHook. Select RoboRIO, and hit "Connect"

If you have connection problems, please unplug the robot radio to open the connection.

6. Set the CAN ID

In GrappleHook, select "Change ID" and set a new CAN ID for your LaserCAN. Choose something unique from other LaserCANs, otherwise they'll conflict!

7. Install the libgrapplefrc Vendor Library

In VSCode, hit CTRL+SHIFT+P and select "WPILib: Manage Vendor Libraries". Select "Install new libraries (online)" and paste the following URL: https://storage.googleapis.com/grapple-frc-maven/libgrapplefrc2024.json

8. Use LaserCAN!

See one of our examples:

Code Examples