1 #ifndef SLAM_CTOR_ROS_INIT_UTILS_H 2 #define SLAM_CTOR_ROS_INIT_UTILS_H 9 #include "../core/states/world.h" 11 #include "../utils/properties_providers.h" 19 const std::string &dflt_value) {
21 ros::param::param<std::string>(name, value, dflt_value);
26 return props.
get_str(
"in/lscan2D/ros/topic/name",
"/base_scan");
30 return props.
get_str(
"in/odometry/ros/tf/odom_frame_id",
"odom_combined");
42 bool async_correction;
43 ros::param::param<bool>(
"~ros/tf/async_correction", async_correction,
false);
44 return async_correction;
50 return props.
get_bool(
"in/lscan2D/skip_exceeding_vals",
57 return props.
get_bool(
"slam/performance/use_trig_cache",
false);
63 std::string Rec_Sep =
":", Entry_Sep =
"-";
64 std::unordered_map<std::string, std::vector<std::string>> ignores;
66 auto data = props.
get_str(
"in/odometry/ros/tf/ignore",
"");
67 auto next_entry_i = std::string::size_type{0};
68 while (next_entry_i < data.length()) {
69 auto next_sep_i = data.find(Rec_Sep, next_entry_i);
70 if (next_sep_i == std::string::npos) {
71 next_sep_i = data.length();
74 auto entry = data.substr(next_entry_i, next_sep_i - next_entry_i);
75 next_entry_i = next_sep_i + 1;
77 auto entry_sep_i = entry.find(
"-");
78 if (entry_sep_i == std::string::npos) {
79 std::cout <<
"[WARN] Unable to parse tf_ignore entry \"" 80 << entry <<
"\"" << std::endl;
83 auto from = entry.substr(0, entry_sep_i);
84 auto to = entry.substr(entry_sep_i + 1, entry.size() - entry_sep_i - 1);
85 ignores[
"/" + from].push_back(
"/" + to);
90 template <
typename ObservT,
typename MapT>
91 std::shared_ptr<PoseCorrectionTfPublisher<ObservT>>
95 auto pose_publisher = std::make_shared<PoseCorrectionTfPublisher<ObservT>>(
100 return pose_publisher;
103 template <
typename MapT>
104 std::shared_ptr<RobotPoseTfPublisher>
106 auto pose_publisher = std::make_shared<RobotPoseTfPublisher>(
109 return pose_publisher;
112 template <
typename ObservT,
typename MapT>
118 auto stamped_pose_publisher =
121 scan_provider->
subscribe(stamped_pose_publisher);
123 return stamped_pose_publisher;
126 template <
typename MapT>
127 std::shared_ptr<OccupancyGridPublisher<MapT>>
130 double ros_map_publishing_rate) {
131 auto map_publisher = std::make_shared<OccupancyGridPublisher<MapT>>(
132 nh.
advertise<nav_msgs::OccupancyGrid>(
"map", 5),
135 return map_publisher;
139 double &ros_map_rate,
140 int &ros_filter_queue,
141 int &ros_subscr_queue) {
142 ros::param::param<double>(
"~ros/tf/buffer_duration",ros_tf_buffer_size, 5.0);
143 ros::param::param<double>(
"~ros/rviz/map_publishing_rate", ros_map_rate, 5.0);
144 ros::param::param<int>(
"~ros/filter_queue_size",ros_filter_queue, 1000);
145 ros::param::param<int>(
"~ros/subscribers_queue_size",ros_subscr_queue, 1000);
std::shared_ptr< PoseCorrectionTfPublisher< ObservT > > create_pose_correction_tf_publisher(WorldObservable< MapT > *slam, TopicWithTransform< ObservT > *scan_prov, const PropertiesProvider &props)
auto tf_ignored_transforms(const PropertiesProvider &props)
virtual str get_str(const std::string &id, const str &dflt) const =0
std::shared_ptr< RobotPoseTfPublisher > create_robot_pose_tf_publisher(WorldObservable< MapT > *slam)
std::string laser_scan_2D_ros_topic_name(const PropertiesProvider &props)
bool get_use_trig_cache(const PropertiesProvider &props)
std::shared_ptr< OccupancyGridPublisher< MapT > > create_occupancy_grid_publisher(WorldObservable< MapT > *slam, ros::NodeHandle nh, double ros_map_publishing_rate)
void subscribe_map(std::shared_ptr< WorldMapObserver< MapType >> obs)
std::string tf_odom_frame_id(const PropertiesProvider &props)
void subscribe_pose(std::shared_ptr< WorldPoseObserver > obs)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::string tf_robot_pose_frame_id()
void init_constants_for_ros(double &ros_tf_buffer_size, double &ros_map_rate, int &ros_filter_queue, int &ros_subscr_queue)
auto make_pose_correction_observation_stamped_publisher(WorldObservable< MapT > *slam, TopicWithTransform< ObservT > *scan_provider, const PropertiesProvider &props)
bool is_async_correction()
bool get_skip_exceeding_lsr(const PropertiesProvider &props)
virtual bool get_bool(const std::string &id, bool dflt) const =0
std::string get_string_param(const std::string &name, const std::string &dflt_value)
std::string tf_map_frame_id()