User Tools

Site Tools


drexel_darwin_source_codes_explanation

Explanation of Source Codes

Motivation

How a robot operates is pretty much dependent on the algorithm that it reads.

But before we go to that stage, we need to understand how to just simply make the robot move.

This section explains about what each part of the source code means and give examples of a short program.

Code used will be Cpp.

As mentioned previously, since there is no GUI available in DASL's very own Darwin, you cannot use gedit to modify and play around with the codes in Darwin.

Instead, import the codes into your own computer to edit and export them back into Darwin to execute, via the use of the Ubuntu Terminal.

Search the Internet for the relevant codes to achieve this.

These keywords should help in your search: scp, chmod.

Another way you can modify the source codes would be to use the command sudo nano /path/to/CPp/text/ to open up the text file and edit right inside Darwin. vi or vim is another way to do so but i prefer nano.

Walking

With reference to the ball following tutorial, I have made a short summary of what is the role of each part of the ball_following tutorial to contributing the making the robot move here under the name “codetutorial”.

The original codes are downloaded from here.

Explanations of each part are based on this website.

I will be referring to DARwIn-OP_ROBOTIS_v1.5.0 source codes.

NOTE: It seems that the source code titled “LinuxCamera.cpp” is missing the line “#include <sys/stat.h>“. Without it the program would not work. There is a patch to fix this but I did not use it. So far, it worked fine anyway with the above correction.

In the “workspace”, with reference to this code, I edited the program such that the value of X_MOVE_AMPLITUDE will increase each time one presses a button.

The video shows how the robot move faster gradually each time i press the return key.

Walking::GetInstance()->X_MOVE_AMPLITUDE = 10.0;//initialize value of variables
Walking::GetInstance()->A_MOVE_AMPLITUDE = 10.0;
 
while(count<8)//limit max value
{ 	Walking::GetInstance()->Start();//start walking
	showvalue();
	printf("Press the ENTER key to increase value! \ncount=%d \n", count);	
	getchar();//wait for user interference
	inc();//increase value
	count++;
} 
	Walking::GetInstance()->Stop(); //walking stops when variables reahes max value
    return 0;
}
 
void showvalue()
{
	printf("Walking::GetInstance()->X_MOVE_AMPLITUDE= %f\n", Walking::GetInstance()->X_MOVE_AMPLITUDE);
}
 
void inc()
{
	Walking::GetInstance()->X_MOVE_AMPLITUDE+=10;
}


As mentioned here, among the two variables that affect walking speed, the variable X_MOVE_AMPLITUDE controls the length of stride while the variable PERIOD_TIME affect the frequency of taking each step. The following are the codes I used to make Darwin walk slower by decreasing the frequency of it making each step, ie. increasing the variable PERIOD_TIME.

void inc()
{
	Walking::GetInstance()->PERIOD_TIME+=50;
}


My codes can be found here.

Vision

Ok plan is to export vision captured from Darwin's camera to OpenCV totally and ignore how it is done locally with the LinuxCamera class in Darwin.

Go here for a guide to install OpenCV via Ubuntu terminal.

NOTE: The previous version in DASL's very own Darwin is Maverick-10.10 which is given the End-Of-Life status. The address of the files that one needs to access for upgrade and installation of libraries etc. has now been changed. Some changes need to be done in order to successfully install OpenCV the way it is stated in the link above. Refer [http://www.techskater.com/random/installing-ubuntu-gutsy-packages-via-apt-get-when-eoled/|here]] for details. Hence, if you are working on an outdated version you know what to do.

However, based on research and advices received, it is not desirable to use image processing on Darwin it self as it will be slow.

The storage space is also little.

(TO BE CONTINUED)

drexel_darwin_source_codes_explanation.txt · Last modified: 2016/11/06 19:11 by dwallace