Valkyrie 2026
Loading...
Searching...
No Matches
valor::sensors::LaserProximitySensor Class Reference

Combines Lidar distance measurements and debounce logic. More...

#include <valkyrie/sensors/LaserProximitySensor.h>

Inheritance diagram for valor::sensors::LaserProximitySensor:
valor::sensors::BaseSensor< LaserProximityData > valor::sensors::LidarSensor valor::sensors::DebounceSensor valor::sensors::BaseSensorCore valor::Loggable valor::sensors::BaseSensor< units::millimeter_t > valor::sensors::BaseSensor< bool > valor::sensors::BaseSensorCore valor::Loggable valor::sensors::BaseSensorCore valor::Loggable valor::sensors::CANrangeSensor valor::sensors::GrappleSensor

Public Member Functions

 LaserProximitySensor ()
 Construct a new LaserProximitySensor object.
void SetThresholdDistance (units::millimeter_t threshold)
 Set the threshold distance for triggering the sensor.
units::millimeter_t GetThresholdDistance () const
 Returns the threshold distance for triggering the sensor.
void Reset () override
 Reset the sensor state, including Lidar and debounce logic.
LaserProximityData Get ()
 Get the current sensor data.
void SetGetter (std::function< units::millimeter_t()> getter)
 Set the getter function for the Lidar sensor.
Public Member Functions inherited from valor::sensors::BaseSensor< LaserProximityData >
void SetGetter (std::function< LaserProximityData()> _lambda)
 Set the lambda function to fetch sensor data.
void ApplyPostProcessing (std::function< LaserProximityData(LaserProximityData)> func)
 Set a post-processing function for sensor data.
LaserProximityData Get () const
 Get the current sensor state.
Public Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 Loggable (std::shared_ptr< nt::NetworkTable > table)
 Construct a Loggable that uses an existing NetworkTable.
 Loggable ()
 Default construct an uninitialized Loggable.
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
void SetPeriodicLevel (LogLevel level)
 Set the logging level for LoggablePeriodic.
template<typename T>
WriteLog (std::string_view field, const T &data, LogLevel level=LogLevel::Normal)
 Publish a value to NetworkTables under the given field.
template<typename T>
ReadLog (std::string_view field, const T &defaultValue={})
 Read a value from NetworkTables for the given field.
template<>
decltype(Loggable::subscribers) ::iterator addSubscriber (std::string_view field, const std::vector< bool > &defaultValue)
template<>
void WriteLogImpl (nt::Publisher *pub, const std::vector< bool > &data)
template<>
std::vector< bool > ReadLogImpl (nt::Subscriber *sub)
Public Member Functions inherited from valor::sensors::LidarSensor
 LidarSensor ()
 Construct a new LidarSensor object.
void SetMaxDistance (units::millimeter_t dist)
units::millimeter_t GetMaxDistance () const
void SetDefaultDistance (units::millimeter_t dist)
units::millimeter_t GetDefaultDistance () const
virtual bool IsHealthy () const
 Represents whether the sensor data is healthy.
void SetupSim (std::function< frc::Pose2d()> robotPoseGetter, frc::Transform2d sensorPosition, std::vector< sim::FieldFeature > features)
void SetGetter (std::function< units::millimeter_t()> getter)
Public Member Functions inherited from valor::sensors::BaseSensor< units::millimeter_t >
void SetGetter (std::function< units::millimeter_t()> _lambda)
 Set the lambda function to fetch sensor data.
void ApplyPostProcessing (std::function< units::millimeter_t(units::millimeter_t)> func)
 Set a post-processing function for sensor data.
units::millimeter_t Get () const
 Get the current sensor state.
Public Member Functions inherited from valor::sensors::DebounceSensor
 DebounceSensor ()
 Construct a new DebounceSensor object.
void SetEdgeCallback (std::function< void()> lambda)
 Set a callback function for detecting any edge (rising or falling).
void SetRisingEdgeCallback (std::function< void()> lambda)
 Set a callback function for detecting a rising edge.
void SetFallingEdgeCallback (std::function< void()> lambda)
 Set a callback function for detecting a falling edge.
Public Member Functions inherited from valor::sensors::BaseSensor< bool >
void SetGetter (std::function< bool()> _lambda)
 Set the lambda function to fetch sensor data.
