Robotics | Final Project Reflection

Throughout this project, I’ve utilized many programming skills to achieve a robot dance synced to the tune of the song, “Eye of the Tiger.” The project has taught me a lot about programming, problem-solving, and working together as a team.

 

There were many new programming concepts taught for this project. We learned about while loops, which allow us to loop a portion of code consecutively. We learned about functions, which allow us to call a set portion of code at any time. Personally, I used functions repeatedly in my code. I used them far more than while loops, because the song I chose is not very regular. With a function, the programmer can define integers, and modify values within the function itself. Functions are very useful for condensing code, my code would have been significantly longer without them.

To define a function, you need to write “void functionname()” and {} will contain the code of the function. You can then call the function at any time by simply writing the name of the function followed by (); In the round parentheses, you can put an integer if you’d like.

An example of a function (stop) with an integer (time):

 

Syncing the robot’s dance to the music was quite a complicated task. At first, I tried to count the seconds of specific parts of the song, and using the Youtube video’s progress. For example, the first move I wanted my robot to initiate began after eight seconds of the song, so I made sure my robot was stationary for 8000 milliseconds. Despite this, I found 9000 milliseconds (9 seconds) to work better in my code, so actually using the precise measurements was a somewhat ineffective strategy.

Using this strategy was a good starting point, but I found trial and error to be far more effective. With the help of virtual worlds, I repeated dance moves over and over until I got the timing to a level in which I was satisfied with. For trial and error, I would put in my closest estimate, try it out, and adjust the value depending on how the timing was.

Another factor that disrupted my timing was the power of the motors on the physical robots. Due to the age and use of the robots/parts we used, our actual robots were not as powerful as the one in the virtual world. An example of this is when my robot wouldn’t move as far in the real world as the virtual world, or it wouldn’t turn as quickly. The motors, battery, and several other parts all worked less well than in the virtual world, so I had to adjust my code to accommodate this.

One thing that really messed with my entire dance was when I was informed of the size of our area. My robot’s dance relied on a large, open space, so when I learned of our restrictions, I was forced to change my code.

 

I really like some of the moves I accomplished with my robot. It definitely works better in virtual worlds, because the motors on the physical robot are old, and they don’t work as well as they should. The beginning part (the shuffling to the beat of the song) was incredibly satisfying to get in sync. Though some may think it repetitive, I personally think this is one of the strongest parts of my entire dance. Another original move is when I have the robot’s arm go up when the singer says “rising up.” I thought it was quite clever, and watching it move in sync with the music after all of the work it took was very satisfying.

 

I think the greatest strength I demonstrated in this project was not programming-based at all. This skill I demonstrated was good teamwork. When others were struggling with their robots, I would take considerable time away from my own project in order to help my peers. If someone was struggling with understanding a concept, I tried to explain it to them. If someone was unsure about an unexpected outcome from their code, I would help troubleshoot, and then suggest various solutions. If a robot was unstable, a screw loose, a motor unplugged, a wire jammed, I’d usually be offering my advice to my peers. There were also times where I struggled, and I had many friends to turn to. I also asked for help, and received it, from my peers. This project may have been a test of our programming skills, but it brought out a collaborative nature in the class.

Robotics | Final Project Progress Update

How much have you done so far?

So far I have around 50 seconds of the dance done. I have a good plan of what I want to do next with my robot, and I’ve synced the completed 50 seconds quite well. The robot shuffles left and right to the sounds of the song, “Eye of the Tiger.” It performs quick swing turns for the beginning sequence corresponding to the quick parts, and does a long swing turn for the longer sections.

 

What are the different programming techniques that you used? Are you using any sensors?

I am not currently using any sensors, and due to the fact that we haven’t been taught how to use them, I don’t see myself using them in the future. The most useful technique I used was functions. It saved me a lot of time, as I didn’t have to repeat the same code over and over. I was able to make my robot do the same amount of actions in far fewer lines of code.

Using a function like one of these:

 

I can condense what would be the same three lines of code repeated constantly to this:

