Author: macerobotics

MRPi1 – delivery robot

New video of MRPi1 robot :

  • Python program,
  • Autonomous robot,
  • Control the position with remote control,

The python program :

from mrpi1_lib import *
import time

ir = 0;
state = 0

controlEnable()


while 1:
  # read the infrared receiver
  ir = irReceiver()
  time.sleep(0.2)

  if(ir == 1) and (state == 0):
    forwardC(10,400)
    state = 1
  if(ir == 2) and (state == 0):
    forwardC(10,800)  
    state = 2
  if(ir == 3) and (state == 0):
    forwardC(10,1600)  
    state = 3
  if(ir == 3) and (state == 1):
    forwardC(10,1200)  
    state = 3
  if(ir == 3) and (state == 2):
    forwardC(10,800)  
    state = 3
  if(ir == 2) and (state == 1):
    forwardC(10,400)
    state = 2
  if(ir == 1) and (state == 2):
    backC(10,400)
    state = 1
  if(ir == 1) and (state == 3):
    backC(10,1200)
    state = 1
  if(ir == 2) and (state == 3):
    backC(10,800)
    state = 2
  if(ir == 0) and (state == 3):
    backC(10,1600)
    state = 0
  if(ir == 0) and (state == 2):
    backC(10,800)
    state = 0
  if(ir == 0) and (state == 1):
    backC(10,400)
    state = 0

 

 

 

MRPi1 version Arduino

La plateforme MRPi1 avec une carte Arduino Uno :

MRPi1-arduino

Voici une petite vidéo du robot contrôlé par l’Arduino :

Le programme réalise sous l’IDE arduino :

// initialisation des variables
int prox_1;
int prox_2;
int prox_3;
int prox_4;
int prox_5;
int prox_6;
int speed = 60;

void setup() 
{
  // initialisation du port série 
  Serial.begin(115200);         
  
  // Allumer les 3 leds du robot
  led(1,1);
  led(2,1);
  led(3,1);
}

void loop()
{
  // Lectures des capteurs de proximité
  prox_1 = proxSensor(1); 
  prox_2 = proxSensor(2); 
  prox_3 = proxSensor(3); 
  prox_4 = proxSensor(4); 
  prox_5 = proxSensor(5); 
  prox_6 = proxSensor(6); 

  // Si obstacle à gauche
  if(( prox_1 > 500) or (prox_2 > 500))
  {
    // tourner à droite
    turnRight(speed);
  }

  // Si obstacle à droite
  if(( prox_6 > 500) or ( prox_5 > 500))
  {
    // tourner à gauche
    turnLeft(speed);
  }

  // Si obstacle devant
  if(( prox_3 > 500) or ( prox_4 > 500))
  {
    // tourner à gauche
    turnLeft(speed);
  }

  // si pas d'obstacle 
  if((prox_1 < 500) and (prox_2 < 500) and (prox_3 < 500) and (prox_4 < 500) and (prox_5 < 500) and (prox_6 < 500))
  {
    // avancer
    forward(speed);
  }

}

MRPi1 Raspberry Pi robot – Speech synthesis

  • Speech synthesis
  • Autonomous robot
  • Python program

The python program :


from mrpi1_lib import *
import time

#main program

state = 1

try:
  # infinite loop
  while 1:

    if state == 2:
      play("Thank you bye")# speech synthetis
      state = 3
    # read sensors
    p3 = proxSensor(3) 
    p4 = proxSensor(4)

    forward(30)
    print "%d %d" %(p3, p4)

    if (p3 > 900 or p4 > 900):
     stop() # stop robot
     state = 2
     playWav("BeCarefull.wav") # play wav file
     
     
except:
  stop()
  exit()

 

 

 

Architecture logicielle du microcontrôleur

Voici, l’architecture logicielle du microcontrôleur STM32F407 du robot MRPi1 :

  • Un bloc de la gestion pour la communication série 8 bits vers la carte Raspberry Pi.
  • Un bloc scheduler pour la gestion des différentes taches de manière synchrone et en temps réel,
  • Un bloc d’acquisition et de traitement des capteurs du robot,
  • Un bloc de contrôle du niveau de la tension de la batterie lipo,
  • Un bloc d’asservissement du robot en position/orientation avec deux régulateurs numérique de type PID,
  • Un bloc de commande des moteurs en signaux PWM,
  • Un bloc d’acquisition des encodeurs en quadrature avec deux timers configuré sur les front des signaux,
  • Un bloc du calcul de la position du robot sur les axes X et Y puis sur l’orientation du robot.

 

archi_micro

 

 

MRPi1 – Wake up alarm

Wake up alarm with MRPi1 robot. The robot stops the alarm automaticly when the robot detects the light.

Python program :

# import mrpi1 lib
from mrpi1_lib import *
import time

try:

  while 1:
    al1 = ambiantLight(1) # read ambiant light,sensor 1
    al2 = ambiantLight(2)
    al3 = ambiantLight(3)
    al4 = ambiantLight(4)
    al5 = ambiantLight(5)
    al6 = ambiantLight(6)
    print "Ambiant light = %d %d %d %d %d %d" %(al1, al2, al3, al4, al5, al6)

    if (al1 < 4000 and al2 < 4000): # light detects
     print "end alarm"
     writeCommand("SPD")# disable speaker
     exit()
    else:
      playWav("alarmClock.wav") # play alarm wav file
    time.sleep(0.2)

except:
  writeCommand("SPD") # disable speaker
  exit()