diff --git a/ROMFS/px4fmu_common/init.d/airframes/50005_ssrc_scout_mini_rover b/ROMFS/px4fmu_common/init.d/airframes/50005_ssrc_scout_mini_rover index 9c28f7b0b233..f3894e439fd3 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/50005_ssrc_scout_mini_rover +++ b/ROMFS/px4fmu_common/init.d/airframes/50005_ssrc_scout_mini_rover @@ -13,8 +13,10 @@ . ${R}etc/init.d/rc.rover_defaults +# Rover interface param set-default RI_ROVER_TYPE 0 -param set-default RI_MAN_THR_MAX 3.0 +param set-default RI_MAN_THR_MAX 1.0 +param set-default RI_MIS_THR_MAX 1.0 # Battery setting param set-default BAT1_N_CELLS 7 diff --git a/ROMFS/px4fmu_common/init.d/airframes/50006_ssrc_bunker_rover b/ROMFS/px4fmu_common/init.d/airframes/50006_ssrc_bunker_rover index 180e6378adb4..c1fe66c5143d 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/50006_ssrc_bunker_rover +++ b/ROMFS/px4fmu_common/init.d/airframes/50006_ssrc_bunker_rover @@ -13,8 +13,10 @@ . ${R}etc/init.d/rc.rover_defaults +# Rover interface param set-default RI_ROVER_TYPE 5 param set-default RI_MAN_THR_MAX 1.5 +param set-default RI_MIS_THR_MAX 1.0 # Battery setting param set-default BAT1_N_CELLS 14 diff --git a/src/drivers/rover_interface/RoverInterface.cpp b/src/drivers/rover_interface/RoverInterface.cpp index 0e85984e8a1d..171e9b5c1307 100644 --- a/src/drivers/rover_interface/RoverInterface.cpp +++ b/src/drivers/rover_interface/RoverInterface.cpp @@ -6,12 +6,14 @@ RoverInterface *RoverInterface::_instance; // CAN interface | default is can0 const char *const RoverInterface::CAN_IFACE = "can0"; -RoverInterface::RoverInterface(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max) +RoverInterface::RoverInterface(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max, + float mission_throttle_max) : ModuleParams(nullptr), ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::rover_interface), _rover_type(rover_type), _bitrate(bitrate), - _manual_throttle_max(manual_throttle_max) + _manual_throttle_max(manual_throttle_max), + _mission_throttle_max(mission_throttle_max) { pthread_mutex_init(&_node_mutex, nullptr); } @@ -43,14 +45,14 @@ RoverInterface::~RoverInterface() } -int RoverInterface::start(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max) +int RoverInterface::start(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max, float mission_throttle_max) { if (_instance != nullptr) { PX4_ERR("Already started"); return -1; } - _instance = new RoverInterface(rover_type, bitrate, manual_throttle_max); + _instance = new RoverInterface(rover_type, bitrate, manual_throttle_max, mission_throttle_max); if (_instance == nullptr) { PX4_ERR("Failed to allocate RoverInterface object"); @@ -223,7 +225,7 @@ void RoverInterface::ActuatorControlsUpdate() actuator_controls_s actuator_controls_msg; if (_actuator_controls_sub.copy(&actuator_controls_msg)) { - auto throttle = (_is_manual_mode ? _manual_throttle_max : 1.0f) * + auto throttle = (_is_manual_mode ? _manual_throttle_max : _mission_throttle_max) * actuator_controls_msg.control[actuator_controls_s::INDEX_THROTTLE]; auto steering = actuator_controls_msg.control[actuator_controls_s::INDEX_YAW]; _scout->SetMotionCommand(throttle, steering); @@ -384,12 +386,18 @@ extern "C" __EXPORT int rover_interface_main(int argc, char *argv[]) float manual_throttle_max = 1.0; param_get(param_find("RI_MAN_THR_MAX"), &manual_throttle_max); + // Mission control mode max throttle (1m/s to 3m/s) + float mission_throttle_max = 1.0; + param_get(param_find("RI_MIS_THR_MAX"), &mission_throttle_max); + // Start PX4_INFO("Start Rover Interface to rover type %d at CAN iface %s with bitrate %d bit/s", rover_type, RoverInterface::CAN_IFACE, can_bitrate); return RoverInterface::start(static_cast(rover_type), can_bitrate, - manual_throttle_max); + manual_throttle_max, + mission_throttle_max + ); } /* commands below assume that the app has been already started */ diff --git a/src/drivers/rover_interface/RoverInterface.hpp b/src/drivers/rover_interface/RoverInterface.hpp index 34d383c12761..3fa28989627e 100644 --- a/src/drivers/rover_interface/RoverInterface.hpp +++ b/src/drivers/rover_interface/RoverInterface.hpp @@ -38,10 +38,10 @@ class RoverInterface : public ModuleParams, public px4::ScheduledWorkItem public: static const char *const CAN_IFACE; - RoverInterface(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max); + RoverInterface(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max, float mission_throttle_max); ~RoverInterface() override; - static int start(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max); + static int start(uint8_t rover_type, uint32_t bitrate, float manual_throttle_max, float mission_throttle_max); void print_status(); @@ -80,6 +80,8 @@ class RoverInterface : public ModuleParams, public px4::ScheduledWorkItem float _manual_throttle_max; + float _mission_throttle_max; + scoutsdk::ProtocolVersion _protocol_version{scoutsdk::ProtocolVersion::AGX_V2}; const char *_can_iface{nullptr}; diff --git a/src/drivers/rover_interface/rover_interface_params.c b/src/drivers/rover_interface/rover_interface_params.c index 9c88429f8e2e..b17b1fa8504f 100644 --- a/src/drivers/rover_interface/rover_interface_params.c +++ b/src/drivers/rover_interface/rover_interface_params.c @@ -68,3 +68,15 @@ PARAM_DEFINE_INT32(RI_CAN_BITRATE, 500000); * @group Rover Interface */ PARAM_DEFINE_FLOAT(RI_MAN_THR_MAX, 1.0); + + +/** + * Rover interface mission control throttle max. + * + * @unit m/s + * @min 1.0 + * @max 3.0 + * @reboot_required true + * @group Rover Interface + */ +PARAM_DEFINE_FLOAT(RI_MIS_THR_MAX, 1.0);