This week's main goal was to get the Arduino to transmit the python data in order to move the servos. This topic was researched on a daily basis to figure out why, not only the transmitting light was not flashing, but the servos weren't moving at all. After coming to no conclusion, with many forums stating that the wiring could be an issue, or maybe there is an issue with the code, nothing was successful in getting the servos to move with the program.
After researching and not being able to find anything, I reached out to Neil Bishop, his idea was that maybe the board may have an issue. Taking this into consideration, the board was swapped out for another board that was available to test the theory, changing the board did not do anything. Note that the board that we swapped for was an Arduino Uno, thinking that perhaps the Arduino Mega might have an issue altogether. This did not work and Neil was at a loss as to why the motors weren't turning, because the code didn't seem to have any problems.
The next person that we reached out to was Khon Duong, a Laboratory Assistant in the programming lab. He brought up multiple points that he thought could be the issue as to why the motors aren't moving, one major point that he made was that perhaps the conversion of the angle between the python program and the Arduino are not lining up and that could be the cause of the issue. I looked into this online, to see if I could find anything on angle conversion between python and Arduino and did not find anything very useful. Due to his lack of experience using Arduino, Khon wasn't able to provide any more idea as to how we can get the program functioning.
At the point of not know why the programs aren't communication correctly and being unable to find help that produced fruitful results, I went back to the thinking board on how else we can get the code working. I spent some time online and that is when I saw a forum stating that using binary values to control servo motors is an easier method of controlling them. I decided to try this idea and send binary values to the Arduino instead of angles. This essentially means that instead of the python code constantly sending values to the Arduino, it will simply be looking for whether the finger is up or not and send a corresponding 1 or 0 to the Arduino which will then rotate the motors.
This also means that I had to go back and edit both the python and Arduino code in order to bring this new method to fruition. Since we only have the hand set up at the moment, the output of the python code will be a value between 00000 and 11111 with each bit representing a finger.
In order to execute this ides, we had to refer back to the landmark points found throughout Mediapipe's resources. We used a basic if-else statement that will compare the tip of the finger to the joint connecting the finger and palm to determine whether the finger is up or down.
![](https://static.wixstatic.com/media/cfd036_696f996a3b0a4931ac8478fa3dfa1e42~mv2.jpg/v1/fill/w_980,h_1078,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/cfd036_696f996a3b0a4931ac8478fa3dfa1e42~mv2.jpg)
Since python's OpenCV and Mediapipe capabilities makes it possible to track the position of the landmark points, the logic behind the code is that is the tip of the finger's value falls below that of the joint, the program will interpret that as the finger being down and will produce a 0, a 1 will be used to represent the finger being in the up position.
See below:
![](https://static.wixstatic.com/media/cfd036_cbaec5e741b944db81e8e4656edf40c2~mv2.png/v1/fill/w_402,h_50,al_c,q_85,enc_auto/cfd036_cbaec5e741b944db81e8e4656edf40c2~mv2.png)
The Arduino will then take that value of 1 or 0 and rotate the corresponding motor a value of 360 degrees (that is what the code currently states, but can be changed).
![](https://static.wixstatic.com/media/cfd036_f625fa9b1c374f7d90fed14383bb8c43~mv2.png/v1/fill/w_345,h_130,al_c,q_85,enc_auto/cfd036_f625fa9b1c374f7d90fed14383bb8c43~mv2.png)
Once both scripts were compiling with no errors, it was put to the test and the Arduino code was sent to the board and we ran the python program to monitor the results. It took a couple of tries when it came to wiring to get it set up, but once everything was set up, we were able to get the servo motors moving with the python code.
Further down this post is a video containing the visual results of what the two programs did together. Unfortunately, we will have to go back and look at the servo motors once again, because as we were testing the code with the arm, we were able to see the servo motors trying to move, but not moving to the full 360 degrees in order to bend the fingers up and down as expected. As I moved my fingers in front of the camera, I was able to get the corresponding motors to move and although it didn't move enough to fully bend the fingers, it is a step further than last week.
To conclude this weeks work, due to the difficulty of figuring our why the Arduino was not taking the angle inputs from the python program, we asked a few people and although they had very valid though processes, it did not help to get the motors moving, we then decided to try sending binary digits to the Arduino instead and that worked to get the motors moving.
The plan for next week is to think about how the wrist and elbow will now be incorporated if we decide to move forward with sending binary digits instead of angles to the Arduino and also continue to work on getting a better result with the hand in terms of finger motion.
The video of this week's work results is below:
Comments