29 #include "rtabmap_ros/MapData.h" 44 #include <nav_msgs/OccupancyGrid.h> 45 #include <std_srvs/Empty.h> 58 std::string configPath;
59 pnh.
param(
"config_path", configPath, configPath);
65 if(!configPath.empty())
73 for(ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
75 ParametersMap::iterator jter = allParameters.find(iter->first);
76 if(jter!=allParameters.end())
78 iter->second = jter->second;
84 ROS_ERROR(
"Config file \"%s\" not found!", configPath.c_str());
87 for(rtabmap::ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
98 else if(pnh.
getParam(iter->first, vBool))
103 else if(pnh.
getParam(iter->first, vDouble))
108 else if(pnh.
getParam(iter->first, vInt))
114 if(iter->first.compare(Parameters::kVisMinInliers()) == 0 && atoi(iter->second.c_str()) < 8)
116 ROS_WARN(
"Parameter min_inliers must be >= 8, setting to 8...");
122 for(rtabmap::ParametersMap::iterator iter=argParameters.begin(); iter!=argParameters.end(); ++iter)
124 rtabmap::ParametersMap::iterator jter = parameters.find(iter->first);
125 if(jter!=parameters.end())
128 jter->second = iter->second;
140 if(iter->second.first && parameters.find(iter->second.second) != parameters.end())
143 parameters.at(iter->second.second)= vStr;
144 ROS_WARN(
"%s: Parameter name changed: \"%s\" -> \"%s\". Please update your launch file accordingly. Value \"%s\" is still set to the new parameter name.",
149 if(iter->second.second.empty())
151 ROS_ERROR(
"%s: Parameter \"%s\" doesn't exist anymore!",
156 ROS_ERROR(
"%s: Parameter \"%s\" doesn't exist anymore! You may look at this similar parameter: \"%s\"",
164 mapsManager_.backwardCompatibilityParameters(pnh, parameters);
165 mapsManager_.setParameters(parameters);
181 std::map<int, Transform> poses;
182 std::multimap<int, Link> constraints;
185 for(
unsigned int i=0; i<msg->nodes.size(); ++i)
187 if(msg->nodes[i].image.size() ||
188 msg->nodes[i].depth.size() ||
189 msg->nodes[i].laserScan.size())
196 if(poses.size() && nodes_.find(poses.rbegin()->first) != nodes_.end())
198 Signature tmpS = nodes_.at(poses.rbegin()->first);
202 poses.insert(std::make_pair(-1, poses.rbegin()->second));
206 poses = mapsManager_.updateMapCaches(
213 mapsManager_.publishMaps(poses, msg->header.stamp, msg->header.frame_id);
215 ROS_INFO(
"map_assembler: Publishing data = %fs", timer.
ticks());
218 bool reset(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
221 mapsManager_.clear();
235 int main(
int argc,
char** argv)
240 for(
int i=1;i<argc;++i)
242 if(strcmp(argv[i],
"--params") == 0)
247 for(rtabmap::ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
249 std::string str =
"Param: " + iter->first +
" = \"" + iter->second +
"\"";
252 std::setw(60 - str.size()) <<
258 ROS_WARN(
"Node will now exit after showing default parameters because " 259 "argument \"--params\" is detected!");
262 else if(strcmp(argv[i],
"--udebug") == 0)
266 else if(strcmp(argv[i],
"--uinfo") == 0)
static const std::map< std::string, std::pair< bool, std::string > > & getRemovedParameters()
static std::string getDescription(const std::string ¶mKey)
rtabmap::Signature nodeDataFromROS(const rtabmap_ros::NodeData &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
static ParametersMap parseArguments(int argc, char *argv[], bool onlyParameters=false)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::map< std::string, std::string > ParametersMap
ROSCPP_DECL const std::string & getName()
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
static void setLevel(ULogger::Level level)
std::string uBool2Str(bool boolean)
ROSCPP_DECL void spin(Spinner &spinner)
bool reset(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
int main(int argc, char **argv)
std::map< int, Signature > nodes_
std::string uNumber2Str(unsigned int number)
ros::ServiceServer resetService_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void mapGraphFromROS(const rtabmap_ros::MapGraph &msg, std::map< int, rtabmap::Transform > &poses, std::multimap< int, rtabmap::Link > &links, rtabmap::Transform &mapToOdom)
static const ParametersMap & getDefaultParameters()
const Transform & getPose() const
SensorData & sensorData()
bool getParam(const std::string &key, std::string &s) const
MapAssembler(int &argc, char **argv)
static void readINI(const std::string &configFile, ParametersMap ¶meters, bool modifiedOnly=false)
void mapDataReceivedCallback(const rtabmap_ros::MapDataConstPtr &msg)
ros::Subscriber mapDataTopic_
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)