This document assumes basic Java programming competence. Look to the javadocs for the Robokind Basic API for more information and a complete list of classes and methods. The following details how to get started using the API for the first time and covers version requirements, creating a Maven project, and sending commands to a robot or avatar. A demo project demonstraiting the use of basic API can be found here.
The RoboKind Basic API uses the Maven build tool and Java 6. You can download a package containing Netbeans with the Maven plugin and JDK 6 directly from Oracle. An excerpt from the documentation detailing this follows.
It is recommended that you either uninstall Java 7 and any other more recent version of Java before installing this bundle or that you reset you default to point to Java 6 instead.
To create a new project, start by clicking on the 'File' menu and selecting 'New Project' (Ctrl+Shift+N)
Select 'Maven' in 'Categories' and 'Java Application' in 'Projects' then select 'Next'
Fill in the Name and Location as you normally would (note there and suggestions in the Maven Standard though) and select 'Ok'
A Maven project will automatically contain a pom.xml in the 'Project Files'. This file is an XML representation of the project. It contains all the necessary information about the project and the configurations of the plugins. Include your dependencies here. With all the necessary dependencies in the pom.xml, you will never have to manually add 'imports'. After making your 'main' class, press Ctrl+Shift+I to add all needed imports.
More information on the POM can be found in the Apache Maven "POM Reference"
The following two dependencies are necessary for any robokind project so the following code snippets should be in the pom.xml for every RoboKind Basic project.
<dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.basic</artifactId> <version>${robokind.version}</version> </dependency> <dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.impl.messaging</artifactId> <version>${robokind.version}</version> </dependency>
The 'basic' dependency is needed to use the API and 'messaging' is used to communicate with the robot or avatar.
Documentation on all the the dependencies can be find in the java docs.
Include the following dependencies in the pom.xml as needed.
Motion
Getting positions from and sending new goal positions to servos:
<dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.impl.motion</artifactId> <version>${robokind.version}</version> </dependency>
Animation
Loading and playing animations:
<dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.impl.animation</artifactId> <version>${robokind.version}</version> </dependency>
Speech
Sending speech commands to the robot:
<dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.impl.speech</artifactId> <version>${robokind.version}</version> </dependency>
<dependency> <groupId>org.robokind</groupId> <artifactId>org.robokind.avrogen.sensor</artifactId> <version>${robokind.version}</version> </dependency>
public static org.robokind.api.motion.messaging.RemoteRobot connectRobot()
public static void setRobotAddress(String address)
There are four main commands you might send to the robot. You can load and play animations, have the robot/avatar move joints individually, and have it speak. Each has its own dependency that should be included in the POM in order to use it. See the following examples or the example project for implementation.
//Create animPlayer and load animation RemoteAnimationPlayerClient animPlayer = Robokind.connectAnimationPlayer(); Animation introAnim = Robokind.loadAnimation("intro.anim.xml"); //Create introJob, tell it to play introAnim with animPlayer, get the length of the animation and tell the thread to wait for that length of time plus 500 milliseconds (so the next command is issued AFTER the animation finishes playing.) AnimationJob introJob = animPlayer.playAnimation(introAnim); Robokind.sleep(500 + introJob.getAnimationLength());
RemoteRobot robot = Robokind.connectRobot(); JointId waist = new JointId(robot.getRobotId(), new Joint.Id(RobotJoints.WAIST)); JointId leg = new JointId robot.getRobotId(), new Joint.Id(RobotJoints.RIGHT_HIP_YAW)); RobotPositionMap goalPositions = new RobotPositionHashMap(); goalPositions.put(waist, new NormalizedDouble(1.0)); goalPositions.put(leg, new NormalizedDouble(0.5)); //Moves the joints to the specified goal positions over 1000 milliseconds robot.move(goalPositions, 1000);
RemoteSpeechServiceClient speechService = Robokind.connectSpeechService(); SpeechJob speechJob = speechService.speak("Hello, my name is ZENO.");