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

Add takeoff/landing doc - also covers other action APIs #42

Merged
merged 4 commits into from
Oct 18, 2017
Merged

Add takeoff/landing doc - also covers other action APIs #42

merged 4 commits into from
Oct 18, 2017

Conversation

hamishwillee
Copy link
Collaborator

This adds documentation for the Action API.

  • It is named "Takeoff and Landing" as those are the main APIs, and I don't think that "Action" will necessarily be recognised by readers.
  • It refers to both sync and async APIs but only shows sync examples. IMO that makes sense as a) sync usage is much easier to understand b) will most often be used.
  • I don't show examples in every case, because the APIs are consistent. So I say something like "Used in the normal way"

The code fragment below performs the same task, but additionally exits the app if calibration is required reports what conditions are still required before the vehicle is "healthy":

```cpp
// Exit if calibration is required
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this part of the code because I can't get SITL to fail the calibration.

}
```

The code fragment below performs the same task, but additionally exits the app if calibration is required reports what conditions are still required before the vehicle is "healthy":
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianoes IMO This approach is much better than the default because it exits early in the case where vehicle cannot recover (requires calibration). Should we use this in examples? Pro is "more real world", con is "not as easy to read when getting started".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit verbose but certainly makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. I'd welcome your proposal for a more concise approach, but this will do for now.

}
```

> **Note** Vehicle health can also be checked using [Telemetry:health_all_ok_async()](../api_reference/classdronecore_1_1_telemetry.md#classdronecore_1_1_telemetry_1a83b384cd04b2ed17db805cfad8bafab5).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note again, not showing async usage, just pointing to API.

}
```

Use [Telemetry::armed()](../api_reference/classdronecore_1_1_telemetry.md#classdronecore_1_1_telemetry_1a0ca7da7922c22509ce6d55d4ad19bcf7) to check that the vehicle has armed before calling the takeoff command.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I just had a timer here. Then I tried using FlightMode::Ready - but during startup my SITL showed FlightMode::Hold, so decided just checking armed is more robust.

@julianoes - use this in example code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary. If you do arm() and the command is accepted, it should always be armed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianoes OK, I will remove armed-state checking code.

Should we update example code to include the calibration checks? I'd argue yes, because it is best practice. What about also adding the more verbose status info - should that also be added to example code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be nice.


> **Note** One alternative is to simply wait for enough time that the vehicle *should* have reached the takeoff altitude.

The code below checks for takeoff completion by polling the current altitude until the target altitude is reached:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianoes When PX4 moves to HOLD after takeoff we can revisit this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly.


## Return/RTL

[Return mode](https://docs.px4.io/en/flight_modes/rtl.html) (also known as "Return to Launch", "Return to Land", "Return to Home") flies the vehicle back to the home position and may also land the vehicle (depending on vehicle configuration). This mode is invoked from DroneCore using the [return_to_launch()](../api_reference/classdronecore_1_1_action.md#classdronecore_1_1_action_1a9af73101ce850e37cf7259dcdeda2eb9) or [return_to_launch_async()](../api_reference/classdronecore_1_1_action.md#classdronecore_1_1_action_1aa1253c356c7628d329dfa98d78eb39ee) methods.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a big discussion on return modes going on now. For this purpose lets just ignore that :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there? ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. There are a couple more possible modes and variations on modes in the works - rally points (return to a safe point) and follow original path back to safety.

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, thanks.

}
```

The code fragment below performs the same task, but additionally exits the app if calibration is required reports what conditions are still required before the vehicle is "healthy":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit verbose but certainly makes sense.

std::cout << ERROR_CONSOLE_TEXT << " - Local position estimate." << NORMAL_CONSOLE_TEXT << std::endl;
}
if (!current_health.home_position_ok) {
std::cout << ERROR_CONSOLE_TEXT << " - Home position to be set." << NORMAL_CONSOLE_TEXT << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice.

}
```

Use [Telemetry::armed()](../api_reference/classdronecore_1_1_telemetry.md#classdronecore_1_1_telemetry_1a0ca7da7922c22509ce6d55d4ad19bcf7) to check that the vehicle has armed before calling the takeoff command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary. If you do arm() and the command is accepted, it should always be armed.


> **Note** One alternative is to simply wait for enough time that the vehicle *should* have reached the takeoff altitude.

The code below checks for takeoff completion by polling the current altitude until the target altitude is reached:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly.


## Return/RTL

[Return mode](https://docs.px4.io/en/flight_modes/rtl.html) (also known as "Return to Launch", "Return to Land", "Return to Home") flies the vehicle back to the home position and may also land the vehicle (depending on vehicle configuration). This mode is invoked from DroneCore using the [return_to_launch()](../api_reference/classdronecore_1_1_action.md#classdronecore_1_1_action_1a9af73101ce850e37cf7259dcdeda2eb9) or [return_to_launch_async()](../api_reference/classdronecore_1_1_action.md#classdronecore_1_1_action_1aa1253c356c7628d329dfa98d78eb39ee) methods.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there? ok

* Integration tests:
* [simple_hover.cpp](https://github.com/dronecore/DroneCore/blob/master/integration_tests/simple_hover.cpp)
* [async_hover.cpp](https://github.com/dronecore/DroneCore/blob/master/integration_tests/async_hover.cpp)
* [takeoff_and_kill.cpp](https://github.com/dronecore/DroneCore/blob/master/integration_tests/takeoff_and_kill.cpp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@hamishwillee hamishwillee merged commit 3401447 into mavlink:master Oct 18, 2017
@hamishwillee hamishwillee deleted the takeoff_landing branch October 18, 2017 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants