|
Nav2 Navigation Stack - lyrical
lyrical
ROS 2 Navigation Stack
|
A ROS wrapper for a 2D Costmap. Handles subscribing to topics that provide observations about obstacles in either the form of PointCloud or LaserScan messages. More...
#include <nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp>


Public Member Functions | |
| Costmap2DROS (const rclcpp::NodeOptions &options=rclcpp::NodeOptions()) | |
| Constructor for the wrapper. More... | |
| Costmap2DROS (const std::string &name, const std::string &parent_namespace="/", const bool &use_sim_time=false, const rclcpp::NodeOptions &options=rclcpp::NodeOptions()) | |
| Constructor for the wrapper. More... | |
| void | init () |
| Common initialization for constructors. | |
| ~Costmap2DROS () | |
| A destructor. | |
| nav2::CallbackReturn | on_configure (const rclcpp_lifecycle::State &state) override |
| Configure node. | |
| nav2::CallbackReturn | on_activate (const rclcpp_lifecycle::State &state) override |
| Activate node. | |
| nav2::CallbackReturn | on_deactivate (const rclcpp_lifecycle::State &state) override |
| Deactivate node. | |
| nav2::CallbackReturn | on_cleanup (const rclcpp_lifecycle::State &state) override |
| Cleanup node. | |
| nav2::CallbackReturn | on_shutdown (const rclcpp_lifecycle::State &state) override |
| shutdown node | |
| void | on_rcl_preshutdown () override |
| as a child-LifecycleNode : Costmap2DROS may be launched by another Lifecycle Node as a composed module If composed, its parents will handle the shutdown, which includes this module | |
| void | start () |
| Subscribes to sensor topics if necessary and starts costmap updates, can be called to restart the costmap after calls to either stop() or pause() | |
| void | stop () |
| Stops costmap updates and unsubscribes from sensor topics. | |
| void | pause () |
| Stops the costmap from updating, but sensor data still comes in over the wire. | |
| void | resume () |
| Resumes costmap updates. | |
| void | updateMap () |
| Update the map with the layered costmap / plugins. | |
| void | resetLayers () |
| Reset each individual layer. | |
| bool | isCurrent () |
| Same as getLayeredCostmap()->isCurrent(). | |
| void | waitUntilCurrent (const rclcpp::Duration &timeout) |
| Wait for the costmap to become current after updates or parameter changes. More... | |
| bool | getRobotPose (geometry_msgs::msg::PoseStamped &global_pose) |
| Get the pose of the robot in the global frame of the costmap. More... | |
| bool | transformPoseToGlobalFrame (const geometry_msgs::msg::PoseStamped &input_pose, geometry_msgs::msg::PoseStamped &transformed_pose) |
| Transform the input_pose in the global frame of the costmap. More... | |
| std::string | getName () const |
| Returns costmap name. | |
| double | getTransformTolerance () const |
| Returns the delay in transform (tf) data that is tolerable in seconds. | |
| Costmap2D * | getCostmap () |
| Return a pointer to the "master" costmap which receives updates from all the layers. More... | |
| std::string | getGlobalFrameID () |
| Returns the global frame of the costmap. More... | |
| std::string | getBaseFrameID () |
| Returns the local frame of the costmap. More... | |
| LayeredCostmap * | getLayeredCostmap () |
| Get the layered costmap object used in the node. | |
| geometry_msgs::msg::Polygon | getRobotFootprintPolygon () |
| Returns the current padded footprint as a geometry_msgs::msg::Polygon. | |
| std::vector< geometry_msgs::msg::Point > | getRobotFootprint () |
| Return the current footprint of the robot as a vector of points. More... | |
| std::vector< geometry_msgs::msg::Point > | getUnpaddedRobotFootprint () |
| Return the current unpadded footprint of the robot as a vector of points. More... | |
| void | getOrientedFootprint (std::vector< geometry_msgs::msg::Point > &oriented_footprint) |
| Build the oriented footprint of the robot at the robot's current pose. More... | |
| void | setRobotFootprint (const std::vector< geometry_msgs::msg::Point > &points) |
| Set the footprint of the robot to be the given set of points, padded by footprint_padding. More... | |
| void | setRobotFootprintPolygon (const geometry_msgs::msg::Polygon &footprint) |
| Set the footprint of the robot to be the given polygon, padded by footprint_padding. More... | |
| nav2::TransformBuffer::SharedPtr | getTfBuffer () |
| bool | getUseRadius () |
| Get the costmap's use_radius_ parameter, corresponding to whether the footprint for the robot is a circle with radius robot_radius_ or an arbitrarily defined footprint in footprint_. More... | |
| double | getRobotRadius () |
| Get the costmap's robot_radius_ parameter, corresponding to raidus of the robot footprint when it is defined as as circle (i.e. when use_radius_ == true). More... | |
| void | getCostsCallback (const std::shared_ptr< rmw_request_id_t >, const std::shared_ptr< nav2_msgs::srv::GetCosts::Request > request, const std::shared_ptr< nav2_msgs::srv::GetCosts::Response > response) |
| Get the cost at a point in costmap. More... | |
Public Member Functions inherited from nav2::LifecycleNode | |
| LifecycleNode (const std::string &node_name, const std::string &ns, const rclcpp::NodeOptions &options=rclcpp::NodeOptions()) | |
| A lifecycle node constructor. More... | |
| LifecycleNode (const std::string &node_name, const rclcpp::NodeOptions &options=rclcpp::NodeOptions()) | |
| A lifecycle node constructor with no namespace. More... | |
| template<typename ParameterT > | |
| ParameterT | declare_or_get_parameter (const std::string ¶meter_name, const ParameterDescriptor ¶meter_descriptor=ParameterDescriptor()) |
| Declares or gets a parameter with specified type (not value). If the parameter is already declared, returns its value; otherwise declares it with the specified type. More... | |
| template<typename ParamType > | |
| ParamType | declare_or_get_parameter (const std::string ¶meter_name, const ParamType &default_value, const ParameterDescriptor ¶meter_descriptor=ParameterDescriptor()) |
| Declares or gets a parameter. If the parameter is already declared, returns its value; otherwise declares it and returns the default value. More... | |
| template<typename MessageT , typename CallbackT > | |
| nav2::Subscription< MessageT >::SharedPtr | create_subscription (const std::string &topic_name, CallbackT &&callback, const rclcpp::QoS &qos=nav2::qos::StandardTopicQoS(), const rclcpp::CallbackGroup::SharedPtr &callback_group=nullptr) |
| Create a subscription to a topic using Nav2 QoS profiles and SubscriptionOptions. More... | |
| template<typename MessageT > | |
| nav2::Publisher< MessageT >::SharedPtr | create_publisher (const std::string &topic_name, const rclcpp::QoS &qos=nav2::qos::StandardTopicQoS(), const rclcpp::CallbackGroup::SharedPtr &callback_group=nullptr) |
| Create a publisher to a topic using Nav2 QoS profiles and PublisherOptions. More... | |
| template<typename ServiceT > | |
| nav2::ServiceClient< ServiceT >::SharedPtr | create_client (const std::string &service_name, bool use_internal_executor=false) |
| Create a ServiceClient to interface with a service. More... | |
| template<typename ServiceT > | |
| nav2::ServiceServer< ServiceT >::SharedPtr | create_service (const std::string &service_name, typename nav2::ServiceServer< ServiceT >::CallbackType cb, rclcpp::CallbackGroup::SharedPtr callback_group=nullptr) |
| Create a ServiceServer to host with a service. More... | |
| template<typename DurationRepT , typename DurationT , typename CallbackT > | |
| rclcpp::GenericTimer< CallbackT >::SharedPtr | create_timer (std::chrono::duration< DurationRepT, DurationT > period, CallbackT callback, rclcpp::CallbackGroup::SharedPtr group=nullptr) |
| Create a sim-time-aware timer for Nav2 lifecycle nodes. More... | |
| template<typename ActionT > | |
| nav2::SimpleActionServer< ActionT >::SharedPtr | create_action_server (const std::string &action_name, typename nav2::SimpleActionServer< ActionT >::ExecuteCallback execute_callback, typename nav2::SimpleActionServer< ActionT >::GoalReceivedCallback goal_received_callback=nullptr, typename nav2::SimpleActionServer< ActionT >::CompletionCallback compl_cb=nullptr, std::chrono::milliseconds server_timeout=std::chrono::milliseconds(500), bool spin_thread=false, const bool realtime=false) |
| Create a SimpleActionServer to host with an action. More... | |
| template<typename ActionT > | |
| nav2::ActionClient< ActionT >::SharedPtr | create_action_client (const std::string &action_name, rclcpp::CallbackGroup::SharedPtr callback_group=nullptr) |
| Create a ActionClient to call an action using. More... | |
| nav2::LifecycleNode::SharedPtr | shared_from_this () |
| Get a shared pointer of this. | |
| nav2::LifecycleNode::WeakPtr | weak_from_this () |
| Get a shared pointer of this. | |
| nav2::CallbackReturn | on_error (const rclcpp_lifecycle::State &) |
| Abstracted on_error state transition callback, since unimplemented as of 2020 in the managed ROS2 node state machine. More... | |
| void | autostart () |
| Automatically configure and active the node. | |
| void | createBond () |
| Create bond connection to lifecycle manager. | |
| void | destroyBond () |
| Destroy bond connection to lifecycle manager. | |
Protected Member Functions | |
| void | mapUpdateLoop (double frequency) |
| Function on timer for costmap update. | |
| void | getParameters () |
| Get parameters for node. | |
| rcl_interfaces::msg::SetParametersResult | validateParameterUpdatesCallback (const std::vector< rclcpp::Parameter > ¶meters) |
| Validate incoming parameter updates before applying them. This callback is triggered when one or more parameters are about to be updated. It checks the validity of parameter values and rejects updates that would lead to invalid or inconsistent configurations. More... | |
| void | updateParametersCallback (const std::vector< rclcpp::Parameter > ¶meters) |
| Apply parameter updates after validation This callback is executed when parameters have been successfully updated. It updates the internal configuration of the node with the new parameter values. More... | |
Protected Member Functions inherited from nav2::LifecycleNode | |
| void | printLifecycleNodeNotification () |
| Print notifications for lifecycle node. | |
| void | register_rcl_preshutdown_callback () |
| void | runCleanups () |
Protected Attributes | |
| nav2::Publisher< geometry_msgs::msg::PolygonStamped >::SharedPtr | footprint_pub_ |
| std::unique_ptr< Costmap2DPublisher > | costmap_publisher_ |
| std::vector< std::unique_ptr< Costmap2DPublisher > > | layer_publishers_ |
| nav2::Subscription< geometry_msgs::msg::Polygon >::SharedPtr | footprint_sub_ |
| nav2::Subscription< geometry_msgs::msg::PolygonStamped >::SharedPtr | footprint_stamped_sub_ |
| nav2::Subscription< rcl_interfaces::msg::ParameterEvent >::SharedPtr | parameter_sub_ |
| rclcpp::CallbackGroup::SharedPtr | callback_group_ |
| rclcpp::executors::SingleThreadedExecutor::SharedPtr | executor_ |
| std::unique_ptr< nav2::NodeThread > | executor_thread_ |
| nav2::TransformBuffer::SharedPtr | tf_buffer_ |
| nav2::TransformListener::SharedPtr | tf_listener_ |
| std::unique_ptr< LayeredCostmap > | layered_costmap_ {nullptr} |
| std::string | name_ |
| bool | map_update_thread_shutdown_ {false} |
| std::atomic< bool > | stop_updates_ {false} |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< bool > | stopped_ {true} |
| std::mutex | _dynamic_parameter_mutex |
| std::unique_ptr< std::thread > | map_update_thread_ |
| A thread for updating the map. | |
| rclcpp::Time | last_publish_ {0, 0, RCL_ROS_TIME} |
| rclcpp::Duration | publish_cycle_ {1, 0} |
| pluginlib::ClassLoader< Layer > | plugin_loader_ {"nav2_costmap_2d", "nav2_costmap_2d::Layer"} |
| bool | always_send_full_costmap_ {false} |
| std::string | footprint_ |
| float | footprint_padding_ {0} |
| std::string | global_frame_ |
| The global frame for the costmap. | |
| int | map_height_meters_ {0} |
| double | map_publish_frequency_ {0} |
| double | map_update_frequency_ {0} |
| int | map_width_meters_ {0} |
| double | origin_x_ {0} |
| double | origin_y_ {0} |
| std::vector< std::string > | default_plugins_ |
| std::vector< std::string > | default_types_ |
| std::vector< std::string > | plugin_names_ |
| std::vector< std::string > | plugin_types_ |
| std::vector< std::string > | filter_names_ |
| std::vector< std::string > | filter_types_ |
| double | resolution_ {0} |
| std::string | robot_base_frame_ |
| The frame_id of the robot base. | |
| double | robot_radius_ |
| bool | rolling_window_ {false} |
| Whether to use a rolling window version of the costmap. | |
| bool | track_unknown_space_ {false} |
| double | transform_tolerance_ {0} |
| The timeout before transform errors. | |
| double | initial_transform_timeout_ {0} |
| The timeout before activation of the node errors. | |
| double | map_vis_z_ {0} |
| bool | subscribe_to_stamped_footprint_ {false} |
| If true, the footprint subscriber expects a PolygonStamped msg. | |
| bool | is_lifecycle_follower_ {true} |
| whether is a child-LifecycleNode or an independent node | |
| bool | use_radius_ {false} |
| std::vector< geometry_msgs::msg::Point > | unpadded_footprint_ |
| std::vector< geometry_msgs::msg::Point > | padded_footprint_ |
| nav2::ServiceServer< nav2_msgs::srv::GetCosts >::SharedPtr | get_cost_service_ |
| std::unique_ptr< ClearCostmapService > | clear_costmap_service_ |
| PostSetParametersCallbackHandle::SharedPtr | post_set_params_handler_ |
| OnSetParametersCallbackHandle::SharedPtr | on_set_params_handler |
Protected Attributes inherited from nav2::LifecycleNode | |
| std::unique_ptr< rclcpp::PreShutdownCallbackHandle > | rcl_preshutdown_cb_handle_ {nullptr} |
| std::shared_ptr< bond::Bond > | bond_ {nullptr} |
| double | bond_heartbeat_period {0.1} |
| rclcpp::TimerBase::SharedPtr | autostart_timer_ |
Additional Inherited Members | |
Public Types inherited from nav2::LifecycleNode | |
| using | SharedPtr = std::shared_ptr< nav2::LifecycleNode > |
| using | WeakPtr = std::weak_ptr< nav2::LifecycleNode > |
| using | SharedConstPointer = std::shared_ptr< const nav2::LifecycleNode > |
A ROS wrapper for a 2D Costmap. Handles subscribing to topics that provide observations about obstacles in either the form of PointCloud or LaserScan messages.
Definition at line 75 of file costmap_2d_ros.hpp.
|
explicit |
Constructor for the wrapper.
| options | Additional options to control creation of the node. |
Definition at line 64 of file costmap_2d_ros.cpp.
References init(), and is_lifecycle_follower_.

