Lego EV3 using a Gyro to drive in a straight line #FLL

At our FLL session yesterday one of our programmer’s was working out how to drive the robot in a straight line.  Thanks to one of Builderdude35’s tutorials she tried using the Gyro to drive in a straight line.

The video makes it seem so easy but when the robot drove it started going back and forth and then turning in a circle.  Frustrating.

Here is the code:

gyro_straight

We tried modifying the values but could not get the robot going in a straight line.

Connecting the robot via bluetooth allowed us to easily view the values as the robot ran.  The gyro values started fluctuating very quickly and got so large that the robot was making huge corrections.

One of the blue blocks is the data logger – this allows you to store the values from a sensor into a file so you can easily review it after the robot run.  Here is the code now:

gyro_datalog

Now a funny thing happened when the robot ran – it ran in a  straight line!  The only difference in the program is the data logging block.  My assumption is that the time that the EV3 brick needs to log the data allows the steering to correct.  I tried using a wait block for 0.1 s but that did nothing.  More testing is required.

Takeway

Use the gyro when you want to turn the robot a specific angle.  For driving in a straight line you can use the encoder sensors for the motors.  We are working on a program that we will try for that.

Advertisements

FLL Meeting agenda

I’ve really enjoyed working with the Riverside and Huntsville Public FLL teams.  In order to maximize our time together Here are the plans for Fridays meeting.

Monday – Thursday

Lego EV3 RobotTwo or three people ensure that the robot is built – remember we want dog gear attachments so that we can quickly modify based on the mission.  Sam suggested Lego Digital Designer be installed – he can share the plans for the robot he built for inspiration. http://ldd.lego.com/en-us/download

Research project – we need to ensure that we have an opportunity to present our research.  My suggestion is that a student formally request a meeting with the school Trustee for the last week of November – if we wait to book the meeting we may not get an opportunity before competition on December 9.  We need to wrap up our research of the problem and start researching potential solutions.

Thursday – Important!

Please plug in the lego robots and the laptops we use so they are ready to go!

Friday meeting

  • Start with the Core Values. Reflect on how someone on the team has demonstrated the Core Values.
  • Download the program you are working on from the Team Drive
  • Check the sensors at motors on the robot – be able to identify what item is plugged into what port.
  • Read the program you downloaded – do the ports match for each block to how you’ve wired your robot?
  • Upload the program to the robot, double-check the program name to ensure it is the one you are running.
  • Run the program – does it run as expected?  If so, what are the next steps you need the robot to perform.  Add the code and upload it for the next steps.
  • If the code does not run as expected, ‘trace’ the blocks as they are performed – which block is causing the change in behaviour?  Also check the following:
    • The position of the robot
    • Are you running the correct program?
    • Are the wires fully seated?
    • Are the wires plugged into the correct port?
    • When plugged in, examine port view – does the sensor display as the correct type of sensor?

Our goal for Friday is to position the robot so that it is at the mission location.  We need to then finalize the dog gear attachment so that the robot can complete the mission.

Our meeting is the same time (3:30 – 6:00).

Lego #ev3 programs that are useful for FLL – turning and using the lines on the the board

Robot Setup:

Program that uses the Gyro sensor – can turn the robot and stop when the robot turns a certain angle.

 

Using the Port View to determine what value to use for a black line

Program to stop robot when it reaches a black line