raulzito234

A nerd blog about cs

Month: March, 2013

Rosie’s software architecture.

Rosie’s architecture is going to be the following:

Image

Advertisements

Deploying MATLAB code on MAC.

Apparently it’s possible to deploy/compile MATLAB code, following instructions from here:

First you need to run:

>> deploytool

Add the main function and the helper files. After done, install mcr that can be found here.

To be able to run the code you need to set the environment variable DYLD_LIBRARY_PATH to the folders list in the README file under the created project folder. The README file says to run the command setenv on your MAC. setenv may not be part of the bash shell. Therefore, you should run the following command:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<mcr_root>/v80/runtime/maci64:<mcr_root>/v80/sys/os/maci64:<mcr_root>/v80/bin/maci64:/Applications/matlab/MATLAB_Compiler_Runtime/v80/bin/maci64:System/Library/Frameworks/JavaVM.framework/JavaVM:/System/Library/Frameworks/JavaVM.framework/Libraries

Where <mcr_root> is the path of the Matlab runtime compiler.

Also you can upload the code directly to the file ~/.cshrc

Sending commands to Lynxmotion Robotic Arm.

First to test if the serial port is working upload the following code:

#include

Servo servo1;

void setup() {
    pinMode(1,OUTPUT);
    servo1.attach(14); //servo 1

    Serial.begin(4800);
    Serial.println(" Hello World");
}

void loop() {
    static int v = 0;

    if ( Serial.available()) {
        char ch = Serial.read();

        switch(ch) {
            case '0'...'9':
                v = v * 10 + ch - '0';
                servo1.write(v);
        }
    }
}

Open the Serial Monitor and check if the printed word is Hello World. If it is then proceed to the next step (The baud rate is a common problem that can cause to not print the appropriate word).

To send Commands to the Robotic Arm first upload the following code using the same baud rate as you used above through the arduino software (http://arduino.cc/en/Main/Software):

#include &lt;Servo.h&gt;

Servo servo1;

void setup() {
    pinMode(1,OUTPUT);
    servo1.attach(14); //servo 1
    Serial.begin(4800);
    Serial.println("Ready");
}

void loop() {
    static int v = 0;

    if ( Serial.available()) {
        char ch = Serial.read();
        switch(ch) {
           case '0'...'9':
           v = v * 10 + ch - '0';
           servo1.write(v);
        }
    }
}

Then open the Serial Monitor and use the commands to control it.

To check the official arduino go to http://playground.arduino.cc/Learning/SingleServoExample

Coding Lynxmotion Arm with MAC

Lynxmotion robotic arm comes with an Arduino Duemilanove microprocessor.

al5a

Arduino has a bunch of tools and a large community of developers which make programming on it much easier than other microprocessor. The first step to start programming on it is to install the software and set it up :

http://arduino.cc/en/Guide/HomePage

Follow the instructions (download the FTDI driver as well)

Then you will need to start getting used to the microprocessor. A good reference is:

http://www.lynxmotion.com/images/html/build185.htm

To start using the servos you can use the following code to make sure the Microcontroller is sending signals to your servos. A good example of code that can be run is the following:

http://arduino.cc/en/Tutorial/Sweep

Coding Command Module IRobot Create with MAC

I’m trying to program the Irobot Create with my MAC and I had some difficulties to make it run.

create

First of all I installed the CMStart1 package to try it out. You can download it here

https://sites.google.com/site/irobotcreate2/home/files/CMStart1.zip?attredirects=0

(IF you want to read a little bit more about the project go to: https://sites.google.com/site/irobotcreate2/commandmodue )

Then you need to install all the libraries for avr. You can download them directly from here:

http://www.obdev.at/products/crosspack/index.html

Follow the instructions on the website and don’t forget to restart the terminal window.

After installing it you will need to compile the code.

run the following command:

>> make

The compiler will probably complain, because SIG_OUTPUT_COMPARE1A is poisoned and it is going to be deprecated in the future. So there is a need to change the code to make it  work. A possible solution is to maybe try adding a:

-D__AVR_LIBC_DEPRECATED_ENABLE__

to the pre-processor options if you insist on trying to maintain code with the poisoned SIG_OUTPUT_COMPARE1A. This solution has been posted int he forum: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=128496

Another possible solution is to change the deprecated SIG_OUTPUT_COMPARE1A for a new one depending on the device that is being used. The complete table of symbols can be found at http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

Since the IRobot Create comes with an AVR ATMega168, it needs to be substituted to:

TIMER1_COMPA_vect

After substituting it, you will be able to run:

>> make

After this it’s necessary to upload the command module I’m doing it through a USB cable. I need to first find the name of the port that this USB is connected, thus I look into the folder /dev using the commands:

>> cd /dev/

>> ls

Then you should look for the tty.usb. In my case the USB port is /dev/tty.usbserial-A9005Qaa. Press the reset button and then  use the following command:

>> avrdude -p ATMega168 -c stk500v1 -P /dev/tty.usbserial-A9005Qaa -U flash:w:cmstart1.hex

There is a tutorial on how to use the command above here: http://www.ladyada.net/learn/avr/avrdude.html if you need more help.