|
explicit |
Constructor for the wrapper.
| name | Name of the costmap ROS node which will also be used as a local namespace |
| parent_namespace | Absolute namespace of the node hosting the costmap node |
| use_sim_time | Whether to use simulation or real time |
Definition at line 96 of file costmap_2d_ros.cpp.
References init().

|
inline |
Returns the local frame of the costmap.
Definition at line 250 of file costmap_2d_ros.hpp.
References robot_base_frame_.
|
inline |
Return a pointer to the "master" costmap which receives updates from all the layers.
Same as calling getLayeredCostmap()->getCostmap().
Definition at line 232 of file costmap_2d_ros.hpp.
Referenced by nav2_costmap_2d::ClearCostmapService::ClearCostmapService(), and nav2_costmap_2d::ClearCostmapService::clearEntirely().

| void nav2_costmap_2d::Costmap2DROS::getCostsCallback | ( | const std::shared_ptr< rmw_request_id_t > | , |
| const std::shared_ptr< nav2_msgs::srv::GetCosts::Request > | request, | ||
| const std::shared_ptr< nav2_msgs::srv::GetCosts::Response > | response | ||
| ) |
Get the cost at a point in costmap.
| request | x and y coordinates in map |
| response | cost of the point |
Definition at line 891 of file costmap_2d_ros.cpp.
References nav2_costmap_2d::FootprintCollisionChecker< CostmapT >::footprintCostAtPose(), nav2_costmap_2d::Costmap2D::getCost(), transformPoseToGlobalFrame(), and nav2_costmap_2d::Costmap2D::worldToMap().
Referenced by on_configure().


