This is an old revision of the document!
Today, Chris and I humored the idea and checked out the possibility of coding an application for the Leap Motion. We share an idea for gesture control on computers for a more user-friendly control experience. The Leap Motion is a simple device that has an array of 3 infrared cameras. this allows it to see a large spectrum above the desk in front of the computer. It is small and compact, and is perfect for our needs on this project. Next Monday, I plan to begin setup and download the necessary sdk files, which they provide for free for developers online.
New month, new things brewing. Today I began the installation and setup of the Leap Motion and its sdk. The sdk gives helpful example codes and libraries that will help with the understanding of how to code and use the data that the leap motion collects in order to provide output. I have decided to use javascript to code what I want, since I would like to learn the language, and it is also very easy to display in a browser and manipulate in real time.
I plan to make some simple programs first in order to understand the ins and outs of the data and manipulations, and then go from there. After I have garnered an acceptable understanding, I want to start using the leap motion to recognize gestures and translate them to key emulations. This will allow me to start making gesture controls for the computer, which is the main end goal.
Today I went through the javascript tutorial for a simple leap motion app. It takes an image of a cat (how fitting) and moves it in respect to the hand in front of it. I learned that the leap service that is running creates a local websocket server that LeapJS connects to. This allows for real time data transfer to and from the browser, which is crucial to smooth performance of the Leap Motion. Using the websocket, the service sends a data frame roughly every 10ms. The deviceFrame object is not used directly by the browser, but instead creates an animation loop using the controller's animation frames.
You can access the movements of fingers and bones through their names, like thumb, pinky, carpal, proximal, medial and distal. Important Orientation Information
I was able to find a very useful file in the sdk named “sample.html”. This was very useful in showing just what The leap motion sees from a data standpoint, and depicts the output of a frame.
This is a sample frame collected by the leap:
Frame data:
Frame ID: 32565
Timestamp: 2003436343 µs
Hands: 1
Fingers: 5
Tools: 0
Gestures: 1
Translation: (8.7, 2.0, -0.2) mm
Rotation axis: (-0.36, 0.91, 0.20)
Rotation angle: 0.03 radians
Scale factor: 1.01
Hand data:
Hand ID: 13
Type: right hand
Direction: (-0.25, 0.43, -0.87)
Palm position: (70.7, 178.1, -6.3) mm
Grab strength: 0.0322437
Pinch strength: 0
Confidence: 0.892863
Arm direction: (-0.5, 0.3, -0.8)
Arm center: (157.6, 116.2, 147.2)
Arm up vector: (0.1, 0.9, 0.3)
Translation: (8.7, 2.0, -0.2) mm
Rotation axis: (-0.4, 0.9, 0.2)
Rotation angle: 0.03 radians
Scale factor: 1.01
Fingers IDs: 130, 131, 132, 133, 134
Finger and tool data:
Pointable ID: 130
Type: Thumb
Belongs to hand with ID: 13
Classified as a finger
Length: 51.4 mm
Width: 20.0 mm
Direction: (-0.76, 0.14, -0.63)
Extended?: true
Metacarpal bone
Center: (64.2, 148.2, 46.0)
Direction: (-0.6, 0.4, -0.7)
Up vector: (-0.6, 0.3, 0.8)
Proximal phalanx bone
Center: (42.3, 153.2, 35.9)
Direction: (-0.9, 0.2, -0.4)
Up vector: (-0.4, 0.2, 0.9)
Intermediate phalanx bone
Center: (7.6, 160.7, 15.2)
Direction: (-0.8, 0.1, -0.6)
Up vector: (-0.6, 0.2, 0.8)
Distal phalanx bone
Center: (-15.9, 165.7, 0.8)
Direction: (-0.9, 0.2, -0.3)
Up vector: (-0.3, 0.2, 0.9)
Tip position: (-20.4, 165.3, -2.4) mm
Pointable ID: 131
Type: Index finger
Belongs to hand with ID: 13
Classified as a finger
Length: 58.0 mm
Width: 19.1 mm
Direction: (-0.35, -0.26, -0.90)
Extended?: true
Gesture data:
Gesture ID: 1, type: swipe, state: start, hand IDs: 13, pointable IDs: 132, duration: 0 µs, start position: (-44.9, 154.0, -86.2) mm, current position: (35.9, 185.0, -107.1) mm, direction: (0.9, 0.3, -0.2), speed: 216.7 mm/s
There is a lot of data to interpret, and discerning what is going to be useful to my implementation and what isn't is going to be difficult.
Day 2: implementing cat2.c, the updated version.
We are using the read function instead of read, open for fopen, and write instead of printf for more universality. These are system calls.
posix standard allows for universal system error codes, among other things. It defines system behaviors.
fopen returns FILE* (which is a struct), but open returns an int, which is known as a file descriptor.
fdopen takes a file descriptor and creates a file pointer in order to cross between the two.
For next time
Continuing the making of cat2.c
implementing getopt so that we can use:
Moving on from cat into the “who” command!
/var/log/wtmp* → shows login data into lab 46.
apropos utmp → u stands for user. See section 5 for configuration items. The header files are located within this file. (man 5 utmp)
Manual page utmp(5) line 26: shows the ut_type translations.
when logging in, ssh calls the login command, and login makes note of the login.
POSIX
Portable Operating System Interface, a set of formal descriptions that provide a standard for the design of operating systems, especially ones that are compatible with Unix.
Origin
1980s: from the initial letters of portable operating system + -ix suggested by Unix.
Life before POSIX = madness.
BSD - Berkeley Standard Distribution (from UC Berkeley)
man gettimeofday, man ctime
Adjusted the time output to include month, day hour and min using the tm struct.
Chmod (change mode) section 2 . we are using the chmod files in order to implement the + & - in our own implementation of who. (who2)
%o prints out in octal
stat man page
including sys/types.h & sys/stat.h
Today we created who2.c as a more functional and closer looking version to the actual who command.
Our first project is to create a version of chmod command.
Today, we are taking on the program of “ls”.
In order to do this, we use man pages such as closedir, opendir, readdir, scandir.
When printing out, we use the attributes of the directory which are name, inode, type, etc.
In scandir, we begin to see the insane (yet still understandable) use of double and even triple pointers. woot.
Alphasort helps us put our results in alphabetical order. :
we are using the extra libraries of <sys/types.h> and <dirent.h>
Section 2 stat man page.
displaying file permissions is tedious as all hell. At least in the way that we did it.