Add include_unfinished_submaps parameter to SerializeState() (#966)
- default to false in gRPC node (unsupported in `MapBuilderStub`) - default to true in classic ROS nodes (as it was before) - add as parameter to `write_state`master
parent
7fbb628a21
commit
edf25139a2
|
@ -78,7 +78,8 @@ void Run() {
|
||||||
node.RunFinalOptimization();
|
node.RunFinalOptimization();
|
||||||
|
|
||||||
if (!FLAGS_save_map_filename.empty()) {
|
if (!FLAGS_save_map_filename.empty()) {
|
||||||
node.SerializeState(FLAGS_save_map_filename);
|
node.SerializeState(FLAGS_save_map_filename,
|
||||||
|
false /* include_unfinished_submaps */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,10 @@ void MapBuilderBridge::RunFinalOptimization() {
|
||||||
map_builder_->pose_graph()->RunFinalOptimization();
|
map_builder_->pose_graph()->RunFinalOptimization();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapBuilderBridge::SerializeState(const std::string& filename) {
|
bool MapBuilderBridge::SerializeState(const std::string& filename,
|
||||||
|
const bool include_unfinished_submaps) {
|
||||||
cartographer::io::ProtoStreamWriter writer(filename);
|
cartographer::io::ProtoStreamWriter writer(filename);
|
||||||
map_builder_->SerializeState(/*include_unfinished_submaps=*/true, &writer);
|
map_builder_->SerializeState(include_unfinished_submaps, &writer);
|
||||||
return writer.Close();
|
return writer.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ class MapBuilderBridge {
|
||||||
const TrajectoryOptions& trajectory_options);
|
const TrajectoryOptions& trajectory_options);
|
||||||
void FinishTrajectory(int trajectory_id);
|
void FinishTrajectory(int trajectory_id);
|
||||||
void RunFinalOptimization();
|
void RunFinalOptimization();
|
||||||
bool SerializeState(const std::string& filename);
|
bool SerializeState(const std::string& filename,
|
||||||
|
const bool include_unfinished_submaps);
|
||||||
|
|
||||||
void HandleSubmapQuery(
|
void HandleSubmapQuery(
|
||||||
cartographer_ros_msgs::SubmapQuery::Request& request,
|
cartographer_ros_msgs::SubmapQuery::Request& request,
|
||||||
|
|
|
@ -639,7 +639,8 @@ bool Node::HandleWriteState(
|
||||||
::cartographer_ros_msgs::WriteState::Request& request,
|
::cartographer_ros_msgs::WriteState::Request& request,
|
||||||
::cartographer_ros_msgs::WriteState::Response& response) {
|
::cartographer_ros_msgs::WriteState::Response& response) {
|
||||||
carto::common::MutexLocker lock(&mutex_);
|
carto::common::MutexLocker lock(&mutex_);
|
||||||
if (map_builder_bridge_.SerializeState(request.filename)) {
|
if (map_builder_bridge_.SerializeState(request.filename,
|
||||||
|
request.include_unfinished_submaps)) {
|
||||||
response.status.code = cartographer_ros_msgs::StatusCode::OK;
|
response.status.code = cartographer_ros_msgs::StatusCode::OK;
|
||||||
response.status.message = "State written to '" + request.filename + "'.";
|
response.status.message = "State written to '" + request.filename + "'.";
|
||||||
} else {
|
} else {
|
||||||
|
@ -787,9 +788,11 @@ void Node::HandlePointCloud2Message(
|
||||||
->HandlePointCloud2Message(sensor_id, msg);
|
->HandlePointCloud2Message(sensor_id, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::SerializeState(const std::string& filename) {
|
void Node::SerializeState(const std::string& filename,
|
||||||
|
const bool include_unfinished_submaps) {
|
||||||
carto::common::MutexLocker lock(&mutex_);
|
carto::common::MutexLocker lock(&mutex_);
|
||||||
CHECK(map_builder_bridge_.SerializeState(filename))
|
CHECK(
|
||||||
|
map_builder_bridge_.SerializeState(filename, include_unfinished_submaps))
|
||||||
<< "Could not write state.";
|
<< "Could not write state.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,8 @@ class Node {
|
||||||
const sensor_msgs::PointCloud2::ConstPtr& msg);
|
const sensor_msgs::PointCloud2::ConstPtr& msg);
|
||||||
|
|
||||||
// Serializes the complete Node state.
|
// Serializes the complete Node state.
|
||||||
void SerializeState(const std::string& filename);
|
void SerializeState(const std::string& filename,
|
||||||
|
const bool include_unfinished_submaps);
|
||||||
|
|
||||||
// Loads a serialized SLAM state from a .pbstream file.
|
// Loads a serialized SLAM state from a .pbstream file.
|
||||||
void LoadState(const std::string& state_filename, bool load_frozen_state);
|
void LoadState(const std::string& state_filename, bool load_frozen_state);
|
||||||
|
|
|
@ -74,7 +74,8 @@ void Run() {
|
||||||
node.RunFinalOptimization();
|
node.RunFinalOptimization();
|
||||||
|
|
||||||
if (!FLAGS_save_state_filename.empty()) {
|
if (!FLAGS_save_state_filename.empty()) {
|
||||||
node.SerializeState(FLAGS_save_state_filename);
|
node.SerializeState(FLAGS_save_state_filename,
|
||||||
|
true /* include_unfinished_submaps */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,8 @@ void RunOfflineNode(const MapBuilderFactory& map_builder_factory) {
|
||||||
const std::string suffix = ".pbstream";
|
const std::string suffix = ".pbstream";
|
||||||
const std::string state_output_filename = output_filename + suffix;
|
const std::string state_output_filename = output_filename + suffix;
|
||||||
LOG(INFO) << "Writing state to '" << state_output_filename << "'...";
|
LOG(INFO) << "Writing state to '" << state_output_filename << "'...";
|
||||||
node.SerializeState(state_output_filename);
|
node.SerializeState(state_output_filename,
|
||||||
|
true /* include_unfinished_submaps */);
|
||||||
}
|
}
|
||||||
if (FLAGS_keep_running) {
|
if (FLAGS_keep_running) {
|
||||||
::ros::waitForShutdown();
|
::ros::waitForShutdown();
|
||||||
|
|
|
@ -13,5 +13,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
string filename
|
string filename
|
||||||
|
bool include_unfinished_submaps
|
||||||
---
|
---
|
||||||
cartographer_ros_msgs/StatusResponse status
|
cartographer_ros_msgs/StatusResponse status
|
||||||
|
|
Loading…
Reference in New Issue