trsing’s diary

勉強、読んだ本、仕事で調べたこととかのメモ。

ros noeticのmap_serverでマップを変更する

change_map serviceを使う。

ros wiki

amclを使っている場合はuse_map_topictrueにしておく。

ソースコード

      //Change the currently published map
      change_map_srv_ = nh_.advertiseService("change_map", &MapServer::changeMapCallback, this);
    bool changeMapCallback(nav_msgs::LoadMap::Request  &request,
                           nav_msgs::LoadMap::Response &response )
    {
      if (loadMapFromYaml(request.map_url))
      {
        response.result = response.RESULT_SUCCESS;
        ROS_INFO("Changed map to %s", request.map_url.c_str());
      }
      else
      {
        response.result = response.RESULT_UNDEFINED_FAILURE;
      }
      return true;
    }

その他

パッケージは更新されててもros wikiは更新されてないのがそれなりにあるっぽい。amclもパラメータ増えてるし。