Next version 'Nixie' is coming soon !

Help us to get ready with MyRobotLab version Nixie: try it !
Javadoc link
Example code (from branch develop):
#########################################
# ImageDisplay.py
# description: used as a general template
# more info @: http:#myrobotlab.org/service/ImageDisplay
#########################################
from time import sleep
import math
 
# Runtime.setConfig("default")
 
# start a image display service
display = runtime.start("display", "ImageDisplay")
 
# =========== Default Values ==================
# setting these are setting default values
# so that any new display is created they will
# have the following properties automatically set accordingly
#
 
# the display will always be on top
# display.setAlwaysOnTop(true)
 
# when a picture is told to go fullscreen
# and is not the same ratio as the screen dimensions
# this tells whether to scale and extend to the min
# or max extension
# display.setAutoscaleExtendsMax(true)
 
# if there is a background while fullscreen - set the color rgb
# display.setColor("#000000")
 
# if true will resize image (depending on setAutoscaleExtendsMax)
# display.setFullScreen(false)
 
# set which screen device to be displayed on
# display.setScreen(0)
 
# set the default location for images to display
# null values will mean image will be positioned in the center of the screen
# display.setLocation(null, null)
 
# set the default dimensions for images to display
# null values will be the dimensions of the original image
# display.setDimension(null, null)
 
# most basic display - an image file, can be relative or absolute file path
# displays are named - if you don't name them - they're name will be "default"
# this creates a display named default and display a snake.jpg
display.display("snake.jpg")
sleep(1)
 
# this creates a new display called "beetle" and loads it with beetle.jpg
# "default" display is still snake.jpg
display.display("beetle", "beetle.jpg")
sleep(1)
 
# the image display service can also display images from the web
# just supply the full url - they can be named as well - this one replaces the snake image
# since a name was not specified - its loaded into "default"
display.display(
    "https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/InMoov_Wheel_1.jpg/220px-InMoov_Wheel_1.jpg")
sleep(1)
 
# animated gifs can be displayed as well - this is the earth
# in fullscreen mode
display.displayFullScreen(
    "earth", "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/300px-Rotating_earth_%28large%29.gif")
sleep(1)
 
# we can resize a picture
display.resize("earth", 600, 600)
sleep(1)
 
# and re-position it
display.move("earth", 800, 800)
 
# make another picture go fullscreen
display.displayFullScreen("robot", "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/FANUC_6-axis_welding_robots.jpg/1280px-FANUC_6-axis_welding_robots.jpg")
sleep(1)
 
display.display("monkeys", "https://upload.wikimedia.org/wikipedia/commons/e/e8/Gabriel_Cornelius_von_Max%2C_1840-1915%2C_Monkeys_as_Judges_of_Art%2C_1889.jpg")
sleep(1)
 
display.displayFullScreen("robot", "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/FANUC_6-axis_welding_robots.jpg/1280px-FANUC_6-axis_welding_robots.jpg")
sleep(1)
 
display.display("inmoov", "https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/InMoov_Wheel_1.jpg/220px-InMoov_Wheel_1.jpg")
sleep(1)
 
display.display("mrl", "https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/VirtualInMoov.jpg/220px-VirtualInMoov.jpg")
sleep(1)
 
for i in range(0, 100):
    display.move("monkeys", 20 + i, 20 + i)
    sleep(0.05)
 
display.resize("monkeys", 200, 200)
sleep(1)
 
display.move("monkeys", 30, 30)
sleep(1)
 
# now we can close some of the displays
display.close("monkeys")
sleep(1)
 
display.close("robot")
sleep(1)
 
x0 = 500
y0 = 500
r = 300
x = 0
y = 0
 
# move the inmoov image in a circle on the screen
for t in range(0, int(4 * math.pi)):
    x = int(r * math.cos(t) + x0)
    y = int(r * math.sin(t) + y0)
    display.move("inmoov", x, y)
    sleep(0.1)
 
 
# in this example we will search for images and display them
# start a google search and get the images back, then display them
google = runtime.start("google", "GoogleSearch")
images = google.imageSearch("monkey")
for img in images:
    display.displayFullScreen(img)
    # display.display(img)
    sleep(1)
 
# set defaults to be fullscree and autoscale extends max for all
# new displays
display.setFullScreen(True)
display.setAutoscaleExtendsMax(True)
 
# another example we'll use wikipedia service to search
# and attach the wikipedia to the display service
# it will automagically display when an image is found
wikipedia = runtime.start("wikipedia", "Wikipedia")
wikipedia.attach(display)
# display.attach(wikipedia)
images = wikipedia.imageSearch("bear")
sleep(2)
display.setFullScreen(False)
display.setAutoscaleExtendsMax(False)
display.displayFullScreen("https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Noto_Emoji_Pie_1f4e2.svg/512px-Noto_Emoji_Pie_1f4e2.svg.png?20190227024729")
sleep(1)
 
display.display("data/Emoji/512px/U+1F47D.png")
sleep(1)
 
display.display("https://raw.githubusercontent.com/googlefonts/noto-emoji/main/png/512/emoji_u1f62c.png")
sleep(1)
display.displayFullScreen("https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Noto_Emoji_Pie_1f4e2.svg/512px-Noto_Emoji_Pie_1f4e2.svg.png?20190227024729")
sleep(1)
display.display("dino", "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Noto_Emoji_Pie_1f995.svg/512px-Noto_Emoji_Pie_1f995.svg.png?20190227143252")
sleep(1)
 
