Module 2 Controlling a Lego EV3 Robot

Slides:



Advertisements
Similar presentations
Book Port Plus Finding Existing Titles and Sending New Content Presented by Maria E. Delgado.
Advertisements

Getting started with LEGO NXT Mindstorms software This is intended to be a short introduction to the LEGO Mindstorms software and programming the LEGO.
EIGHTH GRADE ROBOTICS KITTATINNY REGIONAL HIGH SCHOOL MR. SHEA Introduction to Programming
CS 1 with Robots IDLE and Myro Institute for Personal Robots in Education (IPRE)‏
The NXT is the brain of a MINDSTORMS® robot. It’s an intelligent, computer-controlled LEGO® brick that lets a MINDSTORMS robot come alive and perform.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
BEGINNER EV3 PROGRAMMING Lesson
10/10/ Controlling YOUR ROBOT. 10/10/2015 Basic Stamp  Basic Stamp Input - output pins Interpreter Chip Power supply: 5 Volts voltage Memory: EEPROM.
Minds and Computers 3.1 Preview Spin left motor Spin right motor Wait until the motors have spun two rotations Stop left motor Stop right motor What five.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
A tiny turtle robot DEI The University of Padova.
Change in your CAD Project File - it happens all the time in robotics.
How to link the robot and the computer (Bluetooth) How to turn on and off How to connect the adaptor Fluke card connection Sec Getting Started How.
Castor Bot. Now, we will begin creating a robot Log onto your computer On your screen, click on the website labeled “castor bot” Your building instructions.
Find the Mindstorms Icon on the computer.. To start a new program click go.
LEGO® MINDSTORMS® NXT Move Block.
PROMGRAMING YOUR ROBOT How Servos Work: How to control your robot.
ROBOTC Software EV3 Robot Workshop
Vex Robotics Program Two: Using two motors. Program two: using the motors In the last section, you learned how to turn on one motor. Now, you will take.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
© ABB Entrelec AC 500 Page SD Memory Card Insert image here The Application of the SD Memory Card Advant Controller 500.
EV3 Programming: Moving and Turning CONFIDENTIAL © 2014 Cymer, LLC.
Lego Mindstorm Robots 9797 kit.  Students will learn how to identify how to detect a change in a condition.  Students will learn where and how to identify.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
Introduction to Robotics using Lego Mindstorms EV3 Shreya Reddy & Kiran Raja RoboAvatars Robotics.
Robotics Starter: Quiz Review
After Construction Name: Per #:.
EV3 Programming By Dianna de Matos.
How Do You Make a Program Wait?
Introduction to LEGO Mindstorms EV3 What is in the box?
LEGO Robotics Workshop
LEGO MINDSTORMS PROGRAMMING
Exploring Computer Science Lesson 6-5
Ozoblockly Lesson 03 Beginner Programs
Deriving Consistency from LEGOs
What you asked me to teach…
What Is an Electric Motor? How Does a Rotation Sensor Work?
Mindstorms EV3 Programming
Java on the LEGO Mindstorms EV3
Understanding Communication with a Robot? Activity (60 minutes)
Mindstorms EV3 Programming
Drill Translate the following message:
Lighting LEDs with a RASPBERRY PI
Classroom Digital Camera
Basics for Robotics Programming
Programming - Motion Intro to Robotics.
BEGINNER EV3 PROGRAMMING Lesson
BEGINNER PROGRAMMING LESSON
Mindstorms EV3 Programming
By Sanjay and Arvind Seshan
BEGINNER PROGRAMMING LESSON
Introduction to EV3Dev: Setup with Python
Automation and Robotics
Controlling YOUR ROBOT
Exploring Computer Science Lesson 6-5
Controlling your quadcopter
BEGINNER PROGRAMMING LESSON
Lesson 3: Sensor Wait-for’s Programming Solutions
Lego EV3 Mindstorms SW Programming Blocks.
Maze Challenge Maze Challenge activity > TeachEngineering.org
BEGINNER EV3 PROGRAMMING Lesson
Coding Edbot Dream with Scratch
RobotC Programming for LEGO Mindstorms NXT
Compiled from various Internet sources Presented by Mr. Hatfield
LEGO Education - Mindstorms EV3 - Computer/control center – The Brick
Getting started with LEGO EV3 Mindstorms software
BEGINNER PROGRAMMING LESSON
Downloading to the NXT requires the correct hardware setup
Controlling your quadcopter
LEGO MINDSTORMS NXT PROGRAMMING
Presentation transcript:

Module 2 Controlling a Lego EV3 Robot Python Programming Module 2 Controlling a Lego EV3 Robot Python Programming, 2/e

Download a Program Before you can run a Python program on your robot you must transfer the program file(s). Download the programs shortdrive.py and sensors.py from the Wikispaces page using the Chrome browser. Python Programming, 2/e

Startup EV3 Start up the EV3 brick with the ev3dev SD card inserted. Connect the EV3 brick to the Chromebook using the USB cable. Once the brick has booted into Brickman make sure that “gadget” is turned on in the tethering menu on the EV3 brick. Python Programming, 2/e

