Programming Qoopers & Q-scout with Python

Initiating

Importqmindfile and create an object robot

from qmind import Qmind
robot = Qmind('robot')

Movements

Set on-board motors’ movements (forward or backward)

  • Parameter 1: forward1, backward2, left3, right4
  • Parameter 2: speed range -90 to 90
robot.set_motor_type(1, 45)

Set on-board motors’ movements (clockwise or counterclockwise)

  • Parameter 1: left motor or right motor, range 1 to 2
  • Parameter 2: clockwise or counterclockwise, range 1 to 2
  • Parameter 3: speed range -90 to 90
robot.set_motor_direction(1, 2, -80)

Set angle for left or right servo motor

  • Parameter 1: port number. Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: servo motor insertion port, range 1 to 2
robot.motion_steering_engine(4, 1, 0, 0)

Set angle separately for left or right servo motor

  • Parameter 1: port number. Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: servo motor insertion port, range 1 to 2
  • Parameter 3: angle, range -180 to 180
  • Parameter 4: angle, range -180 to 180
robot.motion_steering_engine(4, 1, 90, 90)

Set external motor’s movement direction and speed

  • Parameter 1: port number, Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: external motor insertion port, range 1 to 2
  • Parameter 3: clockwise or counterclockwise, range 1 to 2
  • Parameter 4: speed range -90 to 90
robot.set_external_motor(4, 2, 0, 45)

Stop on-board motors’ movement

robot.set_motor_stop()

Lights

Set on-board lights’ color (RGB)

  • Parameter 1: both 0, left 1, right 2
  • Parameter 2: red, range 0 to 255
  • Parameter 3: green, range 0 to 255
  • Parameter 4: blue, range 0 to 255
robot.set_led(0, 220, 115, 220)

Set graphics for LED matrix panel

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: graphic value
data = [
    [1,1,0,0,0,0,0,0,0,0,0,0,1,1],
    [0,0,1,1,0,0,0,0,0,0,1,1,0,0],
    [0,0,0,0,1,1,0,0,1,1,0,0,0,0],
    [0,0,0,0,0,0,1,1,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
]
robot.show_matrix(2, data)

Set graphics for RGB LED matrix panel

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: graphic value
data = [
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0],
  [0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0],
  [0, 0, 4, 4, 4, 0, 0, 4, 0, 0, 0, 0],
  [0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]
robot.gs_matrix_rgb_led4(0, data)

Set color for ultrasonic sensor’s lights (RGB)

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: red, range 0 to 255
  • Parameter 3: green, range 0 to 255
  • Parameter 4: blue, range 0 to 255
robot.set_ultrasonic(0, 47, 144, 44)

Sound

Set buzzer frequency and lasting time

  • Parameter 1: frequency
  • Parameter 2: lasting time
robot.set_sound(262, 500)

results matching ""

    No results matching ""