ENED 1120 Robot Simulation

Last updated on

Project overview

The repository encompasses all the deliverables of the ENED 1120 - Engineering and Design Thinking - Spring 2020 Robot simulation project. The project’s objectives is: There are random boxes, each with their own barcode, spread across 16 shelves on the area; given a barcode input, the robot must scan the whole arena until it picks up the box with the right code.

Project deliverables include:

Inspiration

The project is part of the course ENED 1120. I worked together in a team of 4 over 10 weeks to construct a simple version of an automonous robot that can scan barcodes and pick boxes without human intervention. The hardware of the robot is made from LEGO blocks and the software would be code written in Python.

Initially, the code was embeded into the LEGO Mindstorm EV3, directly controlling the robot’s motors and sensors so that the robot would then be demonstrated in the university hall. However, after the mid-term demonstration, Covid-19 hit and lock-down instituted. Therfore, for the final demonstration, we had changed to write a simulation program instead, using shapes and graphs to simulate how the robot should move and work.

How I built it

For the mid-term demonstration, we used the library ev3dev2 to interface Python with the robot’s sensors and motors. The task at hand was to make the robot able to move straight and turn 180 degrees. We wrote multiple functions to make my code more concise and composeable so that I didn’t need to repeat complex logic.

For the final demonstration, we used the library matplotlib to draw shapes that represent my robot and the area, and continuously update the graph with new positions of the rectangles to show how our robot would move. The goal is to develop logic of the robot not only moving, but also picking up randomized boxes locations while avoiding road obstacles

Graphs with rectangles and circles

Demonstration GIF

Challenges

The first challenge was getting the robot to go straight. Possibly due to imperfect equipments, simple approaches such as putting both left and right motors to same powers, or using a simple read of the gyro sensor to steer the wheel back when the angle is too large did not work. Therefore, we had to research and eventually choose a the more advanced PID algorithm Correction = Error * Kp + Integral * Ki + Deriative * Kd. The difficult part of the PID algorithm is find the suitable Kp, Ki, and Kd values that suits our robot’s weight distribution and thus making the robot go straight. After hours of testing different set of values, we found the set of values that make the robot goes straight the most is (Kp = -0.149495; Ki = -0.0001; Kd = 0)

Another technical challenge was our barcode-scaning algorithm. In our initial algorithm, since our robot moves 4 units of distance a time, when it encounters a box, its goes backwards a little bit until it reaches the start of the current box, and then start scanning the barcode forward from there. However, if multiple boxes are adjacent, the robot might move backwards to much, leading to wrong reading and even infinite loops. Therefore, we had to change our barcode scanning algorithm to account for this case by keep track of the number of back steps the robot made to see if it has encountered the “adjacent boxes” scenario, so that the robot can move the correct amount of distance even if adjacent boxes cover its light sensor. More details can be found on our Engineering Notebook - page 31.

Accomplishments that I’m proud of

I am really proud of all Object-Orientated Programming code I was able to apply to the project. OOP is a piece of knowledge that I had endeavored to learn in my free time outside of the school curriculum, and knowing and using OOP really helped me manage the complexity of all the different parts of my program, allowing me to compose complex codes easily and develop great animation that really made my team stand out from the rest ✨. Seeing the effort of my learning paying huge dividends just truly made me proud and happy.

I am also proud of how our team worked so well and smooth thanks to all the project management tools and techniques that we learned and took took seriously. We had regular meetings with clear agendas beforehand and concrete set of tasks afterwards. Our discussions were constructive and we were able to leverage the strengths of each team member to progress all the different sub-goals really quickly. At the end of the course, we were ahead of the suggested schedule by two weeks, and have had many important milestones done before Covid hits, which really eased our work (and mind) going to the pandemic. Really proid and happy that I was able to work with my amazing teammates.

What I learned