29 #include "rtabmap_ros/MapData.h" 44 #include <nav_msgs/OccupancyGrid.h> 45 #include <std_srvs/Empty.h> 54 localGridsRegenerated_(
false)
59 std::string configPath;
60 pnh.
param(
"config_path", configPath, configPath);
61 pnh.
param(
"regenerate_local_grids", localGridsRegenerated_, localGridsRegenerated_);
67 if(!configPath.empty())
75 for(ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
77 ParametersMap::iterator jter = allParameters.find(iter->first);
78 if(jter!=allParameters.end())
80 iter->second = jter->second;
86 ROS_ERROR(
"Config file \"%s\" not found!", configPath.c_str());
89 for(rtabmap::ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
100 else if(pnh.
getParam(iter->first, vBool))
105 else if(pnh.
getParam(iter->first, vDouble))
110 else if(pnh.
getParam(iter->first, vInt))
116 if(iter->first.compare(Parameters::kVisMinInliers()) == 0 && atoi(iter->second.c_str()) < 8)
118 ROS_WARN(
"Parameter min_inliers must be >= 8, setting to 8...");
124 for(rtabmap::ParametersMap::iterator iter=argParameters.begin(); iter!=argParameters.end(); ++iter)
126 rtabmap::ParametersMap::iterator jter = parameters.find(iter->first);
127 if(jter!=parameters.end())
130 jter->second = iter->second;
142 if(iter->second.first && parameters.find(iter->second.second) != parameters.end())
145 parameters.at(iter->second.second)= vStr;
146 ROS_WARN(
"%s: Parameter name changed: \"%s\" -> \"%s\". Please update your launch file accordingly. Value \"%s\" is still set to the new parameter name.",
151 if(iter->second.second.empty())
153 ROS_ERROR(
"%s: Parameter \"%s\" doesn't exist anymore!",
158 ROS_ERROR(
"%s: Parameter \"%s\" doesn't exist anymore! You may look at this similar parameter: \"%s\"",
166 mapsManager_.backwardCompatibilityParameters(pnh, parameters);
167 mapsManager_.setParameters(parameters);
183 std::map<int, Transform> poses;
184 std::multimap<int, Link> constraints;
187 for(
unsigned int i=0; i<msg->nodes.size(); ++i)
189 if(msg->nodes[i].image.size() ||
190 msg->nodes[i].depth.size() ||
191 msg->nodes[i].laserScan.size())
194 if(localGridsRegenerated_)
198 uInsert(nodes_, std::make_pair(msg->nodes[i].id, data));
203 if(poses.size() && nodes_.find(poses.rbegin()->first) != nodes_.end())
205 Signature tmpS = nodes_.at(poses.rbegin()->first);
209 poses.insert(std::make_pair(0, poses.rbegin()->second));
213 poses = mapsManager_.updateMapCaches(
220 mapsManager_.publishMaps(poses, msg->header.stamp, msg->header.frame_id);
222 ROS_INFO(
"map_assembler: Publishing data = %fs", timer.
ticks());
225 bool reset(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
228 mapsManager_.clear();
244 int main(
int argc,
char** argv)
249 for(
int i=1;i<argc;++i)
251 if(strcmp(argv[i],
"--params") == 0)
256 for(rtabmap::ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
258 std::string str =
"Param: " + iter->first +
" = \"" + iter->second +
"\"";
261 std::setw(60 - str.size()) <<
267 ROS_WARN(
"Node will now exit after showing default parameters because " 268 "argument \"--params\" is detected!");
271 else if(strcmp(argv[i],
"--udebug") == 0)
275 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)
void setOccupancyGrid(const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewPoint)
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 localGridsRegenerated_
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)