src: drivers: uavcan: allow to set the fuel type through a parameter

This commit is contained in:
Nuno Marques
2024-06-17 12:58:46 -07:00
parent 4067ff0a59
commit cec0d7c66b
3 changed files with 25 additions and 2 deletions
@@ -39,7 +39,6 @@
#include "fuel_tank_status.hpp"
#include <parameters/param.h>
#include <uORB/topics/fuel_tank_status.h>
const char *const UavcanFuelTankStatusBridge::NAME = "fuel_tank_status";
@@ -72,8 +71,11 @@ void UavcanFuelTankStatusBridge::fuel_tank_status_sub_cb(const
_max_fuel_capacity *= 1000.0f; // convert to ml
report.maximum_fuel_capacity = _max_fuel_capacity;
report.fuel_type = fuel_tank_status_s::MAV_FUEL_TYPE_LIQUID;
// Fetching fuel type
param_get(param_find("UAVCAN_ECU_FUELT"), &_fuel_type);
report.fuel_type = static_cast<uint8_t>(_fuel_type);
report.consumed_fuel = NAN; // only the remaining fuel is measured
report.fuel_consumption_rate = msg.fuel_consumption_rate_cm3pm / 60.0f; // convert to ml/s
report.percent_remaining = msg.available_fuel_volume_percent;
@@ -42,6 +42,8 @@
#include "sensor_bridge.hpp"
#include <uavcan/equipment/ice/FuelTankStatus.hpp>
#include <uORB/topics/fuel_tank_status.h>
class UavcanFuelTankStatusBridge : public UavcanSensorBridgeBase
{
public:
@@ -67,4 +69,5 @@ private:
uavcan::Subscriber<uavcan::equipment::ice::FuelTankStatus, FuelTankStatusCbBinder> _sub_fuel_tank_status_data;
float _max_fuel_capacity{0.0f};
int32_t _fuel_type{fuel_tank_status_s::MAV_FUEL_TYPE_UNKNOWN};
};
+18
View File
@@ -111,6 +111,24 @@ PARAM_DEFINE_FLOAT(UAVCAN_RNG_MAX, 200.0f);
*/
PARAM_DEFINE_FLOAT(UAVCAN_ECU_MAXF, 15.0f);
/**
* UAVCAN fuel tank fuel type
*
* This parameter defines the type of fuel used in the vehicle's fuel tank.
*
* 0: Unknown
* 1: Liquid (e.g., gasoline, diesel)
* 2: Gas (e.g., hydrogen, methane, propane)
*
* @min 0
* @max 2
* @value 0 Unknown
* @value 1 Liquid
* @value 2 Gas
* @group UAVCAN
*/
PARAM_DEFINE_INT32(UAVCAN_ECU_FUELT, 1);
/**
* UAVCAN ANTI_COLLISION light operating mode
*