Although this also looks quite repetitive, it would have been at least three times as long had I not used functions. With these functions, I use an integer in the circle parentheses for the variable of time. I could have condensed my functions within another function, however I personally preferred to list them in this way because the song’s notes are not always in a linear pattern (this is why the numbers are of different values).

 

How do you tackle the sync issue?

Syncing the robot’s dance to the song is perhaps the most difficult parts of this project. To start, it is good to get a general idea of when you want your robot to perform the move. In my case, the first action I wanted my robot to perform was around eight seconds in to the song.

Although using the actual millisecond values for parts of the song is effective, it can sometimes be hard, especially if the song is very complicated. Once you get a general idea of the location in time that you want your move to be performed, it really comes down to trial and error. I listed 8000 milliseconds (8 seconds) at first, but after trying if a few times, I found that it synced better with 9000 milliseconds (9 seconds). It would be very unpractical to do trial and error on an actual robot, so I spent a lot of time in virtual worlds.

 

Any other challenges you encountered during the development process?

Despite my success in the virtual world, I am still unable to get my code to work with an actual robot. I spent an entire lesson trying different robots with my code, and I came to the conclusion that there was a problem with all of the batteries that I tried using. To fix this issue, I need a robot that is guaranteed to work, one that I know has absolutely no problems with its motors, cortex, or battery.

 

 

Robotics | Functions

