User Tools

Site Tools


opus:fall2013:eolson1:journal

Data Communications Journal

August 28th, 2013

We assembles the new raspberry pies that were so generously purchased for our use this semester. After assembly we discovered that we will need to modify the cases of the pies so that the I/O pins will be exposed. This will be resolved tomorrow. Hopefully we will also be able to get an operating system on them as well tomorrow.

August 29th, 2013

Installed Raspberry pie distros of linux on the sd cards.

August 30th, 2013

Used a Dremel to cut holes in the cases of the Raspberry pies so the I/O pins were exposed.

September 4th, 2013

Began to experiment with the raspberry pies I/O interface. followed the tutorial on the website on the lab46 data comm course homepage.

September 5th, 2013

Continued working on the Tutorials on the homepage.

September 11th, 2013

Did additional dremelling on the Raspberry pie cases to allow for a cable connection to the I/O pins

Raspberry Pie Programming

Beginning to program the Raspberry Pie to make use of the GPIO pins starts with creating a basic library to use. We used a few tutorials and made some modifications to get the code to work.

Tutorials:

https://sites.google.com/site/semilleroadt/raspberry-pi-tutorials/gpio

http://www.pieter-jan.com/node/15

After folloring the tutorials we came and help modifying the code we cam up with these files that can be used to manipulate the GPIO pins

The Codez:

http://lab46.corning-cc.edu/~eolson1/RPI.c

http://lab46.corning-cc.edu/~eolson1/RPI.h

Once these were in place we were able to manipulate the GPIO pins. All programs need to be compiled with the .c files and have the header included.

LED Blinking Binary Counter

The first program We wrote was to simply turn an led on and off, and create a binary counter. Here is the code.

http://lab46.corning-cc.edu/~eolson1/main.c

I also played around with using a button to turn an led on and off. Here it is.

http://lab46.corning-cc.edu/~eolson1/button.c

The problem seemed to be that there is a slight lag when the button is pressed to when the led turns on. This might be fixed by implementing an interrupt on the pin. A problem we also have later when trying to receive the Morse code.

Morse Code Send

Here is the Morse code:

http://lab46.corning-cc.edu/~eolson1/Morse.c

http://lab46.corning-cc.edu/~eolson1/morse.h

This will take a string such as a sentence and translate it to Morse code and send it over a single line via the GPIO pins on the raspberry pie.

If you take a look at the code it is done by a large loop that iterates through the string one character at a time. Depending on what the character is it will call a series of functions. These are a combination of dot's and dash's related to what each character is in Morse code. If you look in the header file morse.h you will see how these fictions imitate a dot and a dash. They basically turn a pin on for a specified time and then turn it off.

If you look here there is a great chart explaining how Morse code works and the increments.

Now we have officially run into the problem of latency over the line when trying to detect when pins turn on and off. What we will have to do to remedy this problem is download the Kernel source change a few things and instal the new kernel.

Adding a URI to your sources.list

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

HPC Experience I Journal

Aug 29th, 2013

Began reading about LFS (Linux from scratch). I plan to do a full build using the tutorial provided.

September 2nd, 2013

Continued working on the tutorial provided by the LFS webpage. I created a separate working directory called lfs.

Into to Unity

September 20th, 2013

I have decided to try my hand at game development with the Unity game engine. I have been doing a lot of research and have found some really good tutorials to get started with. I will be using a tutorial by quill18creates who does a very basic FPS importing no extras and writing all your own scripts for the first person controller. This tutorial also implements the use of Blender which is a free and very powerful 3d modeling program. In the tutorial I will be using blender to create all of the objects that I will be using in the game. This is the very reason I chose to use this tutorial because it seemed to get right into the dirty work from the start which is how I think it should be. Many of the other tutorials had you download packages that basically did everything for you. I like to have the power to do it myself if I need to.

First off we needed to create a simple map for the game. Blender is very keyboard shortcut oriented so I have attached a cheat sheet.

blender_cheat_sheet.pdf

And this is what I created.

You can also download it and use it here:

http://lab46.corning-cc.edu/~eolson1/Fpsmap.blend

Once I created the map I could save it into my unity projects assets folder and use it in unity.

I made a models folder within my asserts folder to make everything a little more organized. Wherever you put it you can now click on the icon and notice that information about the object will appear on the right side of the screen in the inspector.

As you can see I have circled the Generate Collides Option. This is very important if you want anything to sit stand or just not fall right through your map. This option may not be selected and you will have to select it and hit apply at the bottom. Once you have done this you can drag and drop the map into the Hierarchy tab.

Alright now that we have a map in our game world we need to have a character that can run around and check it so the first thing we will do is create an empty object. This is located in the game object tab.

Now that we have an empty object we will have to add a character controller to it. The Character controller doesn't actually “control” the character we will have to write scripts for that. What it does do is add a collision box to the character and you can change things like the slope in degrees that the character can walk up and even the step height that the character can walk up. You can also height of the character and things like that. Here is what it looks like.

Here I have also included some visual ads to help explain, a cross section of the map and my character. Basically when creating my map I messed up the point at which it takes its position from is the actually the ceiling rather than the floor. The structure is 4 units tall so -4 is the floor. So the character controller is set to -4 and then the center is set to 1.01 to bring the controller up so that the feet are just above the ground. If it was set to 1 there could be a glitch where the character starts slightly below or right at the floor of the map and fall right through.

