Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rover interface: allow configurable maximum mission speed #501

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ROMFS/px4fmu_common/init.d/airframes/50006_ssrc_bunker_rover
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions src/drivers/rover_interface/RoverInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<uint8_t>(rover_type),
can_bitrate,
manual_throttle_max);
manual_throttle_max,
mission_throttle_max
);
}

/* commands below assume that the app has been already started */
Expand Down
6 changes: 4 additions & 2 deletions src/drivers/rover_interface/RoverInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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};
Expand Down
12 changes: 12 additions & 0 deletions src/drivers/rover_interface/rover_interface_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);