void ApplyPostProcessing (std::function< bool(bool)> func)
 Set a post-processing function for sensor data.
bool Get () const
 Get the current sensor state.

Protected Member Functions

void Calculate () override
 Perform proximity sensor-specific calculations.
void Refresh () override
 Refresh the sensor state.
Protected Member Functions inherited from valor::Loggable
virtual void OnLoggingStart ()
 Hook invoked when logging is started for this object.
virtual void LoggablePeriodic ()
 Periodic callback for logging updates.
Protected Member Functions inherited from valor::sensors::LidarSensor
void Calculate () override
 Perform Lidar-specific calculations.

Additional Inherited Members

Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
static constexpr LoggableGetRoot ()
Static Public Attributes inherited from valor::sensors::BaseSensorCore
static constexpr units::millisecond_t LOOP_PERIOD = frc::TimedRobot::kDefaultPeriod / 2
Protected Attributes inherited from valor::sensors::BaseSensor< LaserProximityData >
std::function< LaserProximityData()> sensorLambda
 Lambda function to fetch sensor data.
std::function< LaserProximityData(LaserProximityData)> postProcessor
 Lambda function to post-process sensor data.
LaserProximityData prevState
 Previous and current sensor states.
LaserProximityData currState
Protected Attributes inherited from valor::sensors::LidarSensor
std::unique_ptr< SimStatesimState
Protected Attributes inherited from valor::sensors::BaseSensor< units::millimeter_t >
std::function< units::millimeter_t()> sensorLambda
 Lambda function to fetch sensor data.
std::function< units::millimeter_t(units::millimeter_t)> postProcessor
 Lambda function to post-process sensor data.
units::millimeter_t prevState
 Previous and current sensor states.
units::millimeter_t currState
Protected Attributes inherited from valor::sensors::BaseSensor< bool >
std::function< bool()> sensorLambda
 Lambda function to fetch sensor data.
std::function< bool(bool)> postProcessor
 Lambda function to post-process sensor data.
bool prevState
 Previous and current sensor states.
bool currState

Detailed Description

Combines Lidar distance measurements and debounce logic.

This class integrates Lidar sensor data with debounce functionality to provide reliable proximity sensing.

Constructor & Destructor Documentation

◆ LaserProximitySensor()

valor::sensors::LaserProximitySensor::LaserProximitySensor ( )

Construct a new LaserProximitySensor object.

Parameters
robotReference to the robot, used to schedule the calculate method.

Member Function Documentation

◆ Calculate()

void valor::sensors::LaserProximitySensor::Calculate ( )
overrideprotectedvirtual

Perform proximity sensor-specific calculations.

This method is called every 10ms and processes the sensor data.

Reimplemented from valor::sensors::BaseSensorCore.

◆ Get()

LaserProximityData valor::sensors::LaserProximitySensor::Get ( )
inline

Get the current sensor data.

Returns
LaserProximityData The current sensor readings.

◆ GetThresholdDistance()

units::millimeter_t valor::sensors::LaserProximitySensor::GetThresholdDistance ( ) const
inline

Returns the threshold distance for triggering the sensor.

Returns
The threshold distance of the sensor

◆ Refresh()

void valor::sensors::LaserProximitySensor::Refresh ( )
overrideprotectedvirtual

Refresh the sensor state.

Updates prevState and currState by fetching new data using the lambda function. If a post-processing function is set, it is applied to the fetched data.

Reimplemented from valor::sensors::BaseSensor< LaserProximityData >.

◆ Reset()

void valor::sensors::LaserProximitySensor::Reset ( )
overridevirtual

Reset the sensor state, including Lidar and debounce logic.

Reimplemented from valor::sensors::BaseSensor< LaserProximityData >.

◆ SetGetter()

void valor::sensors::LaserProximitySensor::SetGetter ( std::function< units::millimeter_t()> getter)

Set the getter function for the Lidar sensor.

Parameters
getterLambda function to fetch Lidar distance data.

◆ SetThresholdDistance()

void valor::sensors::LaserProximitySensor::SetThresholdDistance ( units::millimeter_t threshold)
inline

Set the threshold distance for triggering the sensor.

Parameters
thresholdDistance in millimeters.

The documentation for this class was generated from the following file: