Hi guys,
My program involves trajectory planning using cubic spline method for a robotic arm. In the process, I had to calculate joint angles for each point in the path. In the last few lines of the code I need to write the values for counter and theta1 into a text file which I called "Test.txt". I am doing this using a nested for loop(the counter runs until it reaches 19 and hence need 19 theta1 values corresponding to it). However, I can't get all the theta1 values transferred to the text file.The statement within my inner loop is wrong and don't know how to fix it. I'd appreciate any help.
My program involves trajectory planning using cubic spline method for a robotic arm. In the process, I had to calculate joint angles for each point in the path. In the last few lines of the code I need to write the values for counter and theta1 into a text file which I called "Test.txt". I am doing this using a nested for loop(the counter runs until it reaches 19 and hence need 19 theta1 values corresponding to it). However, I can't get all the theta1 values transferred to the text file.The statement within my inner loop is wrong and don't know how to fix it. I'd appreciate any help.
Code:
for(i=0;i<num_via;i++){
current_time = GetTickCount();
//joint[0] = mult_joint[i][0];
//joint[1] = mult_joint[i][1];
//joint[2] = mult_joint[i][2];
//joint[3] = mult_joint[i][3];
//vel[0] = a1[i][0];
//vel[1] = a1[i][1];
//vel[2] = a1[i][2];
//vel[3] = a1[i][3];
//accel[0] = a2[i][0];
//accel[1] = a2[i][1];
//accel[2] = a2[i][2];
//accel[3] = a2[i][3];
t = ((current_time-start_time)/1000);
tf = compl_time/num_via;
counter = 0;
while( t < ((i+1)*tf)){
//MoveWithConfVelAcc(joint,vel,accel);
current_time = GetTickCount();
counter ++;
theta1 = a0[i][0] + a1[i][0]*(t-i*tf) + a2[i][0]*pow((t-i*tf),2) + a3[i][0]*pow((t-i*tf),3);
theta2 = a0[i][1] + a1[i][1]*(t-i*tf) + a2[i][1]*pow((t-i*tf),2) + a3[i][1]*pow((t-i*tf),3);
d_3 = a0[i][2] + a1[i][2]*(t-i*tf) + a2[i][2]*pow((t-i*tf),2) + a3[i][2]*pow((t-i*tf),3);
theta4 = a0[i][3] + a1[i][3]*(t-i*tf) + a2[i][3]*pow((t-i*tf),2) + a3[i][3]*pow((t-i*tf),3);
t = ((current_time-start_time)/1000);
if(counter%1000000 == 0){
cout<< theta1 <<" "<<t<<endl;
}
}
//======================================
ofstream myfile;
myfile.open("Test.txt");
for(int num1=0; num1<20; num1++){
for(int num2=0; num2<20; num2++){
theta1; //problem occurs here
}
counter=num1;
myfile<<counter<<" "<<theta1<<endl;
}
myfile.close();
}
cin>> d;
}
Comment