Today, I was extremely excited to pick one of my favorite songs of all time for my robot to dance to, however, my song was rejected as “too controversial,” despite it being the national anthem of a country >:(

 

I also learned how to use functions. I got my robot to shuffle in virtual worlds, and I’m going to make it move to the beat of “Eye of the Tiger.”

Robotics | Robotics Choreography

I still haven’t decided what songs to choose, but I have some move ideas. I’m thinking that I can make the robot move across the room, and wave its arm up and down. I might even make the robot move on the spot as well. I think I could probably make the robot move in a zigzag pattern to the beat of the song. If possible, I’d like to get LED lights working on the robot. Also, maybe I’d add to my robot to give it more parts (moving or sensors), to find more combinations of moving parts that my robot could utilize. Maybe for a certain part of the song, I’ll have the robot go backwards. I’ll try to include both point turns and swerve turns.

I will probably choose the song “Eye of the Tiger” as my song.

Robotics | Unit 2 Reflection

What was this challenge about?

This challenge was about programming our robots to traverse a course. We did this through the use of a new tool that we had previously not used known as “shaft encoders.” Initially, I believed that this would be a simple challenge, however, through the many, many technical difficulties we faced, I learned that making the correct code is only half of the battle.

A shaft encoder

What did you know before the working on the challenge?

We knew basic movement and motion commands in RobotC for our robots, however, we mostly used virtual worlds instead of a real robot, as we were quite inexperienced. We also knew a vague definition of what a shaft encoder is, but we never tried using one at all. Before this challenge, we hadn’t done too much with our robots, so we didn’t see too many technical difficulties.

A screenshot of an older version of virtual worlds on RobotC

 

What are the technical difficulties for completing the challenge? List them out and explain why they are difficult.

During this challenge, we faced many technical difficulties. In fact, we probably spent more time trying to fix technical difficulties than we did actually working on the challenge. Some of them include: the shaft encoders not registering, the firmware not updating properly, one motor going faster than the other, motors not working, batteries not working, and wires getting tangled/removed our robot. These are just a few of the many technical difficulties we faced, and they were difficult because the time we spent trying to fix these could have been spent on actually doing the challenge, which left us with less time to work on the program itself. Many of these problems required us to literally take apart our robots to replace the parts with new ones. We spent entire lessons simply surveying the class to see if other people were having the same problems as us, and trying to narrow down the cause of said problem.

One of the many errors we faced was a firmware issue, there should only be one light on.

Describe the approach(es) (e.g. time vs shaft encoder) you tried throughout the problem solving process.

To get our measurements as precise as possible, my team used mathematics to solve for the values required for the robot to go certain distances and to turn certain angles. We found the distance that the robot would move after one full rotation of the shaft encoder (it was 35 cm). We then found the full length of the portion we were using (with measuring tape), and divided it by the distance of one rotation to find the amount of rotations needed for the specific distance (8.4 rotations). Using this number, we found the number of rotations required to get through a specific distance by multiplying it by 360. For angles, we did the same process. We found the required value for a 90° turn, and used this ratio to solve the angles required. To get the angles in the first place, we used a protractor.

In the end, our mathematics did not work flawlessly. It was very close, but due to age from the motors and/or shaft encoders, the mathematically accurate values did not work perfectly. This led to us using trial and error, slightly adjusting values and testing repeatedly until we got a good enough demonstration.

Some of the calculations we used to solve our distances and angles.

Did you use the virtual world to test your program? Was it useful?

No, we tested with our actual robot. Virtual worlds would have been good for testing, however, as I mentioned earlier, some of the motors are old, and there are natural errors that can happen in the real world that are not possible to be recreated in the virtual world.

What have you learnt in the process? Any new insight?

I learned a lot about how to use VEX robots and RobotC, and I’ve learned a lot about good troubleshooting methods. Some of the methods I used could have been more effective, and I now know that. For example, if I had double-checked the motor and sensor setup from the start, I could have saved time replacing parts that could have possibly been working properly. Overall, I’ve learned a lot about troubleshooting, as well as how to use VEX robots in person, and on the computer with RobotC.

My Video

Robotics | Performing Task (almost completed)

After slight problems last lesson, my teammate and I were able to finally get our shaft encoders to work perfectly. We also fixed all other issues with our robot and our computer. Now, our goal was to traverse the course set before us. We went about doing this by using mathematics, division, and trial and error to determine the correct values to set in our code in order to make the robot move the required distance. We used measuring tape to find the length of each section. Then, we calculated the distance our robot would move when we set the axle rotation to 360. Then we found the length of the portion divided by the length of 360 rotations, and then we multiplied this number by 360. This was done to find the amount of rotations required for the beginning area. However, due to age or human error, the robot was unable to reach this point using our calculated value, so we resorted to trial and error.

 

For turns, we used a protractor to get the exact angle required. We also found the amount of rotations required for a 90 degree turn. Using a ratio of number of rotations divided by 90 degrees, we were able to calculate the number of rotations for a specific angle (found with the protractor). Despite age/human error, our turns worked very well. All we need to do is some last minute adjustments to our distances (which we are still testing) and we should be good to go for the entire course.

 

Some of our math we did to calculate the values required (not all of it worked):

Robotics | Programming Robot to Track Continued

In this class, all of our robots were broken, however we learned valuable lessons/skills about fixing and debugging robots. We also learned about problem solving, and through trial and error we were able to learn how to find and solve the problems. In the end, we did not solve the problem, but we made many theories and hypotheses as to why they wouldn’t work. We also learned a great lesson about teamwork, and how after working together we were able to progress our problem solving faster. 🙂 🙂

Robotics | Programming Robot to Track

There are/were many problems with our robot, so we spent the lesson guessing and checking speeds. Our shaft encoders are broken, so we ended up programming the robot to move using the motor speed and time. After many technical glitches and problems, we ended up solving them, and making our robot move along the length desired.

Robotics | Shaft Encoder Investigation

What is a shaft encoder?

A shaft encoder is a device used among VEX parts to count the amount of rotations on a connected shaft/axle. It is also referred to as a rotation sensor.

 

How does it work?

The encoder starts with a value of 0, and it goes to 360 depending on the amount of rotation. It also goes down depending on the direction.

 

How do we code it in RobotC?

You need to have some code to configure the sensors, but it is written automatically when the sensors are connected/when you load the sample program. You then have to make a while loop for the encoder to record.

 

Why is it better to use a shaft encoder?

Without it, you can’t make precise movements tuned to the amount of rotations an axle would make. You’d have to guess using the speed and time.