12 control_pad_key_ = info.control_pad_key;
13 enable_chassis_ = info.enable_chassis;
14 enable_gimbal_ = info.enable_gimbal;
15 enable_shoot_ = info.enable_shoot;
22 if (enable_gimbal_ && info.secondary_gimbal_info) {
24 if (!secondary_gimbal_)
return false;
26 if (enable_gimbal_ && info.large_yaw_info) {
28 if (!large_yaw_)
return false;
30 if (enable_shoot_ && !
roboctrl::init(info.shoot_info))
return false;
31 if (enable_shoot_ && info.secondary_shoot_info) {
32 secondary_shoot_ = std::make_unique<shoot>();
33 if (!secondary_shoot_->init(*info.secondary_shoot_info))
return false;
35 controlled_motors_.clear();
36 const auto bind_motor = [
this](
const std::string& key) {
37 auto* motor = &roboctrl::get<device::dji_motor>(key);
38 if (std::find(controlled_motors_.begin(), controlled_motors_.end(), motor) == controlled_motors_.end())
39 controlled_motors_.push_back(motor);
41 if (enable_chassis_) {
42 bind_motor(info.chassis_info.left_front_motor);
43 bind_motor(info.chassis_info.right_front_motor);
44 bind_motor(info.chassis_info.left_rear_motor);
45 bind_motor(info.chassis_info.right_rear_motor);
48 for (
auto*
gimbal : {gimbal_, secondary_gimbal_, large_yaw_})
50 if (enable_shoot_) roboctrl::get<shoot>().start();
51 if (secondary_shoot_) secondary_shoot_->start();
52 auto motion = info.motion_info;
53 motion.control_pad_key = control_pad_key_;
54 motion.enable_shoot = enable_shoot_;
75 log_warn(
"Ignored request to leave NoForce during shutdown");
76 state = robot_state::NoForce;
79 const bool gimbal_enabled =
state != robot_state::NoForce;
80 const bool motion_enabled = gimbal_enabled &&
state != robot_state::FinishInit;
81 if (chassis_) chassis_->
set_enabled(motion_enabled);
82 for (
auto*
gimbal : {gimbal_, secondary_gimbal_, large_yaw_}) {
87 for (
auto* motor : controlled_motors_) motor->set_enabled(motion_enabled);
88 if (enable_shoot_) roboctrl::get<shoot>().set_enabled(motion_enabled);
89 if (secondary_shoot_) secondary_shoot_->set_enabled(motion_enabled);