Introduction
In this tutorial, you can learn the basics of how to communicate with the Furhat system by using the Furhat Proxy, a simple Java client.
Note: Under the hood, the Furhat proxy is connecting to the Furhat using the TCP broker. Advanced users might also be interested in the tutorial on broker using C#.
Note: this tutorial assumes that you:
- Have a Furhat robot (or a device with Furhat SDK running) with a known IP-address.
- Have Java development kit (version >1.8) installed.
Downloading and importing the JAR
- Download the JAR here.
- In your Java project, import the JAR.
Use the Proxy API methods
Create a furhat proxy using FurhatProxy furhat = new FurhatProxy(IP_ADDRESS)
and then use the methods like furhat.say("hello there")
. See all available methods below:
Command | Parameters | Description |
---|---|---|
say | String text | Makes Furhat speak the input text |
gesture | String name | Makes Furhat do the specific gesture |
gestureFromXML | String xml | Makes Furhat do the gesture as defined by the XML input |
gaze | double x, double y, double z | Makes Furhat gaze at the coordinates |
gaze | double x, double y, double z, int slack | Makes Furhat gaze at the coordinates and modifies the slack (the amount of movement in degrees that Furhat does without moving the head. Default is 60) |
gaze | double x, double y, double z, String mode { "eyes", "head" } | Makes Furhat gaze with either only eyes or only head. |
faceParam | String name, Double Value | Set a face parameter |
Send custom events
In addition to the above methods, you can also send any custom event by:
1. Defining an event with Event event = new Event("my.event")
2. Add any key-value pair with event.put("key", "value")
3. Using the furhat.send(event)
method.
See all system events available here.
Full example using the proxy
try {
// Connect to the proxy, in this case to localhost
FurhatProxy furhat = new FurhatProxy("127.0.0.1");
// Methods available through API
furhat.say("Hi, I am a speaking robot");
furhat.gaze(1, 0, 1);
furhat.gesture("smile");
// Send a custom event
Event event = new Event("my.custom.event");
event.put("key", "value");
furhat.send(event);
} catch (Exception e) {
e.printStackTrace();
}