My Journey with Failures (Microprocessor Project Edition)
Tags: learning, showdev, motivation
Published: 2023-09-01 23:30:13

## فشلى فى مشروع المايكرو 

LinkedIn is often filled with success stories, achievements, and positivity. However, I believe that failure is the first step to success.  

Over the past few months, I've come to realize that failure, the stumbling block that seems to close doors, is actually the pathway to discovering new opportunities and creativity.

With this in mind, I've decided to kick off a series of posts where I'll discuss my failures – instances where I didn't necessarily reach a solution or succeed.

> It's my attempt to express gratitude for my failures, the ones that I often curse and yet endure. 

> محاولة مني بسيطة لشكر فشلي اللي دايما بشتمه ومع ذلك مستحملني 

Let's dive into my journey by starting with a significant experience from my college semester – the Microprocessor Project.

## The Epic Microprocessor Project

[Briefly, the project was a robot game competition between teams. The robots should play each other in 5 games (maze - darts - ball collecting - shooting - defending goal <goalkeeper>)]

My team was in charge of the Ball Collecting Game. In this game, a robot had to pick up either red or blue balls, but it would get in trouble if it picked the wrong color. The robot also had to come back to a specific spot within four minutes.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ch3jku0q91vgzgxpj39i.png)



The project's problems seemed to have a life of their own, tangled up in a web that had nothing to do with the project itself.

كانت الدروس المستفادة من المشروع كثيرة، ولكن الأهم منها كان أني أدركت

> أن وجود حلاً لمشكلة لا يعني بالضرورة حل المشكلة نفسها

أصبح واضحً ليا أن بعض المشاكل ممكن تتفكك وتكشف مشكاكل جديدة تمامًا

حقيقة جزء مني كان خايف يبدأ بحكاية المشروع ده فمعرفش اعبر عنه 😂 

Nevertheless, I would like to discuss how I learned from my failures, both those that preceded the project and those that occurred during it.

---

## 1. First Failure: I Failed to Recognize Some of My Stumbling Blocks 

فشلت في ادراك ان ليه مضغوطة/مزنوقة/مش لاقية حل 

### Health

صحتي كانت بنسبالي الاجابة البعيدة جدا للسؤال 

But the project was an exception; as it was very dynamic (compared to the software projects that I used to)

المشروع كان في مشواير بتتعمل وحركة ونزول علي الارض وشيل 

This eventually resulted in chronic pain in my back and knees, which I hadn't considered in terms of my health back then.

But the stress that comes from the pains led to wrong decisions led to more stress.

🥲 

Thankfully, I've come to recognize the importance of prioritizing my health, and I now make more efforts to take better care of myself.

 

### Slowness toward taking action

وتاني السبب كان الأنجاز 

انا بعد المشروع ده سرعة انجازي علي ما اعتقد اضربت في اتنين 

This project, with its numerous potential failures and experiments, required quick thinking and a faster assessment of risks. It pushed me beyond the boundaries of what I was accustomed to.

ولأن أن وقت المشروع الواحد متقسم علي خمس تيمات مش تيم واحد

(as there are 5 sub-teams that should do different things inside the main team with only one robot)  

(🫠)

## 2. Failed to understand wheels (Wheels, Ya Wheels!)

مشاكل العجل بدأت معانا من بدري  

وتقريبا مسمعتمش عن تيم محكاش عن العجل ومشاكله 

المشروع كان كبير كحجم روبوت فكان في مشاكل كتير بخصوص العجل و حركة الروبوت

### Explain My Team's problem with wheels 

Our initial wooden base robot was too thin as the thickness (as far as I remember) was 5mm, causing it to tilt slightly under load. Additionally, not everything was placed in the optimal position. This imbalance stopped the robot from spinning around itself properly.

For the robot to move as intended, the right wheels needed to move in the opposite direction of the left wheels, or vice versa.

Due to the varying weight distribution among the wheels, the robot didn't spin as expected. Instead, it moved with a twist, and sometimes failed to move in a straight line.

