45 #include <px4_platform_common/px4_config.h> 46 #include <px4_platform_common/atomic.h> 47 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp> 56 #include <uavcan/helpers/heap_based_pool_allocator.hpp> 57 #include <uavcan/protocol/global_time_sync_master.hpp> 58 #include <uavcan/protocol/global_time_sync_slave.hpp> 59 #include <uavcan/protocol/node_status_monitor.hpp> 60 #include <uavcan/protocol/param/GetSet.hpp> 61 #include <uavcan/protocol/param/ExecuteOpcode.hpp> 62 #include <uavcan/protocol/RestartNode.hpp> 89 unsigned num_outputs,
unsigned num_control_groups_updated)
override;
109 static constexpr
unsigned MaxBitRatePerSec = 1000000;
110 static constexpr
unsigned bitPerFrame = 148;
111 static constexpr
unsigned FramePerSecond = MaxBitRatePerSec / bitPerFrame;
112 static constexpr
unsigned FramePerMSecond = ((FramePerSecond / 1000) + 1);
114 static constexpr
unsigned ScheduleIntervalMs = 3;
129 static constexpr
unsigned RxQueueLenPerIface = FramePerMSecond * ScheduleIntervalMs;
135 UavcanNode(uavcan::ICanDriver &can_driver, uavcan::ISystemClock &system_clock);
139 virtual int ioctl(
file *filp,
int cmd,
unsigned long arg);
141 static int start(uavcan::NodeID node_id, uint32_t bitrate);
151 void hardpoint_controller_set(uint8_t hardpoint_id, uint16_t
command);
154 static int getHardwareVersion(uavcan::protocol::HardwareVersion &hwver);
157 int list_params(
int remote_node_id);
158 int save_params(
int remote_node_id);
159 int set_param(
int remote_node_id,
const char *
name,
char *value);
160 int get_param(
int remote_node_id,
const char *name);
161 int reset_node(
int remote_node_id);
163 static void busevent_signal_trampoline();
168 void fill_node_info();
169 int init(uavcan::NodeID node_id, UAVCAN_DRIVER::BusEvent &bus_events);
170 void node_spin_once();
172 int start_fw_server();
173 int stop_fw_server();
174 int request_fw_check();
176 int print_params(uavcan::protocol::param::GetSet::Response &resp);
177 int get_set_param(
int nodeid,
const char *name, uavcan::protocol::param::GetSet::Request &req);
183 void enable_idle_throttle_when_armed(
bool value);
186 px4::atomic<int> _fw_server_action{
None};
187 int _fw_server_status{-1};
189 bool _is_armed{
false};
191 unsigned _output_count{0};
211 bool _idle_throttle_when_armed{
false};
212 int32_t _idle_throttle_when_armed_param{0};
219 void handle_time_sync(
const uavcan::TimerEvent &);
221 typedef uavcan::MethodBinder<UavcanNode *, void (UavcanNode::*)(const uavcan::TimerEvent &)>
TimerCallback;
224 bool _callback_success{
false};
226 uavcan::protocol::param::GetSet::Response *_setget_response{
nullptr};
229 void (UavcanNode::*)(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &)>
GetSetCallback;
230 typedef uavcan::MethodBinder<UavcanNode *,
231 void (UavcanNode::*)(
const uavcan::ServiceCallResult<uavcan::protocol::param::ExecuteOpcode> &)>
ExecuteOpcodeCallback;
232 typedef uavcan::MethodBinder<UavcanNode *,
233 void (UavcanNode::*)(
const uavcan::ServiceCallResult<uavcan::protocol::RestartNode> &)>
RestartNodeCallback;
235 void cb_setget(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &result);
236 void cb_opcode(
const uavcan::ServiceCallResult<uavcan::protocol::param::ExecuteOpcode> &result);
237 void cb_restart(
const uavcan::ServiceCallResult<uavcan::protocol::RestartNode> &result);
volatile bool _task_should_exit
uavcan::TimerEventForwarder< TimerCallback > _master_timer
uavcan::Node _node
library instance
uavcan::MethodBinder< UavcanNode *, void(UavcanNode::*)(const uavcan::ServiceCallResult< uavcan::protocol::param::GetSet > &)> GetSetCallback
MixingOutput & mixingOutput()
UAVCAN_DRIVER::CanInitHelper< RxQueueLenPerIface > CanInitHelper
pthread_mutex_t _node_mutex
void attachITxQueueInjector(ITxQueueInjector *injector)
MixingOutput _mixing_output
UAVCAN <–> ORB bridge for ESC messages: uavcan.equipment.esc.RawCommand uavcan.equipment.esc.RPMCommand uavcan.equipment.esc.Status.
UavcanEscController & _esc_controller
uavcan::MethodBinder< UavcanNode *, void(UavcanNode::*)(const uavcan::ServiceCallResult< uavcan::protocol::RestartNode > &)> RestartNodeCallback
void mixerChanged() override
called whenever the mixer gets updated/reset
static constexpr int MAX_ACTUATORS
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
pthread_mutex_t & _node_mutex
Abstract class for any character device.
UavcanEscController _esc_controller
Drive scheduling based on subscribed actuator controls topics (via uORB callbacks) ...
void set_setget_response(uavcan::protocol::param::GetSet::Response *resp)
void init()
Activates/configures the hardware registers.
bool updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs, unsigned num_control_groups_updated) override
Callback to update the (physical) actuator outputs in the driver.
The UavcanHardpointController class.
perf_counter_t _interval_perf
uavcan::MethodBinder< UavcanNode *, void(UavcanNode::*)(const uavcan::ServiceCallResult< uavcan::protocol::param::ExecuteOpcode > &)> ExecuteOpcodeCallback
Base class for an output module.
static void update_params(ParameterHandles ¶m_handles, Parameters ¶ms, bool &got_changes)
List< IUavcanSensorBridge * > _sensor_bridges
List of active sensor bridges.
static UavcanNode * _instance
singleton pointer
px4_sem_t _server_command_sem
uavcan::NodeStatusMonitor _node_status_monitor
void free_setget_response(void)
static UavcanNode * instance()
struct @83::@85::@87 file
uavcan::GlobalTimeSyncSlave _time_sync_slave
UavcanMixingInterface(pthread_mutex_t &node_mutex, UavcanEscController &esc_controller)
uavcan::MethodBinder< UavcanNode *, void(UavcanNode::*)(const uavcan::TimerEvent &)> TimerCallback
Defines basic functionality of UAVCAN node.
uavcan::GlobalTimeSyncMaster _time_sync_master
uavcan_node::Allocator _pool_allocator
This handles the mixing, arming/disarming and all subscriptions required for that.
perf_counter_t _cycle_perf
uavcan::Node & get_node()
UavcanHardpointController _hardpoint_controller
Performance measuring tools.
This interface defines one method that will be called by the main node thread periodically in order t...