SlideShare a Scribd company logo
Robotics: Designing and Building
     Multi-robot Systems
                     Day 2

UNO Summer 2010 High School
       Workshop
                     Raj Dasupta
                 Associate Professor
           Computer Science Department
           University of Nebraska, Omaha
   College of Information Science and Technology
Plan for Day 2
• Designing autonomous intelligence in
  robots...controller
  –   MyBot: Simple Obstacle Avoidance
  –   Blinking LEDs
  –   Controlling motors
  –   Camera-based object following
  –   Finte State machine: Lawn mower like pattern
  –   Obstacle Avoidance: Code review
  –   Line Follower: Code review
  –   Odometry: Simulation only
  –   Braitenberg: Code review
Designing the Robot’s Controller
• Controller contains the ‘brain’ of the robot



                        Controller

      Read input from                Send output
          sensors                    to actuators
Designing the Robot’s Controller
• Controller contains the ‘brain’ of the robot



                        Controller

      Read input from                Send output
          sensors                    to actuators
Reading the Input from the sensors
 #include <webots/robot.h>
 #include <webots/distance_sensor.h>
 #include <stdio.h>
 #define TIME_STEP 32
 int main() {
  wb_robot_init();
     WbDeviceTag ds = wb_robot_get_device("my_distance_sensor");
     wb_distance_sensor_enable(ds, TIME_STEP);
     while (1) {
       wb_robot_step(TIME_STEP);
       double dist = wb_distance_sensor_get_value(ds);
       printf("sensor value is %fn", dist);
     }
     return 0;
 }
Reading the Input from the sensors
                                                1. Get a handle to
      #include <webots/robot.h>                 the sensor device              This is the “name”
      #include <webots/distance_sensor.h>                                      field of the robot’s
      #include <stdio.h>                                                       sensor from the
      #define TIME_STEP 32                                                     scene tree

      int main() {
       wb_robot_init();
       WbDeviceTag ds = wb_robot_get_device("my_distance_sensor");
       wb_distance_sensor_enable(ds, TIME_STEP);
                                                                               How often to get
        while (1) {                                                            the data from the
          wb_robot_step(TIME_STEP);                                            sensor
          double dist = wb_distance_sensor_get_value(ds);
          printf("sensor value is %fn", dist);
        }
                          3. Get the sensor data...the general format of this step is
        return 0;         wb_<sensor_name>_get_value (sensor_handle)
      }
2. Enable the sensor device...the general format of this step is
wb_<sensor_name>_enable (sensor_handle, poll_time)
Designing the Robot’s Controller
• Controller contains the ‘brain’ of the robot



                        Controller

      Read input from                Send output
          sensors                    to actuators
Sending the output to actuators
#include <webots/robot.h>
#include <webots/servo.h>
#include <math.h>
#define TIME_STEP 32
int main() {
 wb_robot_init();
    WbDeviceTag servo = wb_robot_get_device("my_servo");
    double F = 2.0; // frequency 2 Hz
    double t = 0.0; // elapsed simulation time
    while (1) {
      double pos = sin(t * 2.0 * M_PI * F);
      wb_servo_set_position(servo, pos);
      wb_robot_step(TIME_STEP);
      t += (double)TIME_STEP / 1000.0;
    }
    return 0;
}
Designing the Robot’s Controller
• Controller contains the ‘brain’ of the robot



                        Controller

      Read input from                Send output
          sensors                    to actuators
