Monday, May 5, 2014

Revision 2 of Code

The first revision worked well but I knew I could make it better. To do that I decided to make the robot look and turn at 45 degree increments instead of 90 like the previous revision. I added functions that did the turning and looking, but I needed to change how the robot chose which path to take. The previous code it had two choices left or right, revision 2 has four. I wrote a function that found the lowest variable (further distance away) and turned accordingly. Revision two is posted below.




//=======================================================================
// Name        : FInal_Rev2.cpp
// Author      : George
// Version     : Revision 2
// Copyright   : None
// Description : Adding looking while going forward, also adding more turns
//=======================================================================

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <algorithm>
using namespace std;

////////////////////////////////////////////////////////////////////////
/////////       Motor File Paths "can be put in header file"
////////////////////////////////////////////////////////////////////////
FILE *MC = NULL;
char *M1Period = "/sys/devices/ocp.2/pwm_test_P8_13.10/period"; //P8_13 Left Motor
char *M1Duty = "/sys/devices/ocp.2/pwm_test_P8_13.10/duty";     //P8_13 Left Motor
char *M2Period = "/sys/devices/ocp.2/pwm_test_P8_34.11/period"; //P8_34 Right Motor
char *M2Duty = "/sys/devices/ocp.2/pwm_test_P8_34.11/duty";     //P8_34 Right Motor
char *M3Period = "/sys/devices/ocp.2/pwm_test_P9_21.12/period"; //P9_21 Micro Servo
char *M3Duty = "/sys/devices/ocp.2/pwm_test_P9_21.12/duty";     //P9_21 Micro Servo


////////////////////////////////////////////////////////////////////////
/////////       Declared Functions  "can be put in header file"
////////////////////////////////////////////////////////////////////////
void GPIO_46();
void GPIO_47();
void ADC_setup();
int distance();
int Turn(int,int,int,int);
void setup();
void MotorP(int);
void MotorLL(int);
void MotorRR(int);
void MotorEyes(int);
void Look_Right();
void Look_ShortRight();
void Look_TinyRight();
void Look_Left();
void Look_ShortLeft();
void Look_TinyLeft();
void Look_Ahead();
void reboot();
void Push2Start();
void GoStraight();
void TurnRight();
void ShortRight();
void TurnLeft();
void ShortLeft();
void Stop();

int main(int argc, char** argv)
{
int E,NE,W,NW,N,check_dist;
setup();                   // Setting pins, modes, and motors
printf(" You can Push De Button!! \n");
Push2Start();          // Waiting until button is pressed to proceed
int iteration=0;       // counter

while(1){
                  ////////// Added looking while moving
if (iteration < 20) Look_TinyLeft();    
if (iteration > 20) {                            
if (iteration < 40){                  
Look_Ahead();              
}                                          
else Look_TinyRight();      
}                                                
if (iteration == 61) iteration = 0;
                 //////////
GoStraight();
check_dist = distance();
printf("  distance = %d  \n", check_dist);

if ( check_dist >= 1200){         /////  Additional cases were added
Stop();                                     /////   Stop and start looking
for (int ii=1; ii<6; ii++){      /////    Look both ways before crossing

switch(ii){
case 1:
Look_Left();
usleep(400000);
W=distance();
break;
case 2:
Look_ShortLeft();
usleep(400000);
NW=distance();
break;
case 3:
Look_Ahead();
usleep(400000);
N=distance();
break;
case 4:
Look_ShortRight();
usleep(400000);
NE=distance();
break;
case 5:
Look_Right();
usleep(400000);
E=distance();
Look_Ahead();
break;
}
}
printf("    West  = %d  \n", W);
printf("  N West  = %d  \n", NW);
printf("    North = %d  \n", N);
printf("  N East  = %d  \n", NE);
printf("    East  = %d  \n", E);

int num = Turn(W,NW,NE,E);   // finding lowest value
printf("Lowest number is: %d \n", num);

if (W == num) TurnLeft();   //// Compares to lowest value found
if (NW == num) ShortLeft();
if (NE == num) ShortRight();
if (E == num) TurnRight();
}
reboot(); // Checking if reset button is pressed
iteration++;
}
return 0;
}

