提交 f412959c 编写于 作者: L luoqi06 提交者: Jiangtao Hu

Control : move logic from Proc() to Init()

上级 a4300af7
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include "modules/common/adapters/adapter_gflags.h"
#include "cybertron/common/log.h" #include "cybertron/common/log.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/common/time/time.h" #include "modules/common/time/time.h"
#include "modules/common/util/file.h" #include "modules/common/util/file.h"
#include "modules/common/vehicle_state/vehicle_state_provider.h" #include "modules/common/vehicle_state/vehicle_state_provider.h"
...@@ -97,6 +97,19 @@ bool ControlComponent::Init() { ...@@ -97,6 +97,19 @@ bool ControlComponent::Init() {
control_cmd_writer_ = node_->CreateWriter<ControlCommand>( control_cmd_writer_ = node_->CreateWriter<ControlCommand>(
control_conf_.control_command_channel()); control_conf_.control_command_channel());
// set initial vehicle state by cmd
// need to sleep, because advertised channel is not ready immediately
// simple test shows a short delay of 80 ms or so
AINFO << "Control resetting vehicle state, sleeping for 1000 ms ...";
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// should init_vehicle first, let car enter work status, then use status msg
// trigger control
AINFO << "Control default driving action is "
<< DrivingAction_Name(control_conf_.action());
pad_msg_.set_action(control_conf_.action());
return true; return true;
} }
...@@ -211,19 +224,6 @@ Status ControlComponent::ProduceControlCommand( ...@@ -211,19 +224,6 @@ Status ControlComponent::ProduceControlCommand(
} }
bool ControlComponent::Proc() { bool ControlComponent::Proc() {
// set initial vehicle state by cmd
// need to sleep, because advertised channel is not ready immediately
// simple test shows a short delay of 80 ms or so
AINFO << "Control resetting vehicle state, sleeping for 1000 ms ...";
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// should init_vehicle first, let car enter work status, then use status msg
// trigger control
AINFO << "Control default driving action is "
<< DrivingAction_Name(control_conf_.action());
pad_msg_.set_action(control_conf_.action());
double start_timestamp = Clock::NowInSeconds(); double start_timestamp = Clock::NowInSeconds();
if (control_conf_.is_control_test_mode() && if (control_conf_.is_control_test_mode() &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册