|
inline |
Returns the global frame of the costmap.
Definition at line 241 of file costmap_2d_ros.hpp.
References global_frame_.
Referenced by nav2_costmap_2d::ClearCostmapService::clearAroundPose().

| void nav2_costmap_2d::Costmap2DROS::getOrientedFootprint | ( | std::vector< geometry_msgs::msg::Point > & | oriented_footprint | ) |
Build the oriented footprint of the robot at the robot's current pose.
| oriented_footprint | Will be filled with the points in the oriented footprint of the robot |
Definition at line 519 of file costmap_2d_ros.cpp.
References getRobotPose(), and nav2_costmap_2d::transformFootprint().

|
inline |
Return the current footprint of the robot as a vector of points.
This version of the footprint is padded by the footprint_padding_ distance, set in the rosparam "footprint_padding".
The footprint initially comes from the rosparam "footprint" but can be overwritten by dynamic reconfigure or by messages received on the "footprint" topic.
Definition at line 277 of file costmap_2d_ros.hpp.
| bool nav2_costmap_2d::Costmap2DROS::getRobotPose | ( | geometry_msgs::msg::PoseStamped & | global_pose | ) |
Get the pose of the robot in the global frame of the costmap.
| global_pose | Will be set to the pose of the robot in the global frame of the costmap |
Definition at line 740 of file costmap_2d_ros.cpp.
References global_frame_, robot_base_frame_, and transform_tolerance_.
Referenced by getOrientedFootprint(), and updateMap().