A simple example
#include <webots/robot.h>
#include <webots/differential_wheels.h>
#include <webots/distance_sensor.h>
#define TIME_STEP 32
int main() {
 wb_robot_init();
    WbDeviceTag left_sensor = wb_robot_get_device("left_sensor");
    WbDeviceTag right_sensor = wb_robot_get_device("right_sensor");
    wb_distance_sensor_enable(left_sensor, TIME_STEP);
    wb_distance_sensor_enable(right_sensor, TIME_STEP);
    while (1) {
     wb_robot_step(TIME_STEP);
        // read sensors
        double left_dist = wb_distance_sensor_get_value(left_sensor);
        double right_dist = wb_distance_sensor_get_value(right_sensor);
        // compute behavior
        double left = compute_left_speed(left_dist, right_dist);
        double right = compute_right_speed(left_dist, right_dist);
        // actuate wheel motors
        wb_differential_wheels_set_speed(left, right);
    }
    return 0;
}
A simple example
#include <webots/robot.h>
#include <webots/differential_wheels.h>
#include <webots/distance_sensor.h>
#define TIME_STEP 32
int main() {
 wb_robot_init();
    WbDeviceTag left_sensor = wb_robot_get_device("left_sensor");
    WbDeviceTag right_sensor = wb_robot_get_device("right_sensor");
    wb_distance_sensor_enable(left_sensor, TIME_STEP);
    wb_distance_sensor_enable(right_sensor, TIME_STEP);
    while (1) {
     wb_robot_step(TIME_STEP);
                                                                           Get input from sensor data
        // read sensors
        double left_dist = wb_distance_sensor_get_value(left_sensor);
        double right_dist = wb_distance_sensor_get_value(right_sensor);
        // compute behavior
        double left = compute_left_speed(left_dist, right_dist);          A very simple controller
        double right = compute_right_speed(left_dist, right_dist);
        // actuate wheel motors
        wb_differential_wheels_set_speed(left, right);
    }                                                                     Send output to actuator
    return 0;
}
A few other points
#include <webots/robot.h>
#include <webots/differential_wheels.h>           Mandatory initialization
#include <webots/distance_sensor.h>               step...only used in C language
#define TIME_STEP 32
int main() {                                                                Keep doing this as long as
 wb_robot_init();
                                                                            the simulation (and the
    WbDeviceTag left_sensor = wb_robot_get_device("left_sensor");           robot) runs
    WbDeviceTag right_sensor = wb_robot_get_device("right_sensor");
    wb_distance_sensor_enable(left_sensor, TIME_STEP);
    wb_distance_sensor_enable(right_sensor, TIME_STEP);
    while (1) {
     wb_robot_step(TIME_STEP);                                                 • How often to get data
        // read sensors                                                        from simulated robot into
        double left_dist = wb_distance_sensor_get_value(left_sensor);          the controller program
        double right_dist = wb_distance_sensor_get_value(right_sensor);
                                                                               • Every controller must
        // compute behavior
        double left = compute_left_speed(left_dist, right_dist);               have it
        double right = compute_right_speed(left_dist, right_dist);
                                                                               • Must be called at regular
        // actuate wheel motors                                                intervals
        wb_differential_wheels_set_speed(left, right);
    }                                                                          • Placed inside main()
    return 0;
}
MyBot Controller
• Simple obstacle avoidance behavior
  – Get IR distance sensor inputs (both L and R)
  – If both of these readings are > 500... its an
    emergency, back up fast
  – If only one of these readings is > 500...turn
    proportionately to the sensor values
  – If both readings are < 500...nothing wrong, keep
    moving straight
• Let’s program this in Webots
E-puck: Spinning
• Start spinning left
• If left wheel speed > 1234, stop
E-puck: LED blinking
• Blink the 8 LEDs of the e-puck one after
  another
  – Turn all LEDs off
  – Count repeatedly from 1...8
     • Turn LED<count> on
• Note that in this example, we are not using
  any sensor inputs...the LEDS just start blinking
  in a circle when we start running the
  simulation
Camera Controller
• Objective: Follow a white ball
• How to do it...
  – Get the image from the camera
  – Calculate the brightest spot on the camera’s
    image...the portion of the image that has the
    highest intensity (white color of ball will have
    highest intensity)
  – Set the direction and speed of the wheels of the
    robot to move towards the brightest spot
State-based controller for object
       following with camera
             Analyze     Do some math
            image to     to calculate the
             find the     direction and
            brightest     speed of the
               spot      wheels to get to
                        the brightest spo
                                            Set wheel
Get image                                    speed to
  from                                          the
 camera                                     calculated
                                              values
State Machine
• Controller is usually implemented as a finite
  state machine


       State i
                                                                 State k

                                    State j
                 Transition (i,j)             Transition (J,k)
A finite state-based controller for
             avoiding obstacles

                                Stop
    One of L or R front                           40 steps complete
    sensors recording
        obstacles

                          40 steps not complete

     Moving                                                Make a
     forward                                               U-turn
                           Angle turned >= 180
                                 degrees



  Both L and R front
sensors not recording
    any obstacles
