Lab 2: Intro to Haply
Created by: Ahmed Anwar
In this lab, we had to assemble the Haply device and come up with a maze design and implement it using processing and Haply. Please note that I received my Haply late, so I am submitting this lab now. In addition, I would like to acknowledge, my peer’s comments on the the Can-Hap Discord discuss-labs channel which helped me out a lot. The code for this lab can be found at this repository.
Device and Environment Setup
This device assembly process was pretty straight forward. I just followed the instructions on Haply’s website. The second step was setting up the development environment by installing Arduino IDE, processing and Encoder packages. I faced some issues while selecting the correct port and board on Arduino IDE but after some trials I figured that it was “Arduino Zero (Native USB Port)” and the board name was same as well. In addition, I also face some issues while burning the code to Haply as it gave a “Port busy” error. To resolve this I looked at the discuss-labs channel on discord and found that simply restarting the environment worked for some people and it worked for me as well. After these steps I was all set to explore the Haply.
Firstly, I downloaded all the sketches from https://2diy.haply.co/ and ran all one by one. The most helpful were the “Hello Maze” and “Hello Ball”. With these sketches I experienced the force-feedback for the first time using Haply in this course. While running the sketches, I realized that resetting the Haply to its original position after you are done with the sketch is very important. In cases when I overlooked this step, the end effector would not reach the entire sketch due to miscalibration.
I designed the maze by taking inspiration from the “Hello Wall” sketch. After designing the maze on paper, I figured out that it will basically be a combination of horizontal and vertical walls added to the world i.e. Maze. These walls and environment were created using “FBox” and “FWorld” objects available in the “Fisica” package. In total my maze consisted of 35 walls. I found that adding 35 walls was a tedious process so I created a helper function to create a wall that takes in the width, height, x-position, y-position of the wall. This greatly reduced the amount of code that I had to write. In addition, I also had to tweak the height, width and pixel dimensions of the sketch so that my maze can fit completely in the world window. However, since there are lots of walls so it became difficult to keep track of them later on.
However, a major mistake I made during designing sketch was that I kept the starting position of the maze in the bottom-left corner of the maze. I wanted that the Haply’s end-effector should start from the starting position (green ball), but I realized that it was not possible as the Haply starts from the top-middle position due to calibration requirements. Hence, I had to come up with a way to place the end-effector to the starting position and load the maze.
To achieve this, “Hello Maze” sketch came to my aid. I added two colored balls as starting and ending points for the sketch. When the game starts, the walls are disabled and colored white to give the impression that they there is no maze. When we touch the starting point (green ball), the walls are enabled This gives the impression that a maze has been created. If the user tries to cross the walls, he/she experiences resistance from the haply. When the user navigates to the end position (red ball), the game is reset.
This lab was great at getting started with the Haply and the Fisica Package in processing. I found the package to be really helpful in creating and interacting with the virtual objects in the processing environment. I did make some mistakes in the design phase by not taking into account the starting position of the Haply. In addition, since there were lot of walls to add, it became difficult to track and modify each of them in the later stage. So, I believe that I should have made an array to store the coordinates of the walls so that I would have been able to keep a track and adjust their width and heights.