///////////////////////////////////////////////////////////////////////////////////
////////////// Setup Function
///////////////////////////////////////////////////////////////////////////////////

void setup(){

GPIO_46();         // Exporting and setting PinMode (P8_16)
usleep(20);
GPIO_47();       // Exporting and setting PinMode (P8_15)
usleep(20);
ADC_setup();   // Turning Analog pin 5 on
usleep(20);
MotorP(20000000);  // Setting period for all motors
usleep(20);
Stop();             // Motors in stopped position
usleep(20);
Look_Ahead();      // IR Looking forward
usleep(20);

}

/////////////////////////////////////////////////////////////////////////
///////////// Button Functions
/////////////////////////////////////////////////////////////////////////

void reboot(){
FILE *inval;

int value;
inval = fopen("/sys/class/gpio/gpio46/value", "r");
fseek(inval,0,SEEK_SET);
fscanf(inval,"%d",&value);
fclose(inval);
//printf("value: %d\n",value);

if (value == 1){
system("reboot");
}
//else printf("Im still running");

}

void Push2Start(){

FILE *inval;
int value;

do {
inval = fopen("/sys/class/gpio/gpio47/value", "r");
fseek(inval,0,SEEK_SET);
fscanf(inval,"%d",&value);
fclose(inval);
sleep(1);
//printf("value: %d\n",value);
} while(value != 1);
}

///////////////////////////////////////////////////////////////////////////
//////////////  Motor Functions
///////////////////////////////////////////////////////////////////////////

