TigerJython4Kids
 robotics
Deutsch   English   

Documentation mbRobot

Moduls: mbrobot (F), mbrobot_plus, mbrobot_plusV2 (F), mbrobot_plusV3

Additional modules marked with (F) are automatically copied to the micro:bit during flashing.
Download off all Moduls.


Modul import:

from mbrobot import */from mbrobot_plus import */from mbrobot_plusV2 import */from mbrobot_plusV3 import *

Real-aund Simultion mode

Function Action
forward() sets the robot in forward motion
backward() sets the robot in backward motion
left() sets the robot in a left turn (one motor in forward, the other in backward rotation)
right() sets the robot in a right turn (one motor in forward, the other in backward rotation)
leftArc(radius) sets the Maqueen to a left curve with given radius (in m)
rightArc(radius) sets the Maqueen to a right curve with given radius (in m)
stop() stops the movement
setSpeed(speed)

sets the speed for all movements (0..100)

motL.rotate(speed)

sets the left motor in motion with the rotation speed speed. For speed > 0 forwards, for speed < 0 backwards, speed = 0 stops the rotation

motR.rotate(speed)

sets the right motor in motion with the rotation speed speed. For speed > 0 forwards, for speed < 0 backwards, speed = 0 stops the rotation

calibrate(offset, differential, arcScaling)
(only real mode)

calibrates motors, if the robot does not drive straight
offset: minimal power of the motors (-10 to 50)
differential: Adjusts power difference of left and right Wheel (-150 to 150),
if a robot steers left when driving forward < 0, if steers right > 0
arcScalling: Adjusts the radius by leftArc() or rightArc() (values -50 to 50), if radius to laarge > 0, if radius to small < 0

setPID(1) [only mbrobot_plus, real mode]

reduces the speed, the robot moves slower (at walking pace)

setPID(0) [nur mbrobot_plus, real mode]

PID is switched off, robot moves at given speed

pidControlDistance(dir, d) [nur mbrobot_plusV3]

moves exactly the distance d (in cm) forwards (dir=1) or backwards (d =2)

setControlAngle(angle) [nur mbrobot_plusV3]

rotates exactly by the angle angle to the left (angle>0) or right (angle<0)

getDistance() returns the distance (in mm) measured with the ultrasonic sensor
getDistanceList() [nur mbrobot_plusV3]

returns a list of 64 distance values from the lidar sensor

getDistanceGrid() [nur mbrobot_plusV3] returns 8 lists, each with 8 distance values from the lidar sensor
getDistanceRow(i) [nur mbrobot_plusV3] returns the values of the i-th row of the distance matrix of the lidar sensor
getDistanceColumn(j) [nur mbrobot_plusV3] returns the values of the j-th column of the distance matrix of the lidar sensor
getDistanceAt(x, y) [nur mbrobot_plusV3] returns the distance to the point (x, y) of the distance matrix of the lidar sensor
irLeft.read_digital(), irRight.read_digital() infrared sensors return 0, if floor is dark; 1, if floor is bright
Maqueen PlusV2 has 5 IR-Sensors (irL1, irR1, irL2, irR2, irM)
Maqueen Plus has 6 IR-Sensors ((irL1, irR1, irL2, irR2, irL3, irR3)
irX.read_digital() return 0 or 1
setLED(1) turns LEDs on
mbRobot_plus has 7 colors(1:rot, 2:grün, 3:gelb, 4:blau, 5:pink, 6:cyan, 7:weiss)
setLED(0) turns LEDs off
setLEDLeft(n)

turns left LED on (n = 1) or off (n = 0)

setLEDRight(n)

turns the right LED on (n = 1) or off (n = 0)

setLEDs(n1, n2) [nur mbrobot_plusV3]

turns left LED color n1 an right LED color n2 on

setRGB(red, green, blue)
(only mbrobot_plusV2, V3)

turns RGB-LEDs in the given color on (red, green, blue: 0 ...255)

cleanRGB(red, green, blue)
(only mbrobot_plusV2, V3)

turns RGB-LEDs off

setAlarm(1) sets alarm on
setAlarm(0) sets alarm off
readLightIntensity(0) [nur mbrobot_plusV3] returns the light value of the right light sensor (0 -1023)
readLightIntensity(1) [nur mbrobot_plusV3] returns the light value of the left light sensor (0 -1023)
setServo(port, angle) turns the servomotor connected to port S1 or S2 (or P1 or P2) to the specified angular position. (0 <= angle <= 180)
playTone(freq, duration) plays a tone of a given frequency and duration
intersectDetecting()
[nur mbrobot_plusV3]
returns 1 (True) if a crossing is detected, otherwise 0 (False)
patrolling(1) [nur mbrobot_plusV3] enables the line tracking algorithm (disabled at parameter 0)
setPatrolSpeed(1) [nur mbrobot_plusV3] sets the optimum speed for line tracking
RobotContext.
enableTrace(True) [only S]
robot leaves traces
RobotContext.
enableRotCenter(True) [only S]
draws the center of rotation for movements on a circular arc
RobotContext.
useBackground("sprite") [only S]
adds a background image for the simulation with light or color sensors
RobotContext.
setStartPosition(x, y) [only S]
places the simulated robot at the position (x, y) in the graphics window
RobotContext.
setStartDirection(w) [only S]
determines the start direction (0: east, 90: north, 180: west, 270: south)
RobotContext.
useObstacle("sprite", x, y) [only S]
adds an image with transparent background at position x,y
setBeamAreaColor() [only S] sets the color of the beam area boundaries
setProximityCircleColor() [only S] sets the color of the proximity circle
setMeshTriangleColor() [only S] sets the color of the mesh triangles
eraseBeamArea() [only S] erases the beam area boundaries


Modul mbrobotmot(switch motors individually)
(real- and simulation mode)
Modul import: from mbrobotmot import *
Modul import: from mbrorobot_plus import *
Modul import: from mbrorobot_plusV2 import *

motL, motR motor left, motor right
motX.rotate(speed) sets the left or right motor in motion with the rotation speed speed. For speed > 0 forwards, for speed < 0 backwards, speed = 0 stops the rotation