Alright now we need to be able to see but not only that we want to see through the eyes of our character. Now there should be a camera already in the scene. the easiest way to attach it to our player is simply drag and drop in onto the player in the hierarchy. This will make the camera a child of the play. Now the camera should be at about eye height so we will have to make that happen. In hierarchy click on the camera and set its y position to 1.75 as the height of the character controller is 2 meters.

Now onto a script for movement and mouse look!

Now in assets I do not believe there is a standard scripts folder. I made one, again to keep things organized. Once you have a scripts folder you can right click and create C# script and name it FirstPersonController.

Now you can double click on the script you made and it will come up in mono development (the editor). This is what mine looks like I will also be adding a link so you will be able to download the file if you wish.

Also you can downloed it here: http://lab46.corning-cc.edu/~eolson1/FirstPersonController.cs

now this is going to seem very foreign to you unless you have done any sort of 3D game dev in unity. it definitely was for me. Iam going to start explaining the code in the movement section. The first two lines in this section are setting up the players forward/backward and left/right speed. Lets take the line

float forwardSpeed  = Input.GetAxis( "Vertical" ) * movementspeed;

for example. We are defining a variable that is going to be our forward speed then we are setting it = to Input.GetAxis( “Vertical” ) * movementspeed; Input.GetAxis is a function in the unity library that will do exactly what it says for a certain input it will get that axis. So we give it “vertical”… where does that come from? well if we look into edit, project settings and input we will see this in the inspector:

As you can see there is a drop down labeled axis and under that drop down there are more labeled Horizontal and Vertical. Now it all makes sense! Also if you look there are “inputs” associated with these axis, Vertical would be w and s and left and right would be a and d but you could actually change them here if you so desired. Now I have not mentioned the movementspeed variable yet. That variable is defined and set at the top of the script. This will actually give us control over the movement of or character without having to edit the script as you can see here:

Under the First Person Controller (Script) you can see a bunch of variables and values that you can change right here. Unity has recognized these and we now have control over these from here. This may be confusing as it does not edit them in the script but it does make for quick changes on the fly.

Next lets look into the mouse look portion now that we have covered the movement.

For the x axis portion of it it is much like the movement because it is alright for the charccter to look all the way around. Here is the code:

float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
transform.Rotate( 0, rotLeftRight, 0);

The function transform.Rotate() is what actually rotates the camera on the axis defined as rotleftright.

The Y axis on the other hand is a totally different story because we do not want our character to be able to look at all 360 degrees on the y rotation. That would be weird. For this situation we are going to use a clamp.

verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);

Here is an example of how it works. Basically the first line is setting verticalRotation the position of the mouse. Then it is checking that value and making sure it is within the clamp set in line two. Then it moves the camera to that position in line three.

Next we will get to the jump portion.

verticalVelocity += Physics.gravity.y * Time.deltaTime;
		
	if( characterController.isGrounded && Input.GetButtonDown("Jump") )
	{
		verticalVelocity = jumpSpeed;
	}

In this cut from the code we are applying Physics.gravity.y * Time.deltaTime to the variable verticalVelocity. after this is done we check to see if the characterController is grounded (are his/her feet on the floor) if this is true AND we are pressing the jump button the player will jump and apply jumpSpeed to verticalVelocity.

And now lastly for the things I have missed.

Vector3 speed = new Vector3( sideSpeed, verticalVelocity, forwardSpeed ); speed = transform.rotation * speed;

This excerpt basically takes all three axis and applies it to the players speed. so if the player turns while walking forward he will walk in the direction he/she is walking.

Then at the end all of this data is applied to the character controller making everything happen in game.

characterController.Move( speed * Time.deltaTime );

Also you may have noticed that the mouse is still on the screen when you are testing the game. this is not generally desirable.

void Start () {
		Screen.lockCursor = true;
		characterController = GetComponent<CharacterController>();
	      }

Adding Screen.lockCursor = true; to the start() function will fix this and when you need the mouse press esc.

Setting Up Sudoreboot.net

First check out its current state!!

http://sudoreboot.net/

Static IP Set up

Here is the original /etc/network/interfaces

  1 # This file describes the network interfaces available on your system
  2 # and how to activate them. For more information, see interfaces(5).
  3
  4 # The loopback network interface
  5 auto lo
  6 iface lo inet loopback
  7
  8 # The primary network interface
  9 allow-hotplug eth0
 10 iface eth0 inet dhcp

They we modified it to read like this

  1 # This file describes the network interfaces available on your system
  2 # and how to activate them. For more information, see interfaces(5).
  3
  4 # The loopback network interface
  5 auto lo
  6 iface lo inet loopback
  7 auto eth0
  8 iface eth0 inet static
  9 #Our static IP
 10 address 192.168.0.100
 11 #Our Gateway IP
 12 gateway 192.168.0.1
 13 netmask 255.255.255.0
 14 #Our Network address
 15 network 192.16.0.0
 16 broadcast 192.168.0.255
 17
 18 # The primary network interface
 19 allow-hotplug eth0
 20
 21 #Commented out to disable dhcp
 22 #iface eth0 inet dhcp
opus/fall2013/eolson1/journal.txt · Last modified: 2013/12/04 16:19 by eolson1