Skip to content

Commit

Permalink
control: updated integrated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjiang2018 authored and Capri2014 committed Nov 25, 2019
1 parent f606afb commit 32bd225
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 2 additions & 4 deletions modules/control/control_component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ bool ControlComponent::Init() {
} else {
local_view_writer_ =
node_->CreateWriter<LocalView>(FLAGS_control_local_view_topic);
CHECK(local_view_writer_);
pad_msg_writer_ = node_->CreateWriter<PadMessage>(FLAGS_pad_topic);
CHECK(pad_msg_writer_);
CHECK(local_view_writer_ != nullptr);
}

// set initial vehicle state by cmd
Expand Down Expand Up @@ -312,6 +310,7 @@ bool ControlComponent::Proc() {
}

{
// TODO(SHU): to avoid redundent copy
std::lock_guard<std::mutex> lock(mutex_);
local_view_.mutable_chassis()->CopyFrom(latest_chassis_);
local_view_.mutable_trajectory()->CopyFrom(latest_trajectory_);
Expand All @@ -321,7 +320,6 @@ bool ControlComponent::Proc() {
// use control submodules
if (FLAGS_use_control_submodules) {
local_view_writer_->Write(std::make_shared<LocalView>(local_view_));
pad_msg_writer_->Write(std::make_shared<PadMessage>(pad_msg_));
return true;
}

Expand Down
1 change: 0 additions & 1 deletion modules/control/control_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class ControlComponent final : public apollo::cyber::TimerComponent {
std::shared_ptr<Writer<ControlCommand>> control_cmd_writer_;
// when using control submodules
std::shared_ptr<Writer<LocalView>> local_view_writer_;
std::shared_ptr<Writer<PadMessage>> pad_msg_writer_;

common::monitor::MonitorLogBuffer monitor_logger_buffer_;

Expand Down
8 changes: 7 additions & 1 deletion modules/control/integration_tests/control_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,19 @@ bool ControlTestBase::test_control() {
control_.OnMonitor(monitor_message);
}

control_.local_view_.mutable_chassis()->CopyFrom(control_.latest_chassis_);
control_.local_view_.mutable_trajectory()->CopyFrom(
control_.latest_trajectory_);
control_.local_view_.mutable_localization()->CopyFrom(
control_.latest_localization_);

auto err = control_.ProduceControlCommand(&control_command_);
if (!err.ok()) {
ADEBUG << "control ProduceControlCommand failed";
return false;
}
return true;
}
} // namespace control

void ControlTestBase::trim_control_command(ControlCommand *origin) {
origin->mutable_header()->clear_radar_timestamp();
Expand Down
1 change: 1 addition & 0 deletions modules/control/submodules/preprocessor_submodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ bool PreprocessorSubmodule::Proc(
AERROR << "local view msg is not ready!";
return false;
}
// TODO(SHU): to avoid redundent copy
local_view_->CopyFrom(*local_view_msg);
}

Expand Down

0 comments on commit 32bd225

Please sign in to comment.