|
inline |
Get the costmap's robot_radius_ parameter, corresponding to raidus of the robot footprint when it is defined as as circle (i.e. when use_radius_ == true).
Definition at line 340 of file costmap_2d_ros.hpp.
|
inline |
Return the current unpadded footprint of the robot as a vector of points.
This is the raw version of the footprint without padding.
The footprint initially comes from the rosparam "footprint" but can be overwritten by dynamic reconfigure or by messages received on the "footprint" topic.
Definition at line 289 of file costmap_2d_ros.hpp.
|
inline |
Get the costmap's use_radius_ parameter, corresponding to whether the footprint for the robot is a circle with radius robot_radius_ or an arbitrarily defined footprint in footprint_.
Definition at line 332 of file costmap_2d_ros.hpp.
| void nav2_costmap_2d::Costmap2DROS::setRobotFootprint | ( | const std::vector< geometry_msgs::msg::Point > & | points | ) |
Set the footprint of the robot to be the given set of points, padded by footprint_padding.
Should be a convex polygon, though this is not enforced.
First expands the given polygon by footprint_padding_ and then sets padded_footprint_ and calls layered_costmap_->setFootprint(). Also saves the unpadded footprint, which is available from getUnpaddedRobotFootprint().
Definition at line 497 of file costmap_2d_ros.cpp.
References nav2_costmap_2d::padFootprint().
Referenced by on_configure(), setRobotFootprintPolygon(), and updateParametersCallback().