# save all displays in their current state
display.save()
 
sleep(5)
# close everything
display.closeAll()
 
# close everything and reset defaults
display.reset()
 
# 
# opencv selected image - or object identified image
 
 
# Display an image as it is. The string might be an internet source or path to an image on the computer.
display.display("asimo", "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/HONDA_ASIMO.jpg/800px-HONDA_ASIMO.jpg")
sleep(2)
# Closes all active images.
display.closeAll()
 
# Display an image scaled by a given multiplication factor.
display.displayScaled("https://upload.wikimedia.org/wikipedia/commons/thumb/c/c0/Asimo_look_new_design.jpg/800px-Asimo_look_new_design.jpg", 2)
sleep(2)
display.closeAll()
 
# Display an image faded faded by a given value between 0 and 1 and scaled by a given multiplication factor.
display.displayScaled("https://upload.wikimedia.org/wikipedia/commons/thumb/c/c0/Asimo_look_new_design.jpg/800px-Asimo_look_new_design.jpg", 0.1, 2)
sleep(2)
display.closeAll()
 
# Display an image in FullScreen Mode (Fullscreenmode can be terminated with a mouseclick.
display.displayFullScreen("https://upload.wikimedia.org/wikipedia/commons/f/fe/Escher_Cube.png")
sleep(2)
display.closeAll()
 
# Display an image in FullScreen Mode faded by a given value between 0 and 1. (Fullscreenmode can be terminated with a mouseclick.
display.displayFullScreen("https://upload.wikimedia.org/wikipedia/commons/f/fe/Escher_Cube.png", 0.1)
sleep(2)
display.closeAll()
 
# opencv example - shows how to display mutliple saved images
# with greater control in the image display service - although
# its only displaying 3 images here - they could be moved and a row
# of captured images based on classification could be reported
# start a image display service
display = runtime.start("display", "ImageDisplay")
cv = runtime.start('cv','OpenCV')
cv.capture()
sleep(5)
cv.attach(display)
sleep(4)
cv.saveImage()
sleep(1)
cv.saveImage()
sleep(1)
cv.saveImage()

ImageDisplay is usefull to open local or remote pictures, and render result to screen...

Fun example, create an ImageDisplay service and one of the Search services - attach them and ask for a picture of something. It should appear (fullscreen if you want).

You can move the image around with by holding down the left mouse button, and close it using the right mouse button.

So, sometimes an arduino running mrlcomm will get away from you.  The best way to reset it is to toggle the serial port.  This resets the arduino that's connected and thus clearing the device list in mrlcomm.

Here's a small snippet of python code that will toggle the DTR pin and reset the arduino.

pi@raspberrypi:~ $ cat reset.py

Javadoc link
Example code (from branch develop):
#########################################
# LocalSpeech.py
# description: used as a general template
# categories: speech
# more info @: http://myrobotlab.org/service/LocalSpeech
#########################################
import os
import platform
 
# start the service
mouth = runtime.start('mouth','LocalSpeech')
 
# by default LocalSpeech will select a command template appropriate for the current 
# operating system
mouth.speakBlocking("this is how I sound out of the box")
 
# possible voices ( selected voice is stored inside config until you change it )
mouth.speakBlocking("these are the voices I can have " + str(mouth.getVoices()))
mouth.speakBlocking ("this is the voice I am using " + str(mouth.getVoice()))
 
if (Runtime.getPlatform().isLinux()):
    mouth.speakBlocking('I appear to be on a Linux system')
    mouth.speakBlocking('I can also use espeak for speech')
    mouth.setEspeak()
    mouth.speakBlocking('this is what espeak sounds like')
 
if (Runtime.getPlatform().isWindows()):
    mouth.speakBlocking('I appear to be on a Windows system')
    mouth.speakBlocking('I can also use mimic for speech')
    mouth.setMimic()
    mouth.speakBlocking('this is how mimic speech sounds')
 
if (Runtime.getPlatform().isMac()):
    mouth.speakBlocking('I appear to be on a Mac OS system')
 
# set your voice from macos control panel
# you can test it using say command from terminal
 
# mouth.setVoice("Microsoft Zira Desktop - English (United States)")
mouth.speakBlocking(u"Hello this is an english voice")
mouth.speakBlocking(u"Bonjour ceci est une voix française, je teste les accents aussi avec le mot éléphant")
 
mouth.setVolume(0.7)
mouth.speakBlocking("I have lowered my volume")
mouth.speakBlocking("Silent please")
mouth.setMute(True)
mouth.speakBlocking("you cannot hear me")
mouth.setMute(False)
Example configuration (from branch develop):
!!org.myrobotlab.service.config.LocalSpeechConfig
blocking: false
listeners: null
mute: false
peers:
  audioFile:
    autoStart: true
    name: localspeech.audioFile
    type: AudioFile
replaceChars: null
speechRecognizers: null
speechType: null
substitutions: null
type: LocalSpeech
voice: null

This text to speech synthesis service use local operating system text to speech engine.

MacOs :

Just set your voice, inside control panel
You can test it using say "something" inside terminal

http://cdn.osxdaily.com/wp-content/uploads/2011/07/add-new-voices-to-os-x-lion.jpg

 

Windows :

Ahoy ! .. This is a little post about a "work in process" called the Test service.  It function is to test the other services.  Currently, it will check if service page documentation exists, if pyrobotlab/service example files exist and test them, if junit service tests exists and run them.