Skip to main content

Featured

Desktop Robotic Companion

 What’s up Tinker gang. I’m back with another update to my robotic experiments.  I’ve already created a pretty stable robotic companion, but now that this companion can travel, I don’t like it super close to me because of dust and dirt. I now want something near me as I’m working on my computer, and have found a pretty cool opensource project to start from.  You may know the project as Emo on YouTube, this humanoid desktop robot rotates its body and arms , as well as displays facial animations thanks to its tiny face screen. I liked the concept and wanted to play with the designs. First, I wanted to add a way for the device to have extra gpio hats. The original design tucks the computer inside the body shell but I needed room for a microphone and any other thing I wanted to add. I thought about a few possibilities, including some kind of backpack (which I still may use later) on the bot but I didn’t like my mental designs. Instead, I decided to increase the height of the base and add

Tips on Troubleshooting errors in your python programs

In order to program effectively, it’s helpful to be good at troubleshooting. Asking for help is definitely a must, but only after you’ve taken a few steps.

  • Check all names are the same for variables class names and methods.
    • Typos are probably the most common error. What I usually do is search for variables or highlight them(via some code editor) and check all areas to make sure they all have highlights where expected. Example Python error:

                  test = “Hello world!”

                  print(tes) <-- Error

        Should be --> print(test)

  • Check all punctuation and syntax is accurate
                    if "hello" in test   <-- Error, wheres the ":" ?

                         print(test) 

        Should be --> if "Hello" in test:

  • Add print statement comments(like the code above for "Hello world!") in each section of your code in order to identify the cause of an error. Basically your code will run until the error, so the comments act like bread crumbs leading you to the section that doesn’t print the test message. 

  • Another way of printing a breadcrumb, that is a little more informative is to use inspect and spit out the function containing the error. First you "import inspect" near the top of the file, then later in a try/except block you would replace your except portion with 
                          except Exception as e:
                                     print("An error in function : " + inspect.stack()[0][3])
                                     print(e)

            which will print out the culprit function as well as the error message.

  • Going inside 3rd party code to follow the bread crumbs to actual error
    • Sometimes you are utilizing opensource code in order to get things done faster. This is often an easy solution except for the case where you have downloaded unkept code. What this means is that the language you are using now has been updated and most likely deprecating some of the unkept code. The code you imported from github for example, may not work now, as the language version for that software may have been 3.6, but the language of your compiler has been updated to 4.0. 
    • In order to resolve issues such as these, you'll have to try running the program and follow each error, fixing them one by one, file by file. This would involve changing methods etc to the new language features.

  • Take a break
    • Sometimes the best solution for resolving errors is a break. Maybe even some sleep. Walking away for as little as 30 minutes can make a world of difference. Looking so intently line by line, character by character can become taxing. 


  • Stackoverflow
    •          When I paste errors into google, the first post is usually stackoverflow. Which is a genius site for troubleshooting programming errors. Code errors are posted as questions, and are answered from all types of people all over the world. The answers to the questions are ranked and updated, making it a great resource.


  • Google
    •       Paste a small subset or all of the error into google and check each link until you find a solution. Usually along the way you pick up more keywords and jargon specific to the issue you're having. I usually paste the new jargon into subsequent searches.


  • Blogs like this one :).
    •      As you create things I highly recommend starting a file with notes. Although a little time consuming, your procedural notes could save you and others tremendous amounts of time.


  • Reddit, Forums and Threads are also good resources.


  • Incompatibility-hardware
    • While importing and downloading code, make sure it is compatible with your operating system or the operating system of the end product.

         


Comments

Popular Posts