| void nav2_costmap_2d::Costmap2DROS::setRobotFootprintPolygon | ( | const geometry_msgs::msg::Polygon & | footprint | ) |
Set the footprint of the robot to be the given polygon, padded by footprint_padding.
Should be a convex polygon, though this is not enforced.
First expands the given polygon by footprint_padding_ and then sets padded_footprint_ and calls layered_costmap_->setFootprint(). Also saves the unpadded footprint, which is available from getUnpaddedRobotFootprint().
Definition at line 512 of file costmap_2d_ros.cpp.
References setRobotFootprint(), and nav2_costmap_2d::toPointVector().
Referenced by on_configure().


| bool nav2_costmap_2d::Costmap2DROS::transformPoseToGlobalFrame | ( | const geometry_msgs::msg::PoseStamped & | input_pose, |
| geometry_msgs::msg::PoseStamped & | transformed_pose | ||
| ) |
Transform the input_pose in the global frame of the costmap.
| input_pose | pose to be transformed |
| transformed_pose | pose transformed |
Definition at line 748 of file costmap_2d_ros.cpp.
References global_frame_, and transform_tolerance_.
Referenced by getCostsCallback().

|
protected |
Apply parameter updates after validation This callback is executed when parameters have been successfully updated. It updates the internal configuration of the node with the new parameter values.
| parameters | List of parameters that have been updated. |
Definition at line 823 of file costmap_2d_ros.cpp.
References nav2_costmap_2d::makeFootprintFromRadius(), nav2_costmap_2d::makeFootprintFromString(), nav2_costmap_2d::padFootprint(), robot_base_frame_, setRobotFootprint(), transform_tolerance_, and updateMap().
Referenced by on_activate().


|
protected |
Validate incoming parameter updates before applying them. This callback is triggered when one or more parameters are about to be updated. It checks the validity of parameter values and rejects updates that would lead to invalid or inconsistent configurations.
| parameters | List of parameters that are being updated. |
Definition at line 762 of file costmap_2d_ros.cpp.
References global_frame_, and robot_base_frame_.
Referenced by on_activate().

| void nav2_costmap_2d::Costmap2DROS::waitUntilCurrent | ( | const rclcpp::Duration & | timeout | ) |
Wait for the costmap to become current after updates or parameter changes.
| timeout | Maximum time to wait for costmap to become current |
| std::runtime_error | if timeout is exceeded |
Definition at line 627 of file costmap_2d_ros.cpp.
References isCurrent().

|
protected |
The height of map, allows to avoid flickering at -0.008
Definition at line 416 of file costmap_2d_ros.hpp.
Referenced by getParameters(), and on_configure().