Documentation on Summer Projects and Progress
The goal for my group over the last two days was to port the EV3 AI Lessons 1-2 to the Spike Prime. Using the given Github Code for the EV3 Lessons, we started to convert the modules over to the Spike Prime. '
One of our initial issues with the system was deciding on an alternative for using the gyro control due to the fact that it is built into the Spike Prime Hub
Ultimately we decided that we were going to utilize the ultrasonic sensor instead in order to represent the two different commands.
The photos above show documentation of our build for Lesson 1 and 2. From left to right, we have Peter the Pug, the whole build setup, and the ultrasonic sensor testing mount. Once we completed the build we started to run into issues porting over the code.
The first hurdle we ran into was handling the two different modules that run the Spike. Since the EV3 AI code utilizes the buttons on the EV3, we had to use the hub module to get access to the top side hub buttons. This caused some initial issues with variable naming but after that it was smooth sailing integrating both modules.
The largest issue we encountered during this lesson so far is running the converted PuppyTraining.py file on the Spike Prime. A link to the master Github Lesson 1 can be seen below:
https://github.com/tuftsceeo/SPIKE_Prime_AI_Demos/tree/master/Lesson_1/Owen_and_Teo
In the Github folder, we have the three translated files: Lesson1.py, PuppyBasic.py, PuppyTraining.py. Although each file is able to compile onto the brick through the use of the REPL, the system ran into a continous MemoryError, that can be seen below.
After failing to figure out the initial issue, I ended up stepping back and removed all non __init__ methods from both of the imported PuppyBasic and PuppyTraining. After simplifying, I was able to compile and fully import both classes in the main Lesson1.py file but after adding more methods, the memory allocation error appeared again.
After searching around the internet to try to find a fix, I could not find a fix but I did find the reason I believe. When I was talking with Chris earlier, he mentioned that the memory allocation error could be caused from the memory fragmentation.
Looking around in the file menu on the Spike Prime, I noticed that they use the 'gc (garbage collector)' module for memory management. I used the gc.mem_free() in order to find the memory free and gc.collect() to collect all fragmented memory. After looking at the memory usage after compiling the code. I found that these allocation errors I was getting did not make sense with the total memory available.
I found a micropython forum post on the same error, but it did not help to solve the issue. The link can be seen below: https://forum.micropython.org/viewtopic.php?t=4912
My partner and I decided to document our errors in this process and move on to making the placemats for AI Lesson 1 and 2
The last step for this week was to make placemats for the Artificial Intelligence Lesson 1 Lesson 2. We split up this work between my partner and I, so I made the placemat for the Lesson 1. The final placemat can be seen below.
This week my goal was to get started with the various features capable with Onshape.
I started out the week by creating a parameterized model of the Spike Prime Hub. I first just made the model without using variables but of course this led to an innacurate model and the holes did not end up lining up.
I ended up completely restarting and learned how to make variables in Onshape and created a finalized parameterized Spike Prime Model.
This process took a long time to complete but I feel very comfortable in Onshape after completing this project.
One large challenge I ran into was learning how to split parts in Onshape. I modelled the Spike Prime, using the master modeling approach where the I modelled the complete hub and then separated the hub into its components for coloring.
I learned that in Onshape you can extrude a sketch into a surface which made these complex splits between the top and botom of the Spike Prime Hub.
I am currently starting to make a basic standardized dimension sheet for LEGO Technic componnents. Im making that in Illustrator, but overall the getting started and workflow in Onshape has been very effortless. I really enjoy using this software a lot so far!
Here is a link to the Enterprise File if you want to take a closer look at it!
So far my process of learning FeatureScript has been a process. My biggest issue with feature script is the lack of clear usage examples and simple terms.
It may be very simple but I wish there was a simple guide that outlined the main terms needed to efficiently create models.
Some important keywords I think need to be more clearly introduced are Queries, BodyTypes, and op* Features. For reference * means all features that have op as a prefix such as opFillet or opExtrude.
I do have to say that I learned a lot through the OnShape seminar videos that showed more complex methods of writing FeatureScripts, but alot of my learning came from reading other users' code. I feel like some very basic videos on how to Query specific types of Bodies or Entities would be amazing and really help the progression of learning.
Nonetheless, I completed two FeatureScripts this week to generate LEGO Technic Axles and Axle Pins. Just like completing the Spike Prime Hub Model, each FeatureScript I completed I became more comfortable with the syntax. For me I feel like the syntax is the largest barrier, but I found that by stepping back and thinking about how I would accomplish this process in the GUI of OnShape everything started to click.
Both of these FeatureScripts took awhile to get right but the links to both of them are displayed below.
Axle Generator:
Axle Pin Generator:
I also found a template for the Internal OnShape documentation on the Forums and created a Getting Started PDF that is attached in each FeatureScript. The pdfs can also be seen below.
This week was all about getting a handle on connecting Onshape's API and the LEGO Robotics Platforms.
My first step this week was to establish a base understanding of API's so that I could start communicating between platforms.
After reading through many websites and the Onshape Github page, I decided to attempt to use the ability of the updateFeatureStudio API call in order to use the color sensor on the EV3 to change the color of a part in Onshape.
My first approach was to refresh my memory with Labview in order to be able to parse a string for specific indices and pull data tags from Systemlink.
My workflow for this project went as follows:
The EV3 reads in color rgb data from the color sensor when the center button is pressed.
This data is then converted from the standard "(R,G,B)" string format to a concatenated string that has the RGB values as %0.3f precision numbers.
This concatenated string is then pushed to Systemlink using a string tag and pulled down by my computer running Labview.
The goal of the Labview code is to parse this concatenated string and assign the respective colors to an updated featurescript and post to Onshape, effectively changing the part color.
This process worked really for me. Although the start up took a while, I made many small steps when writing the Labview code that allowed me to easily work through the goal.
For my final documentation on this project I made a cumulation video using Adobe After Effects, which can be seen below!
After I completed the work for connecting EV3 to Onshape through Systemlink and Labview, we were tasked to make a demo video for LEGO of our progress with Onshape FeatureScripts and assembling parts in Onshape.
Upon starting our LEGO assembly for the first time, we realized that we sent our standardization document too late and all of the modelled pieces did not allign.
In order to get everything to fit, Teo and I remodelled the broken pieces and made sure the Standard was kept for all of them. This included remodelling the Spike Prime Hub and all of the Motors previously modelled. Once this was completed however everything lined up perfectly and we were able to spend a good portion of time planning and setting up our demo.
We decided that we were going to make sure we highlighted three important componnents:
The Part Generation with the FeatureScripts
The Assembly Process of a LEGO Robot in Onshape
The comparison of the final virtual product with the physical created model.
Below are the original robot photos:
The video below is the completed demo video. We formatted it so that the flow went:
LEGO generated parts
High Speed Screen Cap of the Build Process
The final comparison.
My goal for next week is to dive into Thingworks and specifically connect the EV3 with Onshape directly. At the end of the week I was able to complete the download of the Onshape client onto the EV3 and Im looking forward to playing around with it.
This week was all about creating more components of the LEGO Spike Prime Kit and switching our approach of design.
At the beginning of the week I spent some time collecting all of work on the LabVIEW connection with Onshape and creating a page on my Github in order to store all of this work. Below is the link to the repository:
https://github.com/owen-gervais/CEEO2020/tree/master/Color_Sensor_Onshape
I had some critiques about the LabVIEW and Color Sensor work. Instead of posting the true sensor color it was recommended to filter out the primary R, G, B color so that the color change was easier to see a change. I implemented this change this week so that I could show it off during the live demo for PTC this week.
After meeting with PTC this week, we started to look into how we were going to format our LEGO document so that it would be easier for the user to use the document. I found a lot of resources online for standards of making libraries of parts. The way that we settled on making our SPIKE Prime complete document went as followed.
Organize the parts by Technic and standard system bricks
Match like shapes with each other, i.e. Pins with other pins in configurations
We spent most of this week working to setup the standard for this library of parts and also the standard parametric L value for the modeled LEGO pieces. The master public CAD document in progress can be found at this link if you would like to check out the work done so far on the complete library!
Onshape SPIKE Prime Library:
This week was all about rewriting the work done in Python3.5 with the Onshape Client and rewriting the API calls directly in micropython.
Using the python2.7 library that Milan supplied to me, I spent this week trying to figure out how to migrate the work into solely micropython so we can connect to the Onshape API directly through the EV3.
I ran into a lot of issues with this port of the library, but had some successes. I was able to generate all of Onshapes API headers using their SHA256 encryption, but ran into the same error.
OSError: [Errno 5] EIO
After spending most of this shorter week on this project and using my micropython generated headers on both Postman and Milan's LabVIEW VI and having successful API calls, we decided to set this work on the side for later return.
I uploaded my work to the CEEO Github Page and you can see this work in progress code here:
https://github.com/tuftsceeo/micropython_Onshape_API
(UPDATE): After talking with Ethan from PTC it appears that the urequests library for micropython is not supported to make API calls for the Onshape API, I made an edit to the README on the github page to reflect this update.
This week was all about documenting and building more parts in the new configuration format of our LEGO Spike Prime Library. Enjoy our progress update video covering our work since the last update!
This week was a big progress week on the Onshape document. I modeled a lot more pieces in the configurable format so that the user could easily select them when inserting into the assembly format, I am getting close to over halfway done with configuring all of the components in the kit for easy selection.
One valuable thing I learned this week when using configurations is the ability to suppress a feature. Once I learned this ability all of the configurations were difficult because I had to think about how to reference parts so that they used like features. Configurations are great and hopefully soon I will be able to add a configurable properties to parts so that each part can be referenced clearly and individually.
This week I focused on finishing up more of the components and transitioning the LEGO Spike Prime Kit to the public cad domain of Onshape. I also started to test build some robots to make sure all of the modeled pieces aligned.
This week was predominantly spent in CAD, building out a lot of pieces, with only a few left to finish. I made a primary focus to model all of the sensors again, because the original models did not follow the standard when we parameterized the part modeling. The part colors were also standardized and and updated across the LEGO part library. I downloaded the advertisement material for the Spike Prime and grabbed the respective part colors using Adobe Illustrator. Below is a gallery of the completed and updated parts for this week.
I started to create example robots for the Onshape Public document. Below you can see some shots of the walking robot dog. You can animate one of the Revolute joints on the small motor to make the dog walk!
A link to the public document to play with is below:
This last week entailed a lot of tweaking of parts and building assemblies for testing usability.
At the end of the week, we had a small hack together to figure out how to populate features using the Onshape Python API. This is an interesting addition because it will allow us to use the EV3 to create Onshape parts.
A cool idea that we had would be to use the ultrasonic sensor in order to map a space and build the low density point cloud in Onshape.
I started in on this project this week by setting up a testing area, the mapping robot, and starting in on the geometry to accurately plot the positions by utilizing vector math.
Below are some pictures of the robot and testing area:
My goal for next week is to complete tidying up the LEGO Spike Prime Kit, prepare for the CEEO School Series, and continue work on the room mapping robot in Onshape.
This week I focused on adding more to the ultrasonic sensor demo and finishing up all of the efforts on documenting the LEGO SPIKE Prime document.
To start this week we were asked to make our update video on our progress this summer. Instead of writing out how the ultrasonic sensor demo works I explained it in this video below.
I spent the majority of the rest of the week working on the integration of the LEGO document with BrickLink Ids and BOMs.
The goal with this work was to allow the user to build a lego creation in an Onshape assembly and then leverage the Id system to export a csv of the BOM in order to provide a seamless interaction. I also went through and updated all of the part names to their official lego name, added the url to purchase each individual piece, and the material to the properties for each LEGO brick.
You can see in the above image that the generated BOM from this test studio displays each individual part id, url, and name.
I also led a quick 30 minute class on using this document and I got some feedback. First I changed the color black to a lighter grey so it is easier to see the edges of black parts.
Accessing parts was said to be really easy which was the goal, great!
We were recommended too that making quick 30 second videos of mating hard componnents would be great. I will be working on making these videos next week!
I also started working on running physics simulations of these robot assemblies and am looking forward to diving more into it next week as well!