void MotorP(int setvalue){        // Setting period for all motors

char Mclock[10]; /// Making an empty char variable
sprintf(Mclock,"%d", setvalue); /// converting the int to the char

if((MC = fopen(M1Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 1 period
 fclose(MC); //Closing file
}

if((MC = fopen(M2Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 2 period
 fclose(MC); //Closing file
}

if((MC = fopen(M3Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 3 period
 fclose(MC); //Closing file
}
}

void MotorLL(int speed){ // Left Motor M1         Setting Duty cycle

char duty[10];
sprintf(duty, "%d", speed);

if((MC = fopen(M1Duty, "r+")) != NULL){ //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC); //Setting Motor 1 duty
fclose(MC); //Closing file
}
}


void MotorRR(int speed){ // Right Motor M2        Setting Duty cycle

char duty[10];
sprintf(duty, "%d", speed);

if((MC = fopen(M2Duty, "r+")) != NULL){ //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC); //Setting Motor 2 duty
fclose(MC); //Closing file
}
}

/////////////////////////////////////////////////////////////////////////////////
////////////////// GPIO pin Functions
/////////////////////////////////////////////////////////////////////////////////

void GPIO_46(){

FILE *in,*indir;

in = fopen("/sys/class/gpio/export", "w"); // Exporting GPIO 46 (P8_16)
fseek(in,0,SEEK_SET);
fprintf(in,"%d",46);
fflush(in);

indir = fopen("/sys/class/gpio/gpio46/direction", "w"); // Setting Pin 46 Direction as input
fseek(indir,0,SEEK_SET);
fprintf(indir,"in");
fflush(indir);

fclose(in); //Closing file
fclose(indir); //Closing file

}

void GPIO_47(){

FILE *in,*indir;

in = fopen("/sys/class/gpio/export", "w"); // Exporting GPIO 47 (P8_15)
fseek(in,0,SEEK_SET);
fprintf(in,"%d",47);
fflush(in);

indir = fopen("/sys/class/gpio/gpio47/direction", "w"); // Setting Pin 47 Direction as input
fseek(indir,0,SEEK_SET);
fprintf(indir,"in");
fflush(indir);

fclose(in); //Closing file
fclose(indir); //Closing file

}



void ADC_setup(){ // Setting up ADC for BBB
FILE *ain;
ain = fopen("/sys/devices/bone_capemgr.8/slots", "w");
fseek(ain,0,SEEK_SET);
fprintf(ain,"cape-bone-iio");
fflush(ain);

fclose(ain);
}

///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////  Robot routines
////////////////////////////////////////////////////////////////////////////////////////

void Stop(){ // This one is Set
MotorLL(18490000);
MotorRR(18500000);
}

void GoStraight(){ // This one is Set
MotorLL(17600000);
MotorRR(18680000);
}

void TurnRight(){ // This one is Set
MotorLL(17600000);
MotorRR(18300000);
usleep(750000);
Stop();
sleep(1);
}

void ShortRight(){
MotorLL(17600000);
MotorRR(18300000);
usleep(350000);
Stop();
sleep(1);
}

void TurnLeft(){ // This one is Set
MotorLL(18700000);
MotorRR(19800000);
usleep(750000);
Stop();
sleep(1);
}

void ShortLeft(){
MotorLL(18700000);
MotorRR(19800000);
usleep(350000);
Stop();
sleep(1);
}

void Look_Left(){
MotorEyes(17300000);
}

void Look_ShortLeft(){
MotorEyes(17800000);
}

void Look_TinyLeft(){
MotorEyes(18150000);
}

void Look_Ahead(){
MotorEyes(18350000);
}

void Look_Right(){
MotorEyes(19300000);
}

void Look_ShortRight(){
MotorEyes(18900000);
}

void Look_TinyRight(){
MotorEyes(18500000);
}

/////////////////////////////////////////////////////////////////////////////////////////
////////////////// IR Distance Sensor
/////////////////////////////////////////////////////////////////////////////////////////

void MotorEyes(int direction){
char duty[10];
sprintf(duty, "%d", direction);

if((MC = fopen(M3Duty, "r+")) != NULL){    //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC);    //Setting Motor 3 position
fclose(MC); //Closing file
}
}

int distance(){

int num = 0;
int value,avg;
for ( int n=20; n>0; n-- ){  // Reads the sensor 20 times

FILE *aval;
aval = fopen("/sys/devices/ocp.2/helper.14/AIN5", "r");
fseek(aval,0,SEEK_SET);
fscanf(aval,"%d",&value); // Reading AIN5
fclose(aval);
usleep(10);

num += value;

if (n == 1){
avg = num/20; // Gets the average distance read
}

}
return avg;
}

/////////////////////////////////////////////////////////////////////
/////////// find lowest value function
////////////////////////////////////////////////////////////////////
int Turn(int W,int NW,int NE,int E){
int of_W_NW = W < NW ? W : NW;
int of_NE_E = NE < E ? NE : E;
return of_W_NW < of_NE_E ? of_W_NW : of_NE_E;

}

Sunday, May 4, 2014

The CODE (REV 1)

With this code the robot avoids obstacles fairly well. I am going to add more to make it better. The video on this page is running this same exact code.



//=======================================================================
// Name        : Fianl_Rev1.cpp
// Author      : George
// Version     :
// Copyright   : Your copyright notice
// Description : Revision 1 Robot avoidance program, Ansi-style
//=======================================================================


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
using namespace std;

////////////////////////////////////////////////////////////////////////
/////////       Motor File Paths "can be put in header file"
////////////////////////////////////////////////////////////////////////
FILE *MC = NULL;
char *M1Period = "/sys/devices/ocp.2/pwm_test_P8_13.10/period"; //P8_13 Left Motor
char *M1Duty = "/sys/devices/ocp.2/pwm_test_P8_13.10/duty";     //P8_13 Left Motor
char *M2Period = "/sys/devices/ocp.2/pwm_test_P8_34.11/period"; //P8_34 Right Motor
char *M2Duty = "/sys/devices/ocp.2/pwm_test_P8_34.11/duty";     //P8_34 Right Motor
char *M3Period = "/sys/devices/ocp.2/pwm_test_P9_21.12/period"; //P9_21 Micro Servo
char *M3Duty = "/sys/devices/ocp.2/pwm_test_P9_21.12/duty";     //P9_21 Micro Servo


////////////////////////////////////////////////////////////////////////
/////////       Declared Functions  "can be put in header file"
////////////////////////////////////////////////////////////////////////
void GPIO_46();
void GPIO_47();
void ADC_setup();
int distance();
void setup();
void MotorP(int);
void MotorLL(int);
void MotorRR(int);
void MotorEyes(int);
void Look_Right();
void Look_Left();
void Look_Ahead();
void reboot();
void Push2Start();
void GoStraight();
void TurnRight();
void TurnLeft();
void Stop();

int main(int argc, char** argv)
{
int east,west,north,check_dist;
setup();      // Setting pins, modes, and motors
printf(" You can Push De Button!! \n");
Push2Start(); // Waiting until button is pressed to proceed

while(1){

GoStraight();
check_dist = distance();
printf("  distance = %d  \n", check_dist);



if ( check_dist >= 1100){
Stop();

for (int ii=1; ii<4; ii++){

switch(ii){
case 1:
Look_Left();
usleep(400000);
west=distance();
break;
case 2:
Look_Ahead();
usleep(400000);
north=distance();
break;
case 3:
Look_Right();
usleep(400000);
east=distance();
Look_Ahead();
break;
}
}
printf("  West  = %d  \n", west);
printf("  North = %d  \n", north);
printf("  East  = %d  \n", east);

if (west > east){
TurnRight();
}
else TurnLeft();


}

reboot(); // Checking if reset button is pressed

}

return 0;
}

///////////////////////////////////////////////////////////////////////////////////
////////////// Setup Function
///////////////////////////////////////////////////////////////////////////////////

void setup(){

GPIO_46();         // Exporting and setting PinMode (P8_16)
usleep(20);
GPIO_47();   // Exporting and setting PinMode (P8_15)
usleep(20);
ADC_setup();   // Turning Analog pin 5 on
usleep(20);
MotorP(20000000);  // Setting period for all motors
usleep(20);
Stop();   // Motors in stopped position
usleep(20);
Look_Ahead();      // IR Looking forward
usleep(20);


}

/////////////////////////////////////////////////////////////////////////
///////////// Button Functions
/////////////////////////////////////////////////////////////////////////

void reboot(){
FILE *inval;

int value;
inval = fopen("/sys/class/gpio/gpio46/value", "r");
fseek(inval,0,SEEK_SET);
fscanf(inval,"%d",&value);
fclose(inval);
//printf("value: %d\n",value);

if (value == 1){
system("reboot");
}
//else printf("Im still running");

}

void Push2Start(){

FILE *inval;
int value;

do {
inval = fopen("/sys/class/gpio/gpio47/value", "r");
fseek(inval,0,SEEK_SET);
fscanf(inval,"%d",&value);
fclose(inval);
sleep(1);
//printf("value: %d\n",value);
} while(value != 1);
}

///////////////////////////////////////////////////////////////////////////
//////////////  Motor Functions
///////////////////////////////////////////////////////////////////////////

void MotorP(int setvalue){        // Setting period for all motors

char Mclock[10]; /// Making an empty char variable
sprintf(Mclock,"%d", setvalue); /// converting the int to the char

if((MC = fopen(M1Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 1 period
 fclose(MC); //Closing file
}

if((MC = fopen(M2Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 2 period
 fclose(MC); //Closing file
}

if((MC = fopen(M3Period, "r+")) != NULL){ //Opening the file path
 fwrite(Mclock, sizeof(unsigned long int), 4, MC); //Setting Motor 3 period
 fclose(MC); //Closing file
}

}


void MotorLL(int speed){ // Left Motor M1         Setting Duty cycle

char duty[10];
sprintf(duty, "%d", speed);

if((MC = fopen(M1Duty, "r+")) != NULL){ //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC); //Setting Motor 1 period
fclose(MC); //Closing file
}
}


void MotorRR(int speed){ // Right Motor M2        Setting Duty cycle

char duty[10];
sprintf(duty, "%d", speed);

if((MC = fopen(M2Duty, "r+")) != NULL){ //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC); //Setting Motor 1 period
fclose(MC); //Closing file
}
}

/////////////////////////////////////////////////////////////////////////////////
////////////////// GPIO pin Functions
/////////////////////////////////////////////////////////////////////////////////

void GPIO_46(){

FILE *in,*indir;

in = fopen("/sys/class/gpio/export", "w"); // Exporting GPIO 46 (P8_16)
fseek(in,0,SEEK_SET);
fprintf(in,"%d",46);
fflush(in);

indir = fopen("/sys/class/gpio/gpio46/direction", "w"); // Setting Pin 46 Direction as input
fseek(indir,0,SEEK_SET);
fprintf(indir,"in");
fflush(indir);

fclose(in); //Closing file
fclose(indir); //Closing file

}


void GPIO_47(){

FILE *in,*indir;

in = fopen("/sys/class/gpio/export", "w"); // Exporting GPIO 47 (P8_15)
fseek(in,0,SEEK_SET);
fprintf(in,"%d",47);
fflush(in);

indir = fopen("/sys/class/gpio/gpio47/direction", "w"); // Setting Pin 47 Direction as input
fseek(indir,0,SEEK_SET);
fprintf(indir,"in");
fflush(indir);

fclose(in); //Closing file
fclose(indir); //Closing file

}



void ADC_setup(){ // Setting up ADC for BBB
FILE *ain;
ain = fopen("/sys/devices/bone_capemgr.8/slots", "w");
fseek(ain,0,SEEK_SET);
fprintf(ain,"cape-bone-iio");
fflush(ain);

fclose(ain);
}




///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////  Robot routines
////////////////////////////////////////////////////////////////////////////////////////

void Stop(){ // This one is Set
MotorLL(18490000);
MotorRR(18500000);
}

void GoStraight(){ // This one is Set
MotorLL(17600000);
MotorRR(18600000);
}

void TurnRight(){ // This one is Set
MotorLL(17600000);
MotorRR(18300000);
usleep(750000);
Stop();
sleep(1);
}

void TurnLeft(){ // This one is Set
MotorLL(18700000);
MotorRR(19800000);
usleep(700000);
Stop();
sleep(1);
}

void Look_Left(){
MotorEyes(17300000);
}

void Look_Ahead(){
MotorEyes(18350000);
}

void Look_Right(){
MotorEyes(19300000);
}

/////////////////////////////////////////////////////////////////////////////////////////
////////////////// IR Distance Sensor
/////////////////////////////////////////////////////////////////////////////////////////

void MotorEyes(int direction){
char duty[10];
sprintf(duty, "%d", direction);

if((MC = fopen(M3Duty, "r+")) != NULL){    //Opening the file path
fwrite(duty, sizeof(unsigned long int), 4, MC);    //Setting Motor 3 position
fclose(MC); //Closing file
}
}

int distance(){

int num = 0;
int value,avg;
for ( int n=20; n>0; n-- ){  // Reads the sensor 20 times

FILE *aval;
aval = fopen("/sys/devices/ocp.2/helper.14/AIN5", "r");
fseek(aval,0,SEEK_SET);
fscanf(aval,"%d",&value); // Reading AIN5
fclose(aval);
usleep(10);

num += value;

if (n == 1){
avg = num/20; // Gets the average distance read
}

}
return avg;
}

Saturday, May 3, 2014

The Build (Robot)


To build the frame of the robot I used hobby plates and brackets that I got from Lowe's. Figure 0 shows three of the style parts used to build the frame. There were various designs that I came up with but the best one is the one that can be seen in Figure 1.

Figure 0; Parts used for frame

  • 1 3x3 plate
  • 2 8x8 plate
  • 4 1x6 brace
  • 1 L-bracket
  • 4 half inch spacers
  • standard hardware
Figure 1: Final Frame Design
With this design the robot is very easy to break down. The two platforms that hold the BeagleBone Black and the Anker battery are free floating. When I remove the battery I can easily remove the wheels and servos. I did this so I could do a quick field dis-assembly in case I needed the servos for another project.


The platform that holds the BeagleBone Black is a perfect size for holding a mini-breadboard. I will need the breadboard to add components such as resistors and buttons. It also will make connecting the servos and the IR distance sensor a lot easier. See Figure 2.

Figure 2: Mini-Breadboard
To mount the micro-servo on the front of the robot I used a hot glue gun. I also used hot glue to hold the BeagleBone Black case. With everything solid I was then able to wire the various components.

For the IR distance sensor I had to make a voltage divider circuit because the analog pins on the BBB can only handle up to 1.8 V. To make sure I was not going to brick my BBB I connected the IR sensor to a multimeter to check the voltage divider circuit in Figure 3. The voltage divider never went over 1.6 V on the multimeter so it should work.

Figure 3; Voltage divider


With everything ready I wired up the servos, IR sensor, and two push buttons. It looks like a mess but everything connected to the BBB can be seen in Figure 4 and Figure 5.
Figure 4; Everything wired and mounted

Figure 5; Wired Breadboard





Tuesday, April 22, 2014

Setting Up PWM for BeagleBone Black

BeagleBone Black Pin-modes




As can be seen on the BBB, it has a number of usable pins at your disposal. Through further inspection I found out that one pin can have up to seven different modes. For instance one pin can be used for regular GPIO, PWM, UART, or I2c; this is done by pin-muxing. So through multiplexing the different modes can be set. Because the BBB does not POST at boot the only way to initialize hardware capabilities is through Device Tree Overlays (DTO).  A DTO can be considered the equivalent of a driver. I am not sure if this is correct, but I am just stating what I have gathered from it through my own research. The best resource I have found with working with the BBB is on Derek Molloys site. I wouldn't have been able to get as far as I have in such a short time with watching his videos. A link will be posted I really recommend going there for more cool things BBB.


Setting up PWM 


To activate the pins the device tree overlays must be added to:

                    /sys/devices/bone_capemgr.8/slots

To see what pins can be used go to:

                   /lib/firmware

For most applications it would be nice to keep from having to do this manually every time you turn your BBB on. To do this, change the uEnv.txt file inside /media/BEAGLEBONE. An example of what I added to it to run three PWM pins can be seen in Figure 1. Additionally, If you are using a pin that by default is set for HDMI out, you will have to mount the file path manually. Both steps will be in Figure 1.

Figure 1: Mounting filepath, and changing file

 To make it easier to access my Pins and Slots I made multiple shortcuts by modifying the .profile inside the /etc directory. I did this by exporting the file path into a user defined name, see Figure 2.

Figure 2: Adding shortcuts in .Profile

With these modifications everything should be set at boot-up. To check the pins you can set the period and duty cycle to the shortcuts by echoing a value for each. Every servo is a little different, so the values can change. In the first video I show setting the period and duty cycle. The values will be close so they are a good reference.




Resources:

Derek Molloys BeagleBone Black site

 

Sunday, April 13, 2014

Setting up for Cross-Compilation with Eclipse (CDT)


In order to program the BBB cross-compilation is necessary. Because the system I will be using to program the board is x86 architecture and the BBB is using ARM architecutre. So I will be setting Eclipse to do this and will show the entire process that I used in order accomplish this task. I am running Ubuntu 12.04 LTS on my personal desktop to do this (not a virtual system).

Installing Eclipse (CDT)

Figure 1: Installing Eclipse
Before you can set it up you need to install it first, if you have not already. So I opened a terminal and installed Eclipse along with C/C++ development tools, and the compilers for C/C++. As can be seen in Figure 1 I already had it installed on my system. To install it though the terminal enter:      

sudo apt-get install eclipse eclipse-cdt      
sudo apt-get install g++ gcc


After doing that I had my best results by updating everything before I progressed any further.


Because we are compiling to a separate system I also needed to install these in Eclipse:

  • Remote System Explorer End-User Runtime
  • C/C++ Remote Launch
To install those I opened Eclipse and went to Help>>Install New Software. A window popped up like in Figure 2 below. I then clicked on the down arrow at the top of the page and selected Indigo Update Site. Remote System Explorer End-User Runtime is located under general purpose tools. C/C++ Remote Launch is located under Mobile and Device Development. 

Figure 2: Installing add-ons 

Making it ARM Ready

Next step I did was install the toolchain for the BBB. In the terminal I entered:

Figure 3: Checking it installed properly
sudo apt-get install gcc-arm-linux-gnueabi

sudo apt-get install g++-arm-linux-gnueabi

It takes a minute or to, but afterwards if you type arm-linux and press tab a couple times you should end up with something similar to what is shown in Figure 3.




Figure 4: Hello World
At this point a C++ project can be made in Eclipse. For first time set-up I just chose the Hello World C++ Project, that way I can test it right away, Figure 4. By clicking on the hammer to build it and the green button with a white arrow(Run) on it it should display "Hello World". To send it to the BBB you have to change the build settings. By right clicking on your project you can go to properties>>C/C++ Build>>Settings. Going back to Figure 3 I had to input the proper commands for each. Figure 5 shows all four changes that I made.  

Figure 5: Changing Build Settings

Setting up Remote Application

To send the program to run on the BBB, go to run configurations under the run button. Double click on C/C++ Remote Application and create a new connection. The remote system type is Linux, the host name should be the ip address of your BBB. The address from the USB host would be 192.168.7.2. It will change if you are using the Ethernet port  and do not have a static IP setup. I have been using a static ip but will show how for the USB because I do not have it as a connection type in Eclipse. Follow the Figures on how to configure the connection.

Figure 6: Making new connection
























The last part is to give it a file path. Figure 6 shows an example of how that can be done. The part marked by a blue box is what the name of the program will be inside your BBB. The red boxes are what I changed. Click run and it should send it to the BBB. It will automatically run it as soon as you send it. You can also call it from the BBB by typing ./ProgramName while ssh-ing to the BBB.

Figure 11: File Path



Resources:

cross-compile-for-beaglebone-black by Michael H Leonard


What is a BeagleBone Black?

The BeagleBone Black (BBB) is an ARM community-supported development platform for developers and hobbyists. It comes pre-installed with Angstrom Linux but it is compatible with other operating systems like Ubuntu, and Android. While it can be used as a desktop computer its main advantage compared to similar boards is all the pins that are available to the user.

Specifications:

  • AM335x 1GHz ARM Cortex-A8
  • 512MB DDR3 RAM
  • 2GB 8-bit eMMC
  • 3D graphics accelerator
  • NEON floating-point accelerator
  • 2x PRU 32-bit microcontrollers
  • USB client for power and communications
  • USB host
  • Ethernet
  • HDMI (1280x1024)
  • 2x 46 pin headers
 
That is just a little bit of information on the Beaglebone Black, check out the link below if you wish for more.

Beagleboards website


Project Description:

Using the BeagleBones pulse width modulation (PWM) an analog-to-digital converter (ADC) pins I plan to make an autonomous robot. I have done something similar with an Arduino before, but wanted to branch off from that to something more powerful. Being that I have never done anything with it before I decided to keep it as simple as possible using two continuous servos for the wheels and a standard servo to look with an infrared (IR) distance sensor.