-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Hello!
Thank you for this great work. My goal is to use this library together with VIO for position estimation in order to fly my drone in GNSS-denied areas. To achieve this, I followed the px4 guide on enable auto mode with local position, which suggests sending the VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN command. In addition, VEHICLE_CMD_DO_SET_HOME can be used to set the home position once the global position estimate is available.
I am now trying to figure out how to send these two VehicleCommands correctly using this library. So far, I have attempted to send the commands via sendCommandSync in my mode executor ModeExecutorTest, which inherits from ModeExecutorBase. The functions I written for sending the command looks like this:
void ModeExecutorTest::setHome(const CompletedCallback &on_completed)
{
if (is_home_set_)
{
on_completed(Result::Success);
return;
}
// TODO: check if global position is available before sending the command?
const Result result = sendCommandSync(
px4_msgs::msg::VehicleCommand::VEHICLE_CMD_DO_SET_HOME,
1.f);
// TODO: maybe subscribe HomePosition.msg to check if home position is availible?
if (result != Result::Success)
{
on_completed(result);
return;
}
}
void ModeExecutorTest::setGlobalOrigin(const CompletedCallback &on_completed)
{
if (is_origin_set_)
{
on_completed(Result::Success);
return;
}
// VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN does not send back a VehicleCommandAck.
sendCommandSync(
px4_msgs::msg::VehicleCommand::VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN,
NAN, NAN, NAN, NAN,
0.0, 0.0, 0.0);
}VEHICLE_CMD_DO_SET_HOME sends back a VehicleCommandAck, whereas VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN does not.
I plan to use these commands in runState. Two follow up questions occur:
- How can I check, inside the mode executor, when the global position estimate becomes available, before setting the home position?
- How can I subscribe to
HomePosition.msgto detect when the home position becomes available, and then seton_completedtoResult::Successusing this library?