4#include "rclcpp/rclcpp.hpp"
14#include <lanelet2_core/LaneletMap.h>
15#include <lanelet2_io/Exceptions.h>
16#include <lanelet2_io/Io.h>
17#include <lanelet2_io/Projection.h>
18#include <lanelet2_projection/UTM.h>
20#include "geometry_msgs/msg/transform_stamped.hpp"
21#include "sensor_msgs/msg/nav_sat_fix.hpp"
22#include "tf2_ros/static_transform_broadcaster.h"
35template <
typename T,
typename A>
36struct is_vector<std::vector<T, A>> : std::true_type {};
66 const std::string& description,
67 const bool add_to_auto_reconfigurable_params =
true,
68 const bool is_required =
false,
69 const bool read_only =
false,
70 const std::optional<double>& from_value = std::nullopt,
71 const std::optional<double>& to_value = std::nullopt,
72 const std::optional<double>& step_value = std::nullopt,
73 const std::string& additional_constraints =
"");
81 rcl_interfaces::msg::SetParametersResult
parametersCallback(
const std::vector<rclcpp::Parameter>& parameters);
109 void find_available_maps(
const std::string& directory, std::vector<Lanelet2MapMeta>& maps)
const;
126 bool deriveOriginFromMap(
const std::string& map_filepath,
double& origin_lat,
double& origin_lon)
const;
136 bool map_sanity_check(std::string map_filepath,
double origin_lat,
double origin_lon)
const;
151 static void derive_utm_zone(
const double latitude,
const double longitude,
int& zone,
bool& northp);
void unsetMapParameters()
Clears map-specific parameters after an invalid or unloaded map state.
std::vector< Lanelet2MapMeta > available_maps_
void updateMapParameters()
Writes the current map state into this node's exported ROS parameters.
double current_longitude_
rclcpp::TimerBase::SharedPtr one_shot_timer_
rclcpp::TimerBase::SharedPtr automatic_map_timer_
bool declareAndLoadParameter(const std::string &name, T ¶m, const std::string &description, const bool add_to_auto_reconfigurable_params=true, const bool is_required=false, const bool read_only=false, const std::optional< double > &from_value=std::nullopt, const std::optional< double > &to_value=std::nullopt, const std::optional< double > &step_value=std::nullopt, const std::string &additional_constraints="")
Declares and loads a ROS parameter.
OnSetParametersCallbackHandle::SharedPtr parameters_callback_
Callback handle for dynamic parameter reconfiguration.
void setup()
Sets up timers, callbacks, publishers, and initial map loading.
void automaticMapUpdateTimerCallback()
Periodically reevaluates the best map when automatic selection is enabled.
std::shared_ptr< tf2_ros::StaticTransformBroadcaster > tf_static_broadcaster_
std::string map_filepath_
bool map_sanity_check(std::string map_filepath, double origin_lat, double origin_lon) const
Tries to load a map with the provided origin to verify that it is usable.
void derive_map_meta(Lanelet2MapMeta &map_meta) const
Fills the derived metadata fields for a discovered map.
Lanelet2MapServer()
Creates the Lanelet2 map server node and declares its parameters.
bool deriveOriginFromMap(const std::string &map_filepath, double &origin_lat, double &origin_lon) const
Derives a south-west origin latitude and longitude from a Lanelet2 map file.
std::string map_contents_
rcl_interfaces::msg::SetParametersResult parametersCallback(const std::vector< rclcpp::Parameter > ¶meters)
Handles reconfiguration when a parameter value is changed.
void loadMapContents()
Loads the configured map file and caches its serialized contents.
std::string map_directory_
static void derive_utm_zone(const double latitude, const double longitude, int &zone, bool &northp)
Derives the UTM zone and hemisphere from a geographic position.
void navSatFixCallback(const sensor_msgs::msg::NavSatFix::SharedPtr msg)
Stores the latest GNSS fix for automatic map selection.
std::vector< std::tuple< std::string, std::function< void(const rclcpp::Parameter &)> > > auto_reconfigurable_params_
Auto-reconfigurable parameters for dynamic reconfiguration.
void find_available_maps(const std::string &directory, std::vector< Lanelet2MapMeta > &maps) const
Recursively scans a directory for available Lanelet2 map files.
void pub_tf() const
Publishes the static transform from the derived UTM frame to the map frame.
bool use_automatic_map_selection_
rclcpp::Subscription< sensor_msgs::msg::NavSatFix >::SharedPtr navsat_subscription_
std::string map_frame_id_
constexpr bool is_vector_v