LEGO MindstormsEV3

alt text

Table of Contents

Sensor Information



https://www.mathworks.com/help/supportpkg/legomindstormsev3io/ref/readcolor.html

// How to start with automatic detection

https://education.lego.com/en-us/lessons/mindstorms-ev3/object-detection#Planitem2

//How to run the code

https://makecode.mindstorms.com/reference/sensors/ultrasonic/on-event

//set up collision alarm

https://www.mathworks.com/help/supportpkg/legomindstormsev3io/examples/build-a-collision-alarm-using-the-ev3-ultrasonic-sensor.html

! To move the robot straight forward Motor B is 3 less power than A

LEGO EV3 MATLAB Documentation


alt text

You can find all current MATLAB documentation for the LEGO EV3 utility files implemented in this class at the following this

You may also find the following files useful for programming your robot:

Connect to MindstormsEV3


Make sure that your robot has a battery and is turned on and that the battery is connected

In addition to making sure the robots bluetooth is on as well as the device you are connected to

  1. On windows or mac, navigate to your bluetooth settings and set-up a new device
  2. Locate the name of your ev3 power brick (found at the top of the brick screen)
  3. Connect
  4. Once connected you will be prompted for a code, refer to your robot
  5. Input code
  6. Open “ConnectToEV3.m” file

In ConnectToEV3, run the program and it should connect MATLAB to the robot as well as play a sound and display the battery power

Congratulations

Your MindstormsEV3 robot should now be setup

Sensor Files


The first file to test the sensor is touchSwitch which was used to test the touch Sensor

colorSensor

Ultrasonic

Test Key Control


This file tests the use of the key controls and using the keyboard to control the robot

Autonomous Control


Learning autonomous control was one of the most challenging parts of this Mindstorms EV3 project

Working on the While loops was a struggle as we knew what we wanted the robot to do, but we were telling it to do something else. Lot’s of extra work was needed to be put into the robot to allow it to run on it’s own

How to run your Robot Autonomously (Like a Roomba)

  1. Make sure that you load ConnectToEV3
  2. Once done locate the Main.m file within the automation folder
  3. Press F5 on the program, or just run within the view tab
  4. On the pop-up window press the ‘up-arrow’ on your keyboard to start

Challenge with the While Loop


# MATLAB

global key;
InitKeyboard();

startMoving = 0;

while 1
    pause(0.1);
    distance = brick.UltrasonicDist(3);

    switch key

        case 'uparrow' % on the up arrow, the auto-driving will begin

            while(startMoving == 0)

                distance = brick.UltrasonicDist(3);

                if (distance > 15)

                    brick.MoveMotor('A', 50);
                    brick.MoveMotor('B', 47);
                    numRightTurns = 0;
                    numLeftTurns = 0;

                    distance = brick.UltrasonicDist(3);

                elseif (distance < 15)

                    % turn left

                    brick.MoveMotor('A', 27);
                    brick.MoveMotor('B', -27);
                    pause(0.875);
                    brick.StopMotor('A');
                    brick.StopMotor('B');
                    numLeftTurns = 1;

                    distance = brick.UltrasonicDist(3);
                    disp(distance);

                end
            end

        end
    end
end

Our MindstormsEV3 Mission


So what are we trying to do?:

  1. Our first goal in this project was to learn how to work as a team and accomplish the task of delegating our mission within the group
  2. After this, we had people design the robot, work through a gantt chart and learn the MATLAB Documentation
  3. Our first goal and milestone was getting the robot to work through remote control. This was not too difficult and was good for the team as we had to make small design changes as we learned how the sensors worked
  4. From here, the group made many small design changes but ultimately led towards our final design of the robot which would be used for our autonomous control of the robot

Our Goal

How Did we Achieve this Goal?

Final Rubric

Meet the Team


Eric Wu

Jordan Post

Mark Ashinhust

Sammy Arenson

December 1st Update


The main trouble working through the autonomous driving robot was getting it to be able to drive forward without any assistance. Though this was not completely achieved, manual intervention is still not necessary.

Next Updates

  1. Implement stopping on green and trying to pick up person in wheel chair
  2. Maintain turning and driving straight capabilities
  3. A way to detect when the robot has been moving against a wall
  4. What to do when the color on the ground is blue?
  5. implementations
  6. December 5th Final Demonstration

December 3rd Update


Functionality for the robot works when moving straight and turning. However, trouble was hit when turning towards a wall and there were no sensors to calculate for these differences. Therefore, I engineered some touch sensors on the front right and front left of the robot to detect when the robot hits a wall and it will back up and turn slightly in the opposite direction of the wall.

Next Update

  1. What to do when the robot reaches a blue tile
  2. What to do when the robot reaches a green tile? Move to remote control?
  3. How do we implement the robot to get through the maze when there are certain obstacles?
  4. Can our robot pick up the wheel-chair

December 4th Update


Robot works as well as it can with the information provided. Can get through most of the maze without instruction but needs some help. May achieve a good score, however the robot will not be fully Autonomous.

_Demonstration Day_


The main rules of the course were a little difficult in the final go of the robot, however, we were able to successfully get the robot through the course having a drop off and pick up point. Our robot did not work in a fully autonomous style, however, it did go through at least 1/3 of the course in an autonomous style. Videos and pictures will be updated soon.

TOP