Click here to Skip to main content
15,922,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
David Crow18-Oct-06 9:10
David Crow18-Oct-06 9:10 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
Christian Graus18-Oct-06 12:21
protectorChristian Graus18-Oct-06 12:21 
GeneralRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
sahoong19-Oct-06 5:50
sahoong19-Oct-06 5:50 
AnswerRe: 4TH ORDER RUNGE-KUTTA ALGORITHM Pin
JWood18-Oct-06 15:08
JWood18-Oct-06 15:08 
QuestionHandling exception Pin
Demian Panello18-Oct-06 5:59
Demian Panello18-Oct-06 5:59 
AnswerRe: Handling exception Pin
Zac Howland18-Oct-06 6:26
Zac Howland18-Oct-06 6:26 
GeneralRe: Handling exception Pin
Demian Panello18-Oct-06 7:11
Demian Panello18-Oct-06 7:11 
QuestionFOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
sahoong18-Oct-06 5:57
sahoong18-Oct-06 5:57 
The codes that I have written so far is below:

// Simulation of the Dynamics of a 2-Link Pan-Tilt Robotic Manipulator
/* This programme calculates the Velocity, Acceleration and the angles of inclination
of the two links of the Spherical Pointing Motor, which is essentially a Two-Link Robotic
Manipulator*/


//#include
//#include
//#include
//#include
//#include
//#include

// Precompiler Directives

#include
#include


// Constants Declaration

#define n (int) 2
#define m1 (float) 0.05
#define m2 (float) 0.03
#define r1 (float) 0.04
#define r2 (float) 0.06
#define ra (float) 0.04
#define rb (float) 0.06
#define l (float) 0.05
#define d (float) 0.02
#define acc_due_gravity (float) 9.81

class AngVel1
{
public:
};

class AngAccln1
{
public:
};

class AngVel2
{
public:
};

class AngAccln2
{
public:
}

/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/


// Declaration of variables (Robot Parameters)

float t;




// Prototypes

float TorqueVal(float t);
double Runge_Kutta ();

double AngVel1 (double om1){

return om1;
}

double AngAccln1 (double t, double om1, double tetha1, double tetha2){
t = 0.1;
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d) * om1*om2*sintetha2*costetha2 - m2*g*d*costetha1*costetha2)/
om1*(m1(ra*ra + rb*rb)/4 + m1(h1*h1)/3 + m2((r2*r2)(1+sinsqtetha2)/4 + m2*h2*h2*cossqtetha2/3 + m2*d*d*cossqtetha2);
}

double AngVel2 (double om2){
return om2;
}

double AngAccln2 (double t, double om1, double om2, double tetha1, double tetha2){
t=0.4;
return (tau2 + (m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om1*sintetha2*costetha2) - m2*g*d*sintetha1*sintetha2)/
om2*m2(r2*r2/4 + h2*h2/3 + d*d;

double RK(double y){
double k1,k2,k3,k4;
k1=h*fn(y);
k2=h*fn(y+(k1/2.0));
k3=h*fn(y+(k2/2.0));
k4=h*fn(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}

// The Main Routine

int main()
{



// Torque Function
float TorqueVal1(float t)
{
t = 0.1;
return t;

}

// Runge-Kutta Function

double RK(double y){
double k1,k2,k3,k4;
k1=h*fn(y);
k2=h*fn(y+(k1/2.0));
k3=h*fn(y+(k2/2.0));
k4=h*fn(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}

double RK(double l){
double v1,v2,v3,v4;
v1=h*fn(l);
v2=h*fn(l+(k1/2.0));
v3=h*fn(l+(k2/2.0));
v4=h*fn(l+k3);
return l+(v1/6.0)+(v2/3.0)+(v3/3.0)+(v4/6.0);
}




}


i am attempting to simulate the dynamics of a 2-link pan-tilt robot. Two second order ODE were generated. As a requirement of the Runge-Kutta, each of the two second-order ODE was converted to 2 first order ODE thereby making four equations in all.

I was not using a class before and I just started packing the four equation into classes.

For further explanation or clarification, please, mail me to olaskg@yahoo.ie.

Thank you.


skg


skg
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Mark Salsbery18-Oct-06 6:46
Mark Salsbery18-Oct-06 6:46 
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
David Crow18-Oct-06 8:07
David Crow18-Oct-06 8:07 
AnswerRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Chris Losinger18-Oct-06 8:18
professionalChris Losinger18-Oct-06 8:18 
GeneralRe: FOURTH-ORDER RUNGE-KUTTA ALGORITHM Pin
Jörgen Sigvardsson18-Oct-06 11:32
Jörgen Sigvardsson18-Oct-06 11:32 
Questiontcp receive Pin
Archyami18-Oct-06 5:22
Archyami18-Oct-06 5:22 
AnswerRe: tcp receive Pin
Mark Salsbery18-Oct-06 5:28
Mark Salsbery18-Oct-06 5:28 
GeneralRe: tcp receive Pin
Archyami18-Oct-06 6:58
Archyami18-Oct-06 6:58 
GeneralRe: tcp receive Pin
Mark Salsbery18-Oct-06 7:02
Mark Salsbery18-Oct-06 7:02 
GeneralRe: tcp receive Pin
Archyami18-Oct-06 7:14
Archyami18-Oct-06 7:14 
QuestionNetwork Protocol Analyzer? Pin
Andy Rama18-Oct-06 3:07
Andy Rama18-Oct-06 3:07 
AnswerRe: Network Protocol Analyzer? Pin
Mark Salsbery18-Oct-06 6:58
Mark Salsbery18-Oct-06 6:58 
Questionowner darw & xp theme problem Pin
314159265318-Oct-06 2:45
314159265318-Oct-06 2:45 
AnswerRe: owner darw & xp theme problem Pin
Jörgen Sigvardsson18-Oct-06 11:38
Jörgen Sigvardsson18-Oct-06 11:38 
Questionfinding type of device connected to USB port Pin
pavan_sw18-Oct-06 2:31
pavan_sw18-Oct-06 2:31 
AnswerRe: finding type of device connected to USB port Pin
Mark Salsbery18-Oct-06 5:49
Mark Salsbery18-Oct-06 5:49 
Questionfinding type of device connected to USB port Pin
pavan_sw18-Oct-06 2:30
pavan_sw18-Oct-06 2:30 
AnswerRe: finding type of device connected to USB port Pin
David Crow18-Oct-06 3:00
David Crow18-Oct-06 3:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.