mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 12:51:35 +08:00
uavcan: don't init ESC if UAVCAN_ENABLE isn't set for ESC
This commit is contained in:
@@ -81,6 +81,8 @@ UavcanEscController::init()
|
|||||||
_param_handles[i] = param_find(param_name);
|
_param_handles[i] = param_find(param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ public:
|
|||||||
|
|
||||||
int init();
|
int init();
|
||||||
|
|
||||||
|
bool initialized() { return _initialized; };
|
||||||
|
|
||||||
void update_outputs(uint16_t outputs[MAX_ACTUATORS], unsigned total_outputs);
|
void update_outputs(uint16_t outputs[MAX_ACTUATORS], unsigned total_outputs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +99,8 @@ private:
|
|||||||
typedef uavcan::MethodBinder<UavcanEscController *,
|
typedef uavcan::MethodBinder<UavcanEscController *,
|
||||||
void (UavcanEscController::*)(const uavcan::TimerEvent &)> TimerCbBinder;
|
void (UavcanEscController::*)(const uavcan::TimerEvent &)> TimerCbBinder;
|
||||||
|
|
||||||
|
bool _initialized{};
|
||||||
|
|
||||||
esc_status_s _esc_status{};
|
esc_status_s _esc_status{};
|
||||||
|
|
||||||
uORB::PublicationMulti<esc_status_s> _esc_status_pub{ORB_ID(esc_status)};
|
uORB::PublicationMulti<esc_status_s> _esc_status_pub{ORB_ID(esc_status)};
|
||||||
|
|||||||
@@ -529,10 +529,16 @@ UavcanNode::init(uavcan::NodeID node_id, UAVCAN_DRIVER::BusEvent &bus_events)
|
|||||||
|
|
||||||
// Actuators
|
// Actuators
|
||||||
#if defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER)
|
#if defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER)
|
||||||
ret = _esc_controller.init();
|
int32_t uavcan_enable = -1;
|
||||||
|
(void)param_get(param_find("UAVCAN_ENABLE"), &uavcan_enable);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (uavcan_enable > 2) {
|
||||||
return ret;
|
|
||||||
|
ret = _esc_controller.init();
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -607,10 +613,6 @@ UavcanNode::init(uavcan::NodeID node_id, UAVCAN_DRIVER::BusEvent &bus_events)
|
|||||||
_param_opcode_client.setCallback(ExecuteOpcodeCallback(this, &UavcanNode::cb_opcode));
|
_param_opcode_client.setCallback(ExecuteOpcodeCallback(this, &UavcanNode::cb_opcode));
|
||||||
_param_restartnode_client.setCallback(RestartNodeCallback(this, &UavcanNode::cb_restart));
|
_param_restartnode_client.setCallback(RestartNodeCallback(this, &UavcanNode::cb_restart));
|
||||||
|
|
||||||
|
|
||||||
int32_t uavcan_enable = 1;
|
|
||||||
(void)param_get(param_find("UAVCAN_ENABLE"), &uavcan_enable);
|
|
||||||
|
|
||||||
if (uavcan_enable > 1) {
|
if (uavcan_enable > 1) {
|
||||||
_servers = new UavcanServers(_node, _node_info_retriever);
|
_servers = new UavcanServers(_node, _node_info_retriever);
|
||||||
|
|
||||||
@@ -1079,7 +1081,10 @@ void UavcanNode::publish_node_statuses()
|
|||||||
bool UavcanMixingInterfaceESC::updateOutputs(uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs,
|
bool UavcanMixingInterfaceESC::updateOutputs(uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs,
|
||||||
unsigned num_control_groups_updated)
|
unsigned num_control_groups_updated)
|
||||||
{
|
{
|
||||||
_esc_controller.update_outputs(outputs, num_outputs);
|
if (_esc_controller.initialized()) {
|
||||||
|
_esc_controller.update_outputs(outputs, num_outputs);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user