Thursday 12 April 2018

Dinor3x

Dinor3x is a creation from Lego Mindstorms EV3 Fan robots which we attempted to program. This robot is a four legged robot. It starts walking as soon as it is powered on. When an object comes along its way (as detected by infrared sensor), it opens its mouth and acknowledges its presence. Please find the below code as well as a small video clip to see the performance of the robot.


This program consists of two classes. Dinor3x and OpenMouth. Let me explain the functionality of both the classes. Dinor3x is the class which has the main method. This method starts a thread OpenMouth. It also initializes both the large motors which control the legs of the Dinor3x. Based on the assembly of the Dinor3x, it looks like when I move the motors backwards, the Dinor3x moves forward. The Dinor3x moves forward, until ESCAPE button is un-pressed and the turnFlag is OFF (turnFlag represents the condition when there is an obstacle in front of the Dinor3x. I will explain it in detail while explaining the OpenMouth class). When the turnFlag is ON, that means when the Dinor3x mouth is open, both the large motors stop. As a result, the Dinor3x stops. 

Let's talk about the OpenMouth class now. Based on the assembly of the robot, we know that the medium motor controls the opening and closing action of the mouth. Also, the IR sensor in the front part of the Dinor3x activates the opening and closing action of the mouth. When we keep an obstacle (our hand) in the path of the robot, the IR sensor captures the presence of the obstacle. To capture this, the IR sensor has to be in Distance mode. The IR sensor then fetches a single sample of the distance (the distance of the obstacle in front of the robot). If this sample is of distance less than 20 cm, we make the Dinor3x open and close the mouth by moving the motor through 45 and -45 degrees respectively. If you carefully observe the movement of the mouth, the mouth quivers a little after closing. This phenomenon is achieved by rotating the medium motor through 2 and -2 degrees for 4 times. Once the object goes out of site, the medium motor is reinitialized to an angle of 45 degrees and the thread ends. 
 
Meanwhile, the turnFlag is turned on as soon as the object is sensed and it is turned off as soon as the object goes out of site (with more than 20cm distance). This is the same turnFlag which we use in the main method of Dinor3x class to stop the Dinor3x from walking when the object gets sensed.
 
      



We have also implemented the Dinor3x revolving around itself. The video of the revolving process is posted below. However, we have not posted the LeJOS code for the revolving Dinor3x. We suggest you to take this as an assignment. Believe us, it is going to be an interesting program! 





1 comment:

  1. Hi, just a quick note with your Java, the method Button.ESCAPE.isPressed does not exist, it should be !Button.ESCAPE.isDown instead.

    ReplyDelete