Hold/release autonomous abilities ¶
In this tutorial, we will see how to toggle Pepper’s autonomous abilities.
For further details on autonomous abilities, see: Autonomous Abilities.
Before stepping in this tutorial, you should be familiar with
the notion of
You can refer to Chaining operations if you need.
Let’s start a new project
- Start a new project, let’s call it AutonomousPepper.
- Robotify it and make sure it implements the QiSDK & the Robot Life Cycle.
For further details, see: Creating a robot application.
MainActivity class, create a new
To hold the abilities, we first build a
We pass the autonomous abilities we want to hold to the builder, by using the
Next, we can call the
hold methods on the holder to hold the
Now that we know how to disable autonomous abilities, we will see how to re-enable them.
In this section, we will see how to release autonomous abilities.
Create a new
To release autonomous abilities asynchronously, call the
release methods on the corresponding
Next, we will implement an example to test the hold and release functionalities.
Let’s test our code using a button_switch_autonomous.
The following code is just a quick way to test the functionality, this is not what you would do in a real application.
In the activity_main.xml layout file, add the following
<Button android:id="@+id/button_switch_autonomous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Hold"/>
Create these fields in the
Put the following code for the
Set the button_switch_autonomous onClick listener in the
Now, update the
holdAbilities method with the following
releaseFuture in the
releaseAbilities method with a lambda on the UI thread:
We have to execute the lambdas on the UI thread because we update the button_switch_autonomous properties in them.
Let’s try it¶
The sources for this tutorial are available on GitHub.
Install and run the application.
For further details, see: Running an application.
Choose “Hold/release autonomous abilities”.
Notice that the robot moves slightly, blinks, and tracks your movements.
|Click on the button_switch_autonomous and the robot will stop these behaviours after a short time.|
Click again on the button_switch_autonomous and the robot will reactivate his abilities.
We can now toggle abilities!
That’s it, you know how to hold and release autonomous abilities.