Copy the Program to EV3 Go to Linux on the Chromebook and open a terminal window. In the terminal window type the following: cd ~/Downloads Next type: scd shortdrive.py robot@192.168.0.1:. Enter the password: maker Repeat this copying sensors.py to the EV3. Python Programming, 2/e

Run the Program Next in the terminal window type: ssh robot@192.168.0.1 You can do this using the USB connection or using WiFi. The numbers will be different if you are using WiFi. Reenter the password: maker You can now run the program by typing: python3 shortdrive.py The robot should drive a short distance, turning to the right. Python Programming, 2/e

Run the Program Wirelessly Some robot programs work fine while using a USB cable, but if your robot is travelling a long distance you may want to run it wirelessly. You can connect to the robot using WiFi. In this case the IP number used to log into the robot will be different. You can run programs directly from the EV3 brick using Brickman. See the instructions on how to do this. Python Programming, 2/e

Plugging in Motors In order to use motors, they must be plugged into the output ports on the EV3 brick. The output ports are labeled A, B, C, and D on the brick. In these examples we will assume that two large motors are plugged into ports B and C. These will be the “Left motor” and the “Right motor” respectively. Python Programming, 2/e

Loading Libraries Let’s look at what is in the program file. Python is a general purpose language and was not designed with robots in mind. We need to load in modules that contain the bindings connect function calls to the motors. from ev3 import * from time import sleep Python Programming, 2/e

Naming the Motors Next we create a variable name for each motor. We will send messages to the motor using these names. #connect the motors motorLeft = LargeMotor('outB') motorRight = LargeMotor('outC') Since we have two Large Motors we must specify the port name of each. Python Programming, 2/e

Setting the Run Time The motors operate independently so we must set the run time for each of them. We do this by setting a parameter associate with each motor. #set the run time to 5 sec motorLeft.time_sp = 5000 motorRight.time_sp = 5000 Note the run time is in milliseconds Python Programming, 2/e

Set the Power Level Next we set the power level for each motor. Generally this corresponds to speed, but the is a different mode where speed is directly measured and controlled. The values for this parameter range from -100 (100% backward) to 100 (100% forward). Python Programming, 2/e

Set the Power Level The power level can be different for each motor. This will cause the robot to turn. #set the power level for each motor #Right has more power #Robot turns left motorLeft.duty_cycle_sp = 75 motorRight.duty_cycle_sp = 100 Python Programming, 2/e

Run the Motors Now that we know the duration and power level for each motor, we are ready to run them. There are many options here, which we will discuss in a moment. #run the motors motorLeft.run_timed() motorRight.run_timed() Python Programming, 2/e

Wait for the Robot to Stop If the program ends then the motors will stop before the 5 seconds are up. We need to wait for the 5 seconds to end before quitting. #wait for the robot to stop sleep(5) Python Programming, 2/e

Timing Notice that we started the left motor before the right motor. The real world time between these two start times is too small to notice. Also notice that we can have multiple motors running at the same time. This is one advantage of Python over the Lego Software – it is easier to have the robot do two things at once. Python Programming, 2/e

Medium Motors In addition to Large Motors we also have Medium Motors. All of the motors are controlled in the same way except that when we name the motor we would use the following: m = MediumMotor(‘outA’) If your robot only has one Medium Motor you could use: m = MediumMotor() Python Programming, 2/e

Why Two Different Motors? Large Motor: Faster More overall power Medium Motor Slower Higher torque More precise control Python Programming, 2/e

Motor Commands There are several ways to control how long a motor runs. run_timed – run for time_sp milliseconds. run_forever – run until told to stop. run_stop – stop the motor. run_to_rel_pos – run the motor position_sp degrees. There are a few others, but this is a start. Python Programming, 2/e

Motor Parameters There are also several parameter you can set to determine how the motor behaves. time_sp – how long to run (milliseconds). duty_cycle_sp – how much power to use [-100, 100]. polarity – which direction is positive (‘normal’, ‘inversed’). position_sp – how many degrees to rotate. Python Programming, 2/e

Motor Parameters ramp_down-sp – as the motor approaches its goal, how long to slow down (milliseconds). ramp_up_sp – as the motor starts, how long to speed up (milliseconds). speed_regulation_enabled – vary the power to hold a constant speed (‘on’, ‘off’). speed_sp – how fast to go when using speed regulation (degrees per second). Python Programming, 2/e

Motor Parameters stop_command– how to stop: ‘coast’ – remove power and freely coast ‘brake’ – place a load on the motor to absorb energy and stop more quickly. ‘hold’ – after stopping actively try to hold position by using power to “fight” any attempt to move it. Python Programming, 2/e

Activities Experiment and see how close you can to having your robot do the following: Drive in a straight line forward 1 meter. Drive backward 1 meter. Spin in place (drive one wheel forward and the other backward). Turn 90 degrees. Python Programming, 2/e