Supported WebAPI calls
Ohmni.move()
Ohmni.setLightColor()
Ohmni.setNeckPosition()
Ohmni.setNeckTorqueEnabled()
Ohmni.showPageOnBot("url") (version >= 4.0.2)
Ohmni.hidePageOnBot() (version >= 4.0.2)
Ohmni.requestBotInfo() (version >= 4.0.8.2)
Ohmni.captureVideo(resolutionWidth, resolutionHeight)
Ohmni.captureAudio()
Ohmni.stopCaptureAudio()
Ohmni.setBotVolume(Number);
Ohmni.getBotVolume();
Ohmni.on('cdata', callback);
Ohmni.move(lspeed, rspeed, time)
Sets the speed of the left and right wheels of the robot for a specified time in milliseconds.
This gives you low level access to the motion of the base. Wheel speeds are most commonly in the -2000 to 2000 range, but start with slower speeds in the -500 to 500 range when you are testing. If the speed is positive, the wheel will rotate counterclockwise. On the other hand, the wheel will rotate clockwise, if the speed is set negatively.
The time variable is capped at 10000ms (10 seconds). This bounds is for safety, making each command implicitly only last for up to 10 seconds. This prevents developers from accidentally having the robot drive off by writing a single command.
If you want continuous motion for longer than 10 seconds, you can call this function again while the previous movement is still running.
Examples:
Ohmni.move(-500, 500, 2000); // Go backwards for 2 seconds
Ohmni.move(700, -700, 1500); // Go forwards for 1.5 seconds
Ohmni.move(-200, -200, 5000); // Rotate in place for 5 seconds
Ohmni.setNeckTorqueEnabled(en)
Turns on or off neck torque.
This either lets the neck be moved by hand (torque off) or turns on the neck and lets it hold position and be driven by the Ohmni.setNeckPosition call.
CAUTION: DO NOT TRY AND MOVE THE NECK BY HAND WHEN TORQUE IS ON! This can permanently damage the neck servo. When the neck is not in use, it is good practice to turn off torque.
Examples:
Ohmni.setNeckTorqueEnabled(1);
Ohmni.setNeckPosition(650, 100);
Ohmni.setNeckPosition(pos, ival)
Sets the position of the neck servo.
Provide a position in the range of 300 (looking down 90 degrees) to 650 (looking up about 45 degrees). 512 looks straight forwards.
The ival parameter instructs how long the move should last, i.e. larger values mean the neck will move more slowly to the desired position. Typical values are in the range of 80 (fast motion) to 220 (slow motion).
Examples:
Ohmni.setNeckTorqueEnabled(1);
Ohmni.setNeckPosition(350, 220);
Ohmni.setLightColor(h, s, v)
Sets the color of the underbody lighting in HSV space.
Call this to set the color of the LEDs beneath the robot. HSV values are all 0-255.
Example:
Ohmni.setLightColor(30,230,100);
Ohmni.setSpeechLanguage(locale_string)
Set the text to speech language of the robot.
Provide a locale string to set the text to speech language. Some examples: "en-US" for English and "zh-TW" for Traditional Chinese.
Call this before calling Ohmni.say with the appropriate string. You can switch between different languages at runtime.
Example:
Ohmni.setSpeechLanguage("zh-TW");
Ohmni.say("你好");
Ohmni.setSpeechLanguage("en-US");
Ohmni.say("Good morning!");
Ohmni.say(string_to_speak, [optional] callback)
Speaks a string using the current language settings. Triggers a callback when complete to make scripting easier.
This speaks the given string. Use UTF-8 encoded characters for Chinese or other languages. The callback is triggered when speaking is complete, so you can trigger other events (UI changes, robot motion or lights, etc.) on the callback.
Example:
Ohmni.say("Good morning!", function() {
Ohmni.setLightColor(30, 230, 100);
});
Ohmni.requestBotInfo()
Return metadata for current robot
Ohmni.captureVideo(resolutionWidth, resolutionHeight)
The function will retrieve current image in the Video Call and pass data (images: base64) into callback function captureVideoCb
Examples:
# Define function like below to get 30 frames/second.
function captureVideo() {
intervalGetVideo = setInterval(function() {
# If you want to change the resolution response can put the parameters
# into Ohmni.captureVideo(resolutionWidth, resolutionHeight)
# Current resolution default is 300 x 150
Ohmni.captureVideo();
}, 33);
}
# Callback function after Ohmni.captureVideo retrieved the image in current call
function captureVideoCb(imageBase64) {
}
Ohmni.captureAudio()
The function will retrieve current audioStream comes from the bot then pass data (ArrayInt) into callback function captureAudioCb
Examples:
# Run this line below to start get audio stream from the bot.
Ohmni.captureAudio();
# Define callback function captureAudioCb(data) to use data which type is Uint8Array(4096)
# get from the audio stream
# Define global variable like below to push data into and use this data to write audio file
# We will use recordAudio[0] to set header of audio stream data later
var recordAudio = [''];
function captureAudioCb(data) {
if (data.length < 4096) {
// Set header of audio file
recordAudio[0] = data;
} else {
recordAudio.push(data);
}
}
# When stop or during the call if you want to write the audio stream into file by using code
# below to generate url audio file with format blob:https://api.ohmnilabs.com/xxx-xxx-xxxx
# Can download or playback on the link
const blob = new Blob(recordAudio, { type: 'audio/wav' });
const url = URL.createObjectURL(blob);
Ohmni.stopCaptureAudio()
The function will stop retrieve current audioStream comes from the bot after you did call Ohmni.captureAudio()
Ohmni.setBotVolume(value)
The function will set bot volume with range of value (0-11)
Ohmni.getBotVolume()
The function will retrieve current bot volume then pass data (number) into callback function getBotVolumeCb.
Examples:
# Define callback function that will be called automatically after
# Ohmni.getBotVolume retrieves the current bot volume.
function getBotVolumeCb(value) {
}
Ohmni.on('cdata', callback)
Receive json data sent from the bot through the botshell api.
Examples:
Ohmni.on('cdata', data => {
// your custom code here
});
NOTE: In order to send json data to incall/standalone overlay, please look at the botshell APIs send_to_in_call_api/send_to_stand_alone_api in the OhmniAPI
Ohmni.bindSpeechHandler(string_to_match, callback_id)
(currently disabled) This binds a particular string to be matched and triggers it.
Comments
0 comments
Article is closed for comments.