E-puck Webots Review
•   Obstacle Avoidance: Code review
•   Line Follower: Code review
•   Odometry: Simulation only
•   Braitenberg: Code review
Summary of Day 2 Activities
• Today we learned about the controller of a
  robot
• The controller is the autonomous, intelligent
  part of the robot
• The controller processes the inputs from the
  robot’s sensors and tells the robot’s actuator
  what to do
• We wrote the code for different controllers
  and reviewed some complex controllers
Plan for Day 3
• We will learn how to program some basic
  behaviors on the e-puck robot
  – Zachary will be teaching this section

More Related Content

PDF
Lecture6
PDF
libGDX: Scene2D
PDF
Game Programming I - Introduction
PPTX
The Visual Images of Politicians in Ukraine – from the Orange Revolution unti...
PPT
Application of robot’s
PDF
Commerce extérieur france 3e trimestre 2010
PDF
Phree photo editing l
PDF
Find company reports in EBSCO Business Source Complete
Lecture6
libGDX: Scene2D
Game Programming I - Introduction
The Visual Images of Politicians in Ukraine – from the Orange Revolution unti...
Application of robot’s
Commerce extérieur france 3e trimestre 2010
Phree photo editing l
Find company reports in EBSCO Business Source Complete

Viewers also liked (20)

PDF
Semester of Code: Piloting Virtual Placements for Informatics across Europe
PDF
Course 1: Create and Prepare Debian7 VM Template
PDF
Learning services-based technological ecosystems
PPTX
Aléjate de mi
PDF
Programa de prácticas en empresas internacionales para la Facultad de Ciencia...
PDF
EHISTO - Second Newsletter
PPTX
Matematicas 2013
PPTX
Research Perfection
PPTX
The cloud
PDF
Hack for Diversity and Social Justice
PDF
Eee pc 1201n
PPTX
Welcome & Introductory Remarks - IEEE 2014 Web 2.0 Security & Privacy Workshop
PDF
WP7 - Dissemination
PDF
A survey of resources for introducing coding into schools
PPTX
Московский workshop ЕАСD
PDF
Modelado de servicios en contextos web. Aplicación en ecosistemas de aprendizaje
PDF
Course 1: Create and Prepare CentOS 6.7 VM Template
PDF
Are nonusers socially disadvantaged?
Semester of Code: Piloting Virtual Placements for Informatics across Europe
Course 1: Create and Prepare Debian7 VM Template
Learning services-based technological ecosystems
Aléjate de mi
Programa de prácticas en empresas internacionales para la Facultad de Ciencia...
EHISTO - Second Newsletter
Matematicas 2013
Research Perfection
The cloud
Hack for Diversity and Social Justice
Eee pc 1201n
Welcome & Introductory Remarks - IEEE 2014 Web 2.0 Security & Privacy Workshop
WP7 - Dissemination
A survey of resources for introducing coding into schools
Московский workshop ЕАСD
Modelado de servicios en contextos web. Aplicación en ecosistemas de aprendizaje
Course 1: Create and Prepare CentOS 6.7 VM Template
Are nonusers socially disadvantaged?
Ad

Similar to Day 2 slides UNO summer 2010 robotics workshop (20)

PDF
TP_Webots_7mai2021.pdf
PDF
import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf
DOC
Weekly Report 5 7
DOC
Weekly Report 5 7
PDF
Wirelessly Actuated Snake Prototype
PDF
Embedded Robotics Mobile Robot Design And Applications With Embedded Systems ...
PDF
Robotics Report final.compressed (1)
PDF
Line following robot
PDF
How To Make Multi-Robots Formation Control System
PDF
project_NathanWendt
PDF
obstacle avoiding robot project
DOCX
Path Following Robot
PPTX
Line Maze Solver Presentation
PDF
Report - Line Following Robot
DOCX
Arduino Final Project
PDF
Team_Rossum_Design_Final
PDF
Lecture 7 robotics and ai
PPTX
Obstacle avoiding robot
PPTX
Obstacle Avoiding Robot Using Micro Controller
PPTX
PC-based mobile robot navigation sytem
TP_Webots_7mai2021.pdf
import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf
Weekly Report 5 7
Weekly Report 5 7
Wirelessly Actuated Snake Prototype
Embedded Robotics Mobile Robot Design And Applications With Embedded Systems ...
Robotics Report final.compressed (1)
Line following robot
How To Make Multi-Robots Formation Control System
project_NathanWendt
obstacle avoiding robot project
Path Following Robot
Line Maze Solver Presentation
Report - Line Following Robot
Arduino Final Project
Team_Rossum_Design_Final
Lecture 7 robotics and ai
Obstacle avoiding robot
Obstacle Avoiding Robot Using Micro Controller
PC-based mobile robot navigation sytem
Ad

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Cell Structure & Organelles in detailed.
PPTX
Lesson notes of climatology university.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Presentation on HIE in infants and its manifestations
PDF
Classroom Observation Tools for Teachers
102 student loan defaulters named and shamed – Is someone you know on the list?
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Cell Types and Its function , kingdom of life
Pharma ospi slides which help in ospi learning
Microbial diseases, their pathogenesis and prophylaxis
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Cell Structure & Organelles in detailed.
Lesson notes of climatology university.
Module 4: Burden of Disease Tutorial Slides S2 2025
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
RMMM.pdf make it easy to upload and study
Presentation on HIE in infants and its manifestations
Classroom Observation Tools for Teachers

