Class Range

Inheritance Relationships

Base Type

Class Documentation

class Range : public nav2_collision_monitor::Source

Implementation for IR/ultrasound range sensor source.

Public Functions

Range(const nav2_util::LifecycleNode::WeakPtr &node, const std::string &source_name, const std::shared_ptr<tf2_ros::Buffer> tf_buffer, const std::string &base_frame_id, const std::string &global_frame_id, const tf2::Duration &transform_tolerance, const rclcpp::Duration &source_timeout, const bool base_shift_correction)

Range constructor.

  • node – Collision Monitor node pointer

  • source_name – Name of data source

  • tf_buffer – Shared pointer to a TF buffer

  • base_frame_id – Robot base frame ID. The output data will be transformed into this frame.

  • global_frame_id – Global frame ID for correct transform calculation

  • transform_tolerance – Transform tolerance

  • source_timeout – Maximum time interval in which data is considered valid

  • base_shift_correction – Whether to correct source data towards to base frame movement, considering the difference between current time and latest source time


Range destructor.

void configure()

Data source configuration routine. Obtains ROS-parameters and creates range sensor subscriber.

virtual void getData(const rclcpp::Time &curr_time, std::vector<Point> &data) const

Adds latest data from range sensor to the data array.

  • curr_time – Current node time for data interpolation

  • data – Array where the data from source to be added. Added data is transformed to base_frame_id_ coordinate system at curr_time.

Protected Functions

void getParameters(std::string &source_topic)

Getting sensor-specific ROS-parameters.


source_topic – Output name of source subscription topic

void dataCallback(sensor_msgs::msg::Range::ConstSharedPtr msg)

Range sensor data callback.


msg – Shared pointer to Range sensor message

Protected Attributes

rclcpp::Subscription<sensor_msgs::msg::Range>::SharedPtr data_sub_

Range sensor data subscriber.

double obstacles_angle_

Angle increment (in rad) between two obstacle points at the range arc.

sensor_msgs::msg::Range::ConstSharedPtr data_

Latest data obtained from range sensor.