8 #include <sensor_msgs/LaserScan.h> 14 #include "../utils/map_dumpers.h" 15 #include "../utils/properties_providers.h" 16 #include "../slams/viny/init_viny_slam.h" 17 #include "../slams/tiny/init_tiny_slam.h" 18 #include "../slams/gmapping/init_gmapping.h" 31 if (*arg == 0) {
break; }
33 if ((*arg)[0] ==
'-') {
44 switch (mandatory_id) {
45 case Slam_Type_Id:
slam_type = *arg;
break;
48 std::cerr <<
"[Error] Wrong number of mandatory properties\n";
52 }
else if (flag ==
"-p") {
54 }
else if (flag ==
"-t") {
55 traj_dumper = std::make_shared<RobotPoseTumTrajectoryDumper>(*arg);
56 }
else if (flag ==
"-m") {
59 std::cout <<
"[Warn] Skip parameter for unknown flag \"" 60 << flag <<
"\"" << std::endl;
69 stream <<
"Args: <slam type> <bag file>\n" 70 <<
" [-v] [-t <traj file>] [-m <map file>] \n" 71 <<
" [-p <properties file>]\n";
86 template <
typename MapType>
93 assert(args.
props.
get_bool(
"in/lscan2D/ros/topic/enabled",
false));
94 assert(args.
props.
get_bool(
"in/odometry/ros/tf/enabled",
false));
102 auto scan_id =
unsigned{0};
103 while (bag.extract_next_msg()) {
104 lscan_observer.handle_transformed_msg(bag.msg(), bag.transform());
106 args.
traj_dumper->log_robot_pose(bag.timestamp(), slam->pose());
111 std::cout <<
"Handled scan #" << scan_id << std::endl;
116 std::ofstream map_file(args.
map_fname, std::ios::binary);
121 int main(
int argc,
char** argv) {
123 if (!
args.is_valid) {
124 args.print_usage(std::cout);
128 if (
args.slam_type ==
"viny") {
130 }
else if (
args.slam_type ==
"tiny") {
132 }
else if (
args.slam_type ==
"gmapping") {
135 std::cout <<
"Unkonw slam type: " <<
args.slam_type << std::endl;
ProgramArgs & init(char **argv)
static constexpr auto Bag_Id
auto init_gmapping(const PropertiesProvider &props)
void print_usage(std::ostream &stream)
auto tf_ignored_transforms(const PropertiesProvider &props)
std::string laser_scan_2D_ros_topic_name(const PropertiesProvider &props)
std::shared_ptr< RobotPoseTumTrajectoryDumper > traj_dumper
bool get_use_trig_cache(const PropertiesProvider &props)
auto init_tiny_slam(const PropertiesProvider &props)
void run_slam(std::shared_ptr< LaserScanGridWorld< MapType >> slam, const ProgramArgs &args)
static void dump_map(std::ofstream &os, const GridMapType &map)
std::string tf_odom_frame_id(const PropertiesProvider &props)
static constexpr auto Slam_Type_Id
auto init_viny_slam(const PropertiesProvider &props)
int main(int argc, char **argv)
FilePropertiesProvider props
static constexpr auto Mandatory_Id_Nm
void append_file_content(const std::string &path)
str get_str(const std::string &id, const str &dflt) const override
bool get_skip_exceeding_lsr(const PropertiesProvider &props)
bool get_bool(const std::string &id, bool dflt) const override