forward() [S] | sets the robot in forward motion with predefined speed |
forward(time) [S] | moves forward during given time (in ms) (blocking method) |
backward() [S] | sets the robot in back ward motion with predefined speed |
backward(time) [S] | moves backward during given time (in ms) (blocking method) |
left() [S] | starts the left turn |
left(time) [S] | turns left during given time (in ms) (blocking method) |
right() [S] | starts the right turn |
right(ms) [S] | turns right during given time (in ms) (blocking method) |
leftArc(radius) [S] | starts the left curve movement (radius in m, only approximative) |
leftArc(radius, time) [S] | turns on left arc during given time (in ms) with given radius left (blocking method) |
rightArc(radius) [S] | starts the right curve movement (radius in m, only approximative) |
rightArc(radius, time) [S] | turns on right arc during given time (in ms) with given radius left (blocking method) |
stop() [S] | stops the movement |
moveTo(count, blocking = True) [S] | starts the rectilinear movement with predefined speed up to the given wheel count and stops. count > 0: forward, count < 0: reverse |
turnTo(count, blocking = True) [S] | starts the rotation up to the given wheel count and stops. count > 0: clockwise, count < 0: counterclockwise |
setSpeed(speed) [S] | sets the speed (0..100). Only becomes effective when the next motion function is called. Default speed = 30. |
delay(time) [S] | stops the program during the given time (in ms) |
sleep(time [S] | same as delay(ms) |
setLED(n) [S] | switches LED lights: 0: off, 1: green, 2: red, 3: light red , 4: green flashing, 5: red flashing, 6: light red flashing, 7: green double flashing, 8: red double flashing, 9: light red double flashing |
setAlarm(n) [S] | switches beep signal: 0: off, 1: on |
playTone(freq, duration) [S] | plays a tone with a given frequency (in Hertz) and duration (in ms) |
setVolume(volume) | sets the volume (0..100). This value is stored permanently |
clearDisplay() | clears the display |
drawString(text, x, y) | writes single-line text at position (x: horizontal, y: vertical) |
getIPAddresses() | returns a list of all active IP addresses |
getRobot() | returns the instance of the global robot (to be used with OOP classes) |
reset() [only S] | sets the robot to the starting position/direction |
Instances | Port |
motA, motB, motC, motD | motor at corresponding MotorPort |
motL = motA, motR = motB | left and right motor |
Methods | Action |
motX.rotate(speed) [S] | turns the motor motX (speed > 0: forward, speed> 0, backward, speed = 0: stop() |
motX.isMoving() [S] | returns True, if the motor is rotating |
motX.getMotorCount() [S] | returns the current status of the counter |
motX.resetMotorCount() [S] | sets the counter to 0 |
motX.rotateTo(count) [S] | moves motor to counter count and stops (blocking). Sets counter to 0 |
motX.rotateTo(count, blocking) [S] | same as rotateTo(count); not blocking, if blocking = False |
motX.continueTo(count) [S] | same as rotateTo(count), but counter not set to 0 |
motX.continueTo(count, blocking) [S] | same as rotateTo(count); not blocking, if blocking = False. Counter not set to 0 |
motX.continueRelativeTo(count) [S] | same as continueTo(count), but count is increment |
motX.continueRelativeTo(count, blocking) [S] | same as continueTo(count), but count is increment; not blocking, if blocking = False |
motX.setSpeed(speed) | sets the speed of motX (default speed=50) |
Instances | Position |
button_escape [S] | top left |
button_enter [S] | center |
button_left [S] | cursor left |
button_right [S] | cursor right |
button_up [S] | cursor up |
button_down [S] | cursor down |
Method | Action |
was_pressed() [S] | returns True if the button has been pressed since the last call. |
Functionen [S] | Action |
isEscapeHit() [S] | returns True, if the escape button has been pressed since the last call |
isEnterHit() [S] | same for the enter button |
isLeftHit() [S] | same for the left button |
isRightHit() [S] | same for the right button |
isUpHit() [S] | same for the up button |
isDownHit() [S] | same for the down button |
Instances | Port |
ls1, ls2, ls3, ls4 [S] | light sensor at corresponding SensorPort |
Method | Action |
getValue() [S] | returns light intensity (0..1023) |
Instances | Port |
ts1, ts2, ts3, ts4 [S] | touch sensor at corresponding SensorPort |
Method | Action |
isPressed() [S] | returns True, if the touch sensor is pressed |
Instances | Port |
us1, us2, us3, us4 [S] | sensor at corresponding SensorPort |
Methods | Action |
getDistance() [S] | returns distance (in cm); 255, if no reflecting object is detected (for simulation mode: -1) |
setProximityCircleColor(color) [S] | (simulation mode only) sets the color of the proximity circle |
setMeshTriangleColor(color) [S] | (simulation mode only) sets the color of the mesh triangles |
setBeamAreaColor(color) [S] | (simulation mode only) sets the color of the beam area boundaries |
eraseBeamArea() [S] | (simulation mode only) erases the beam area boundaries |
Instances | Port |
cs1, cs2, cs3, cs4 [S] | Colorsensor at corresponding SensorPort |
Methode | Aktion |
getColor() [S] | returns the basic colors as a string (RED, BLUE, YELLOW, GREEN, WHITE, BLACK) |
getColorRGB() [S] | returns a list of color components [r, g, b] ( numbers 0 ... 255) |
calibrateColor(colors, previous) | calibrates colors that are not correctly recognized by the color sensor. Parameter colors is a list of colors to be calibrated. If no list is given, the standard colors (black, blue, green, yellow, red and white) are calibrated. If parameter previous is True, a new calibration starts, if False the results of the last calibration are used. Ex: cs3.calibrateColor(["RED", "BLUE", "GREEN"], True) |
Remark:
If a sensor is connected to SensorPort 1, you can also use global functions (e.g. getValue ().
Instanzen | Port |
grs1, grs2, grs3, grs4 | Gyro Rate Sensor at corresponding SensorPort |
Methode | Aktion |
getValue() | returns the rotation speed of the robot in degrees per second |
Instanzen | Port |
gas1, gas2, gas3, gas4 | Gyro Angle Sensor at corresponding SensorPort |
Methode | Aktion |
getValue() | provides the rotation angle of the robot in degrees |
reset() | sets the start position |
Instances | Port |
sht1, sht2, sht3, sht4 | sensor at corresponding SensorPort |
Method | Action |
getValues() | returns a tuple of floats with temperature (deg C) and humidity (%) |
Instances | Port |
bme1, bme2, bme3, bme4 | sensor at corresponding SensorPort |
Method | Action |
getValues() | returns a tuple of floats with temperature (deg C), humidity (%) and air pressure (hPa) |
Instances | Port |
adxl1, adxl2, adxl3, adxl4 | sensor at corresponding SensorPort |
Method | Action |
getValues() | returns a tuple of floats with accelerations in x-, y- and z-direction (m/s^2 in range -2g .. 2g) |
Instanzen | Port |
tmp1, tmp2, tmp3, tmp4 | sensor at corresponding SensorPort |
Method | Action |
getTemperature() | returns the temperature (deg C) |
Remark:
This method (with SensorPort.S1) is also available as global function (compatibility to mbrobot)
Instances | Port |
irs | Infrared sensor at SensorPort S1 |
Method | Action |
getCommand() | returns the current command ID for the pressed keys: 0: nothing pressed The red slide switch must be at the top position (selecting SensorPort S1) |
Function | Action |
httpGet(url) | executes an HTTP GET request and returns the response. url in the form "http://<server>?key=value&key=value&..." or for SSL "https://..." |
httpPost(url, content) | executes an HTTP POST request and returns the response. url in the form "http://<server>". content in the format "key=value&key=value&..." or for SSL "https://..." |
httpDelete(url) | executes an HTTP DELETE request with the given resource. |
startHTTPServer(handler) | starts an HTTP server (web server on port 80) that listens to HTTP GET requests. For a GET request, the user-defined callback handler(clientIP, filename, params) is called:
clientIP: dotted IP address of the client
Example http://192.168.0.101/on?a=ok&b=3 The return value consists of comma-separated values (packed into tuple) that are inserted into the %s-format specifications of the saved HTML file before being sent back to the browser. (The number and order must match.) If the return value is missing, the saved HTML file will be returned unchanged. (The call is not blocking because the server runs in a separate thread.) |
saveHTML(text) | saves the text as an HTML file, which is sent to the browser after a GET request. It may contain %-format specifications that are replaced with the return values of the callback handler(clientIP, filename, params) |
Function | Action | ||||||||||||||||||||
getWeather(city, key) |
performs a weather data request on http://openweathermap.org for the selected town. The given authorization key is used. You can get it for free on this host. (If the parameter is omitted, a standard key is used, which allows a maximum of 60 requests / min for all users.) Return value: Dictionary with the following fields:
|
for given city
Function | Action |
getHTTPDateTime(city, timezone, key) |
performs a time/date request to https://api.timezonedb.com for the selected city. The given authorization key is used. You can get it for free from this host. (If the parameter is omitted, a default key is used which allows a maximum of 1 request/sec for all users.) timezone is either the country code or the country name. Return value: String in format: ww yyyy-nn-dd hh:mm:ss If an error occurs, None is returned |
getHTTPTime(city, timezone, key) | same, but only the time part is returned in the format hh:mm:ss |
getCountryCode(country) | returns the country code (2 letters) for the given country (written in English) |
getCountry(countryCode) | returns the country for the given country code |
countryCodes | Dictionary with code:country |