Dance service
The dance service provides the ability to make the API call the device to dance. As the dance service access agent, OrchestrationManager provides the main API of the dance service, which can be obtained through RobotContext.
OrchestrationManager orchestrationManager = aRobotContext.getSystemService(OrchestrationManager.SERVICE);
dance
When you need the device to dance like a human, you can achieve it with the following code:
promise /* [2] */ = orchestrationManager.play( Uri.parse("orchestration://id/Naxi") /* [1] */) .progress(new ProgressCallback<PlayProgress>() { @Override public void onProgress(PlayProgress playProgress /* [3] */) { // Callback the dance process } }) .done(new DoneCallback<Void>() { @Override public void onDone(Void aVoid) { // Callback the dance completed } }) .fail(new FailCallback<PlayException>() { @Override public void onFail(PlayException e) { // Callback the dance goes wrong } });
[1]The unique identification of the dance, see the appendix for details.
[2]Return the asynchronous object that is waiting for the progress and result of the dance, through which you can wait for or monitor the progress and results, and cancel the dance. See Promise for specific usage.
[3] The PlayProgress object of the asynchronous callback describes the progress information of the dance, including:
| Attribute getter | Descriptions |
|---|---|
| PlayProgress.progress | Progress information began: dance started ended: dance ended playing: dancing |
By specifying options, the dancing action can be adjusted using the following code:
PlayOption /* [1] */ playOption = new PlayOption.Builder( new Orchestration.Builder().build() /* [2] */).setOffsetTime(5000).build(); promise = orchestrationManager.play(playOption);
[1] The PlayOption object is constructed through PlayOption.Builder, and the instructions are as follows:
| Methods | Descriptions | Default value |
|---|---|---|
| Builder.constructor(orchestration) | During construction, the arranged object Orchestration need to be introduced. | |
| Builder.setOffsetTime(5000) | The length of time the dance has lasted, unit: millisecond | 0 |
[2] The Orchestration object is built using Orchestration.Builder. The instructions are as follows:
| Methods | Descriptions | Default value |
|---|---|---|
| Builder.constructor() | ||
| Builder.addTrack(track) | Add tracks, to create an object, see Track | |
| Builder.addTrackList(tracks) | Add track collection | |
| Builder.setMainTrackIndex(0) | Specify the main track | 0 |
The Track object is built using Track.Builder. The instructions are as follows:
| Methods | Descriptions | Default value |
|---|---|---|
| Builder.constructor(type, segment) | When constructing, specify the track type and fragment. Currently, the track types supported are "motion", "locomotion", "audio", and "emotion". | |
| Builder.setRootSegment(rootSegment) | Specify the segment, to create an object, see Segment | |
| Builder.setDescription(description) | Description | Zero-length string |
The Segment object is built using Segment.Builder. The instructions are as follows:
| Methods | Descriptions | Default value |
|---|---|---|
| Builder.constructor() | ||
| Builder.setName(name) | Name of the segment | Zero-length string |
| Builder.setDescription(description) | Description of the segment | Zero-length string |
| Builder.setLoops(loops) | Number of loops, 0: unlimited |
0 |
| Builder.setDuration(duration) | Total execution time: unit: millisecond | 0 |
| Builder.setDurationLoopOnce(durationLoopOnce) | Time required for one execution, unit: millisecond | 0 |
| Builder.setBlank(blank) | wait, true: wait |
false |
| Builder.setOption(option) | Genericity, set the information unique to each track. For details of "motion", please see PerformingOption. For details of "locomotion", please seeLocomotionOption. For details of " emotion", please seeExpressingOption |
If you want to build a collection of fragments, you can use the SegmentGroup object, which inherits Segment and is built through SegmentGroup.Builder. The instructions are as follows:
| Methods | Descriptions | Default value |
|---|---|---|
| Builder.constructor() | ||
| Builder.addChildren(childrenSegment) | Add a segment | |
| Builder.addChildren(childSegmentGroup) | Add multiple segments | |
| Builder.addChildFirst(childrenSegment) | Add a segment to the beginning | |
| Builder.removeChild(childSegment) | Remove a segment |
Dance list
| Dance name | English name | ID |
|---|---|---|
| seaweed | Seaweed | Seaweed |
| Dura | Dura | Dura |
| Faded | Faded | Faded |
| Panama | Panama | Panama |
| Curry | Curry | Curry |
| Ievan Polkka | IevanPolkka | IevanPolkka |
| Crayon | Crayon | Crayon |
| Toca Toca | TocaToca | TocaToca |
| Modern dance | Rock | ModernDance |
| Flamenco | Spain | Flamenco |
| Boom Boom | BoomBoom | BBoomBBoom |
| Naxi | Naxi | Naxi |
Appendix
public static final Uri NAXI = Uri.parse("orchestration://id/Naxi"); public static final Uri BBOOM_BBOOM = Uri.parse("orchestration://id/BBoomBBoom"); public static final Uri FLAMENCO = Uri.parse("orchestration://id/Flamenco"); public static final Uri MODERN = Uri.parse("orchestration://id/Modern Dance"); public static final Uri TOCA_TOCA = Uri.parse("orchestration://id/TocaToca"); public static final Uri CRAYON = Uri.parse("orchestration://id/Crayon"); public static final Uri SEAWEED = Uri.parse("orchestration://id/Seaweed"); public static final Uri CURRY = Uri.parse("orchestration://id/Curry"); public static final Uri IEVAN_POLKKA = Uri.parse("orchestration://id/IevanPolkka"); public static final Uri PANAMA = Uri.parse("orchestration://id/Panama"); public static final Uri FADED = Uri.parse("orchestration://id/Faded"); public static final Uri DURA = Uri.parse("orchestration://id/Dura");