Fix ValidateTrajectoryOptions(). (#465)

The checks in ValidateTrajectoryOptions() are both obsolete. Instead
we now just check that the correct trajectory builder options exist
at all.

Also checks options in Node::StartTrajectoryWithDefaultTopics() now.
master
Wolfgang Hess 2017-08-01 16:04:12 +02:00 committed by GitHub
parent ace7ab5f05
commit 061731399a
1 changed files with 9 additions and 13 deletions

View File

@ -347,18 +347,13 @@ void Node::LaunchSubscribers(const TrajectoryOptions& options,
} }
bool Node::ValidateTrajectoryOptions(const TrajectoryOptions& options) { bool Node::ValidateTrajectoryOptions(const TrajectoryOptions& options) {
if (node_options_.map_builder_options.use_trajectory_builder_2d() && if (node_options_.map_builder_options.use_trajectory_builder_2d()) {
options.trajectory_builder_options.has_trajectory_builder_2d_options()) { return options.trajectory_builder_options
// Only one point cloud source is supported in 2D. .has_trajectory_builder_2d_options();
if (options.num_point_clouds <= 1) {
return true;
}
}
if (node_options_.map_builder_options.use_trajectory_builder_3d() &&
options.trajectory_builder_options.has_trajectory_builder_3d_options()) {
if (options.num_point_clouds != 0) {
return true;
} }
if (node_options_.map_builder_options.use_trajectory_builder_3d()) {
return options.trajectory_builder_options
.has_trajectory_builder_3d_options();
} }
return false; return false;
} }
@ -381,11 +376,11 @@ bool Node::HandleStartTrajectory(
carto::common::MutexLocker lock(&mutex_); carto::common::MutexLocker lock(&mutex_);
TrajectoryOptions options; TrajectoryOptions options;
if (!FromRosMessage(request.options, &options) || if (!FromRosMessage(request.options, &options) ||
!Node::ValidateTrajectoryOptions(options)) { !ValidateTrajectoryOptions(options)) {
LOG(ERROR) << "Invalid trajectory options."; LOG(ERROR) << "Invalid trajectory options.";
return false; return false;
} }
if (!Node::ValidateTopicNames(request.topics, options)) { if (!ValidateTopicNames(request.topics, options)) {
LOG(ERROR) << "Invalid topics."; LOG(ERROR) << "Invalid topics.";
return false; return false;
} }
@ -395,6 +390,7 @@ bool Node::HandleStartTrajectory(
void Node::StartTrajectoryWithDefaultTopics(const TrajectoryOptions& options) { void Node::StartTrajectoryWithDefaultTopics(const TrajectoryOptions& options) {
carto::common::MutexLocker lock(&mutex_); carto::common::MutexLocker lock(&mutex_);
CHECK(ValidateTrajectoryOptions(options));
AddTrajectory(options, DefaultSensorTopics()); AddTrajectory(options, DefaultSensorTopics());
} }