Day 2 slides UNO summer 2010 robotics workshop

1,666 views

Published on

Slides for day 2 of UNO summer 2010 high school robotics workshop

Published in: Education, Technology, Business
1 Comment
1 Like
Statistics
Notes
  • very good presentation for Webots. I add a link to my article about tutorials start robotic simulation with Webots http://www.intorobotics.com/webots-simulation-tutorials-and-resources/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
1,666
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
15
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Day 2 slides UNO summer 2010 robotics workshop

  1. 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. 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. 3. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  4. 4. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  5. 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. 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. 7. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  8. 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. 9. Designing the Robot’s Controller • Controller contains the ‘brain’ of the robot Controller Read input from Send output sensors to actuators
  10. 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. 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. 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. 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. 14. E-puck: Spinning • Start spinning left • If left wheel speed > 1234, stop
  15. 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. 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. 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. 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. 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. 20. E-puck Webots Review • Obstacle Avoidance: Code review • Line Follower: Code review • Odometry: Simulation only • Braitenberg: Code review
  21. 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. 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

×