First, we addressed this issue by adding a support wheel in coordinates that provided assistance to the weaker wheels through experimentation, as their positions changed periodically.

We also suspected that friction existed between the wheels and the robot chassis. (I broke some of the chassis to create a breathable area between them) <I explained it in detail as this process was tough on my back and made it hurt for a few days.>

We ended up changing the entire base of the robot just two days before the deadline 

Initially, everything seemed to be working fine. However, we eventually realized that there might be a noise issue with the wires of the wheels' drivers (not entirely sure). 🥹

It's funny because if we stopped one wheel, the other would stop too.

 “Sadly or <u>thankfully</u> we <u>didn’t have the time</u>  to determine the exact cause of the problem. Although we suspected the drivers and even replaced them, But the problem kept going.” 

 

## Third Problem (Scanning The Field)

Since I started this conversation with the theme of creativity and failure, I aimed to make the last problem be solved by a creative idea.

One of the tasks in Ball Collecting is to scan the field and collect blue balls.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q00nijklw8xzdv24dlcf.jpeg)



In this paragraph, I will discuss the different ideas and challenges we encountered on our journey towards the final result (which turned out to be a failure).

### First idea (expensive sensor)

We began by using a sensor to achieve Dead reckoning (it's a process for calculating exactly your position by using your previous position) 

I'm not sure why I insisted at that time on using the (MPU 9250) sensor, which was quite expensive, even though there was a cheaper sensor with similar capabilities. I recall having reasons <other than انفخ the project's budget> 

Let's focus on the key points. The sensor calculates three things: 

1. Acceleration 

2. Angular velocity 

3. Magnetic inclination 

The sensor could be communicated with using both I2C and SPI communication protocols.

Summarizing three challenging days with no sleep: The sensor was extremely sensitive to noise. At times, I had to move my laptop and mobile devices away to obtain measurements that somewhat made sense.

Funny thing, I insisted on the project manager that we should purchase this sensor. I had watched a video, which (in my opinion) had the most silly and frustrating intro that took up 90% of the video so I decided to ignore it;  At the end of the video mentioned the summary of all my suffering that it's impossible to achieve (Dead reckoning) using MPU :sad

Here's a link to the video; I challenge you to watch it until the end:

{% embed https://www.youtube.com/watch?v=pbxJAuhFizg %}

Nevertheless, I didn't give up. I had a suspicion that the sensor was defective when we purchased it. So, I attempted to run a ROS program on it to simulate the sensor's movement. Unfortunately, this ended up damaging the sensor (I believe only the I2C was the only thing affected, but I didn't attempt further testing).

### Second Idea (A Stupid Ultrasonic)

IDK who came up with this rather silly idea 🙄. In my defense :

> يأننا كنا في عرض اي فكرة

Here's a simplified explanation of the idea: The field was enclosed by a wall, and we knew the precise dimensions between the balls and the wall.

The concept was to initiate rotation when the distance between the robot and the wall was 10 cm. As the distance increased and then decreased, it would signal the completion of half a 45-degree revolution. Then, the robot would start rotating again to reach 90 degrees and begin scanning the next line, and so on.

I don't need to tell you that this approach failed miserably جداااا 🤣 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l4sjvf10rvglk4rydlz.jpeg)

The outcome:

At that moment, we had no idea whether the robot was heading toward the stairs 

{% embed https://youtube.com/shorts/PsyR3RMX-e4 %}

### The Third And Successful Solution 

(Thankfully, the only approach that worked perfectly) 

We decided to utilize the IMU sensor inside a smartphone. Since we were already using the phone's camera to detect the color of the balls,

(it only measures rotation correctly)  

I'll let your eyes enjoy the perfect 90 degrees 

{% embed https://www.youtube.com/watch?v=rdxAZHAzNME %}

 

### Final Note: Yet Another Failure

Last Note: it also failed, As the phone should be positioned at a 90-degree angle to measure the degree, Moreover the holder broke when we delivered the game.