Day 2 slides UNO summer 2010 robotics workshop

  • 1. Robotics: Designing and Building Multi-robot Systems Day 2 UNO Summer 2010 High School Workshop Raj Dasupta Associate Professor Computer Science Department University of Nebraska, Omaha College of Information Science and Technology
  • 2. Plan for Day 2 • Designing autonomous intelligence in robots...controller – MyBot: Simple Obstacle Avoidance – Blinking LEDs – Controlling motors – Camera-based object following – Finte State machine: Lawn mower like pattern – Obstacle Avoidance: Code review – Line Follower: Code review – Odometry: Simulation only – Braitenberg: Code review
  • 3. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  • 4. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  • 5. Reading the Input from the sensors #include <webots/robot.h> #include <webots/distance_sensor.h> #include <stdio.h> #define TIME_STEP 32 int main() { wb_robot_init(); WbDeviceTag ds = wb_robot_get_device("my_distance_sensor"); wb_distance_sensor_enable(ds, TIME_STEP); while (1) { wb_robot_step(TIME_STEP); double dist = wb_distance_sensor_get_value(ds); printf("sensor value is %fn", dist); } return 0; }
  • 6. Reading the Input from the sensors 1. Get a handle to #include <webots/robot.h> the sensor device This is the “name” #include <webots/distance_sensor.h> field of the robot’s #include <stdio.h> sensor from the #define TIME_STEP 32 scene tree int main() { wb_robot_init(); WbDeviceTag ds = wb_robot_get_device("my_distance_sensor"); wb_distance_sensor_enable(ds, TIME_STEP); How often to get while (1) { the data from the wb_robot_step(TIME_STEP); sensor double dist = wb_distance_sensor_get_value(ds); printf("sensor value is %fn", dist); } 3. Get the sensor data...the general format of this step is return 0; wb_<sensor_name>_get_value (sensor_handle) } 2. Enable the sensor device...the general format of this step is wb_<sensor_name>_enable (sensor_handle, poll_time)
  • 7. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  • 8. Sending the output to actuators #include <webots/robot.h> #include <webots/servo.h> #include <math.h> #define TIME_STEP 32 int main() { wb_robot_init(); WbDeviceTag servo = wb_robot_get_device("my_servo"); double F = 2.0; // frequency 2 Hz double t = 0.0; // elapsed simulation time while (1) { double pos = sin(t * 2.0 * M_PI * F); wb_servo_set_position(servo, pos); wb_robot_step(TIME_STEP); t += (double)TIME_STEP / 1000.0; } return 0; }
  • 9. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  • 10. A simple example #include <webots/robot.h> #include <webots/differential_wheels.h> #include <webots/distance_sensor.h> #define TIME_STEP 32 int main() { wb_robot_init(); WbDeviceTag left_sensor = wb_robot_get_device("left_sensor"); WbDeviceTag right_sensor = wb_robot_get_device("right_sensor"); wb_distance_sensor_enable(left_sensor, TIME_STEP); wb_distance_sensor_enable(right_sensor, TIME_STEP); while (1) { wb_robot_step(TIME_STEP); // read sensors double left_dist = wb_distance_sensor_get_value(left_sensor); double right_dist = wb_distance_sensor_get_value(right_sensor); // compute behavior double left = compute_left_speed(left_dist, right_dist); double right = compute_right_speed(left_dist, right_dist); // actuate wheel motors wb_differential_wheels_set_speed(left, right); } return 0; }
  • 11. A simple example #include <webots/robot.h> #include <webots/differential_wheels.h> #include <webots/distance_sensor.h> #define TIME_STEP 32 int main() { wb_robot_init(); WbDeviceTag left_sensor = wb_robot_get_device("left_sensor"); WbDeviceTag right_sensor = wb_robot_get_device("right_sensor"); wb_distance_sensor_enable(left_sensor, TIME_STEP); wb_distance_sensor_enable(right_sensor, TIME_STEP); while (1) { wb_robot_step(TIME_STEP); Get input from sensor data // read sensors double left_dist = wb_distance_sensor_get_value(left_sensor); double right_dist = wb_distance_sensor_get_value(right_sensor); // compute behavior double left = compute_left_speed(left_dist, right_dist); A very simple controller double right = compute_right_speed(left_dist, right_dist); // actuate wheel motors wb_differential_wheels_set_speed(left, right); } Send output to actuator return 0; }
  • 12. A few other points #include <webots/robot.h> #include <webots/differential_wheels.h> Mandatory initialization #include <webots/distance_sensor.h> step...only used in C language #define TIME_STEP 32 int main() { Keep doing this as long as wb_robot_init(); the simulation (and the WbDeviceTag left_sensor = wb_robot_get_device("left_sensor"); robot) runs WbDeviceTag right_sensor = wb_robot_get_device("right_sensor"); wb_distance_sensor_enable(left_sensor, TIME_STEP); wb_distance_sensor_enable(right_sensor, TIME_STEP); while (1) { wb_robot_step(TIME_STEP); • How often to get data // read sensors from simulated robot into double left_dist = wb_distance_sensor_get_value(left_sensor); the controller program double right_dist = wb_distance_sensor_get_value(right_sensor); • Every controller must // compute behavior double left = compute_left_speed(left_dist, right_dist); have it double right = compute_right_speed(left_dist, right_dist); • Must be called at regular // actuate wheel motors intervals wb_differential_wheels_set_speed(left, right); } • Placed inside main() return 0; }
  • 13. MyBot Controller • Simple obstacle avoidance behavior – Get IR distance sensor inputs (both L and R) – If both of these readings are > 500... its an emergency, back up fast – If only one of these readings is > 500...turn proportionately to the sensor values – If both readings are < 500...nothing wrong, keep moving straight • Let’s program this in Webots
  • 14. E-puck: Spinning • Start spinning left • If left wheel speed > 1234, stop
  • 15. E-puck: LED blinking • Blink the 8 LEDs of the e-puck one after another – Turn all LEDs off – Count repeatedly from 1...8 • Turn LED<count> on • Note that in this example, we are not using any sensor inputs...the LEDS just start blinking in a circle when we start running the simulation
  • 16. Camera Controller • Objective: Follow a white ball • How to do it... – Get the image from the camera – Calculate the brightest spot on the camera’s image...the portion of the image that has the highest intensity (white color of ball will have highest intensity) – Set the direction and speed of the wheels of the robot to move towards the brightest spot
  • 17. State-based controller for object following with camera Analyze Do some math image to to calculate the find the direction and brightest speed of the spot wheels to get to the brightest spo Set wheel Get image speed to from the camera calculated values
  • 18. State Machine • Controller is usually implemented as a finite state machine State i State k State j Transition (i,j) Transition (J,k)
  • 19. A finite state-based controller for avoiding obstacles Stop One of L or R front 40 steps complete sensors recording obstacles 40 steps not complete Moving Make a forward U-turn Angle turned >= 180 degrees Both L and R front sensors not recording any obstacles
  • 20. E-puck Webots Review • Obstacle Avoidance: Code review • Line Follower: Code review • Odometry: Simulation only • Braitenberg: Code review
  • 21. Summary of Day 2 Activities • Today we learned about the controller of a robot • The controller is the autonomous, intelligent part of the robot • The controller processes the inputs from the robot’s sensors and tells the robot’s actuator what to do • We wrote the code for different controllers and reviewed some complex controllers
  • 22. Plan for Day 3 • We will learn how to program some basic behaviors on the e-puck robot – Zachary will be teaching this section