Friday, 3 February 2012

robotic arm data structure






MAIN.CPP

#include <iostream>
#include "robotArm.h"
#include <cmath>

using namespace std;

int main()
{
   bool k = true;
   int a,b,c,d,e,f;
   int w;
   robotArm p;

while (k)
{
    cout<<"please insert your value corresponding with the forward kinematics problem";
    cout<<endl<<endl;
    cout<<"value of length 1"<<endl;
    cin>>a;
    cout<<"value of length 2"<<endl;
    cin>>b;
    cout<<"value of length 3"<<endl;
    cin>>c;
    cout<<"value of angle 1"<<endl;
    cin>>d;
    cout<<"value of angle 2"<<endl;
    cin>>e;
    cout<<"value of angle 3"<<endl;
    cin>>f;
    cout<<endl;
    cout<<"Xhand :"<<p.calculateXhand(a,b,c,d,e,f)<<endl;
    cout<<"Yhand :"<<p.calculateYhand(a,b,c,d,e,f)<<endl;
    cout<<"Zhand :"<<p.calculateZhand(d,e,f)<<endl;
    cout<<"X1hand :"<<p.calculateX1hand(a,d)<<endl;
    cout<<"Y1hand :"<<p.calculateY1hand(a,d)<<endl;
    cout<<"X2hand :"<<p.calculateX2hand(a,b,d,e)<<endl;
    cout<<"Y2hand :"<<p.calculateY2hand(a,b,d,e)<<endl;

    cout<<endl;
    cout<<"if want to CONTINUE, please press 1 and others to determination this program"<<endl;

    cin>>w;
    cout<<endl;
    if (w==1)
    {
        k=true;
    }
    else
    {
        k=false;
    }
}

cout<<"PROGRAM IS NOW TERMINATED"<<endl;
return 0;
}


robotArm.cpp

#include "robotArm.h"
#include <iostream>
#include <cmath>
#include<string>

double robotArm::calculateXhand(double a,double b,double c,double d,double e,double f)
{
    float Xhand;
    Xhand=a*cos(d)+b*cos(d+e)+c*cos(d+e+f);
    return Xhand;
}
double robotArm::calculateYhand(double a,double b,double c,double d,double e,double f)
{
   float Yhand;
    Yhand=a*cos(d)+b*cos(d+e)+c*cos(d+e+f);
    return Yhand;
}
double robotArm::calculateZhand(double d,double e,double f)
{
    double Zhand;
    Zhand=d+e+f;
    return Zhand;
}
double robotArm::calculateX1hand(double a,double d)
{
    double X1hand;
    X1hand=a*cos(d);
    return X1hand;
}
double robotArm::calculateY1hand(double a,double d)
{
    double Y1hand;
    Y1hand=a*sin(d);
    return Y1hand;
}
double robotArm::calculateX2hand(double a,double b,double d,double e)
{
    double X2hand;
    X2hand=a*cos(d)+b*cos(d+e);
    return X2hand;
}
double robotArm::calculateY2hand(double a,double b,double d,double e)
{
    double Y2hand;
    Y2hand=a*sin(d)+b*sin(d+e);
    return Y2hand;
}



robotArm.h

#define ROBOTARM_H


class robotArm
{
    public:

        void print()const;
        double calculateXhand(double a,double b,double c,double d,double e,double f);
        double calculateYhand(double a,double b,double c,double d,double e,double f);
        double calculateZhand(double d,double e,double f);
        double calculateX1hand(double a,double d);
        double calculateY1hand(double a,double d);
        double calculateX2hand(double a,double b,double d,double e);
        double calculateY2hand(double a,double b,double d,double e);


    protected:
    private:
    void Xhand();
    void Yhand();
    void Zhand();
    void X1hand();
    void Y1hand();
    void X2hand();
    void Y2hand();
};

No comments:

Post a Comment