diff --git a/Files_4_thesis/Different_controllers/docking_with_PID_controller.asv b/Files_4_thesis/Different_controllers/docking_with_PID_controller.asv deleted file mode 100644 index 22542b32c5e9ec859e4c8da87dd064f80e83c93d..0000000000000000000000000000000000000000 --- a/Files_4_thesis/Different_controllers/docking_with_PID_controller.asv +++ /dev/null @@ -1,470 +0,0 @@ -clc; -close all; -clear all; -%% Import data and time conversion - -% data 1: 556 ros messages for geometry_msgs/Twist -% 557 ros messages for geometry_msgs/PoseStamped -% y-axis gains: -% (010816_1718) best!!! -% P = .4; I = 0; D = 0; - -% y-axis gains: -% (280716_2024) better!!! -% P = .44; I = 0; D = 0; - -% theta-axis gains: -% P = .08; I = 0; D = 0; - -% y-axis gains: -% (280716_2002) -% P = .46; I = 0; D = 0; - -% theta-axis gains: -% P = .08; I = 0; D = 0; - -Pose_Matrix_data_1 = csvread('POSE_with_Py0.86_Iy0_Dy0.002ANDPt0.08_It0_Dt0.txt',1,0); -Vel_Matrix_data_1 = csvread('VEL_with_Py0.86_Iy0_Dy0.002ANDPt0.08_It0_Dt0.txt',1,0); - -% time in position -TimeP_ros_data_1 = Pose_Matrix_data_1(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationP_data_1 = (TimeP_ros_data_1(size(TimeP_ros_data_1,1),:) - TimeP_ros_data_1(1,:))*10^(-9); - -t_P_sec_data_1 = 0:durationP_data_1/size(TimeP_ros_data_1,1):durationP_data_1; -t_P_sec_data_1(:,size(t_P_sec_data_1,2)) = []; - -% time in vel -TimeV_ros_data_1 = Vel_Matrix_data_1(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationV_data_1 = (TimeV_ros_data_1(size(TimeV_ros_data_1,1),:) - TimeV_ros_data_1(1,:))*10^(-9); - -t_V_sec_data_1 = 0:durationV_data_1/size(TimeV_ros_data_1,1):durationV_data_1; -t_V_sec_data_1(:,size(t_V_sec_data_1,2)) = []; - -% ----------------------------------------------------------------------------------------------------- -% data 2: 588 ros messages for geometry_msgs/Twist -% 589 ros messages for geometry_msgs/PoseStamped -% y-axis gains: -% P = .5; I = 0.001; D = 0.03; - -% theta-axis gains: -% P = .28; I = 0.1; D = 0.15; - -Pose_Matrix_data_2 = csvread('POSE_with_Py0.66_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); -Vel_Matrix_data_2 = csvread('VEL_with_Py0.66_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); - -% time in position -TimeP_ros_data_2 = Pose_Matrix_data_2(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationP_data_2 = (TimeP_ros_data_2(size(TimeP_ros_data_2,1),:) - TimeP_ros_data_2(1,:))*10^(-9); - -t_P_sec_data_2 = 0:durationP_data_2/size(TimeP_ros_data_2,1):durationP_data_2; -t_P_sec_data_2(:,size(t_P_sec_data_2,2)) = []; - -% time in vel -TimeV_ros_data_2 = Vel_Matrix_data_2(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationV_data_2 = (TimeV_ros_data_2(size(TimeV_ros_data_2,1),:) - TimeV_ros_data_2(1,:))*10^(-9); - -t_V_sec_data_2 = 0:durationV_data_2/size(TimeV_ros_data_2,1):durationV_data_2; -t_V_sec_data_2(:,size(t_V_sec_data_2,2)) = []; - -% ----------------------------------------------------------------------------------------------------- -% data 3: 538 ros messages for geometry_msgs/Twist -% 539 ros messages for geometry_msgs/PoseStamped -% y-axis gains: -% P = .44; I = .0005; D = 0.15; - -% theta-axis gains: -% P = .08; I = 0; D = 0; - -Pose_Matrix_data_3 = csvread('POSE_with_Py0.86_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); -Vel_Matrix_data_3 = csvread('VEL_with_Py0.86_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); - -% time in position -TimeP_ros_data_3 = Pose_Matrix_data_3(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationP_data_3 = (TimeP_ros_data_3(size(TimeP_ros_data_3,1),:) - TimeP_ros_data_3(1,:))*10^(-9); - -t_P_sec_data_3 = 0:durationP_data_3/size(TimeP_ros_data_3,1):durationP_data_3; -t_P_sec_data_3(:,size(t_P_sec_data_3,2)) = []; - -% time in vel -TimeV_ros_data_3 = Vel_Matrix_data_3(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationV_data_3 = (TimeV_ros_data_3(size(TimeV_ros_data_3,1),:) - TimeV_ros_data_3(1,:))*10^(-9); - -t_V_sec_data_3 = 0:durationV_data_3/size(TimeV_ros_data_3,1):durationV_data_3; -t_V_sec_data_3(:,size(t_V_sec_data_3,2)) = []; - -% ----------------------------------------------------------------------------------------------------- -% data 4: 450 ros messages for geometry_msgs/Twist -% 451 ros messages for geometry_msgs/PoseStamped -% y-axis gains: -% P = .86; I = 0; D = 0.002; - -% theta-axis gains: -% P = .08; I = 0; D = 0; - -Pose_Matrix_data_4 = csvread('POSE_with_Py0.86_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); -Vel_Matrix_data_4 = csvread('VEL_with_Py0.86_Iy0_Dy0.1ANDPt0.08_It0_Dt0.txt',1,0); - -% time in position -TimeP_ros_data_4 = Pose_Matrix_data_4(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationP_data_4 = (TimeP_ros_data_4(size(TimeP_ros_data_4,1),:) - TimeP_ros_data_4(1,:))*10^(-9); - -t_P_sec_data_4 = 0:durationP_data_4/size(TimeP_ros_data_4,1):durationP_data_4; -t_P_sec_data_4(:,size(t_P_sec_data_4,2)) = []; - -% time in vel -TimeV_ros_data_4 = Vel_Matrix_data_4(:,1); % ros time, needs to be converted to sec... - -% duriation = end_time - start_time - durationV_data_4 = (TimeV_ros_data_4(size(TimeV_ros_data_4,1),:) - TimeV_ros_data_4(1,:))*10^(-9); - -t_V_sec_data_4 = 0:durationV_data_4/size(TimeV_ros_data_4,1):durationV_data_4; -t_V_sec_data_4(:,size(t_V_sec_data_4,2)) = []; - - -%% Pose estimation - -%data 1: -% when using marker pose ,,,, -Pose_X_data_1 = Pose_Matrix_data_1(:,4); -Pose_Y_data_1 = Pose_Matrix_data_1(:,3); -Theta_data_1 = Pose_Matrix_data_1(:,5); - - -% when using robot odometry ,,,, -% Pose_X = Pose_Matrix(:,2); -% Pose_Y = Pose_Matrix(:,3); -% Theta = Pose_Matrix(:,7); - -% Extracting reference values when the robot is manually docked! -ref_X_data_1 = Pose_X_data_1(size(Pose_X_data_1,1)); -ref_Y_data_1 = Pose_Y_data_1(size(Pose_Y_data_1,1)); -ref_Theta_data_1 = Theta_data_1(size(Theta_data_1,1)); -ref_Pose_data_1 =[ref_X_data_1;ref_Y_data_1]; - -%data 2: -% when using marker pose ,,,, -Pose_X_data_2 = Pose_Matrix_data_2(:,4); -Pose_Y_data_2 = Pose_Matrix_data_2(:,3); -Theta_data_2 = Pose_Matrix_data_2(:,5); - -% when using robot odometry ,,,, -% Pose_X = Pose_Matrix(:,2); -% Pose_Y = Pose_Matrix(:,3); -% Theta = Pose_Matrix(:,7); - -% Extracting reference values when the robot is manually docked! -ref_X_data_2 = Pose_X_data_2(size(Pose_X_data_2,1)); -ref_Y_data_2 = Pose_Y_data_2(size(Pose_Y_data_2,1)); -ref_Theta_data_2 = Theta_data_2(size(Theta_data_2,1)); -ref_Pose_data_2 =[ref_X_data_2;ref_Y_data_2]; - -%data 3: -% when using marker pose ,,,, -Pose_X_data_3 = Pose_Matrix_data_3(:,4); -Pose_Y_data_3 = Pose_Matrix_data_3(:,3); -Theta_data_3 = Pose_Matrix_data_3(:,5); - -% when using robot odometry ,,,, -% Pose_X = Pose_Matrix(:,2); -% Pose_Y = Pose_Matrix(:,3); -% Theta = Pose_Matrix(:,7); - -% Extracting reference values when the robot is manually docked! -ref_X_data_3 = Pose_X_data_3(size(Pose_X_data_3,1)); -ref_Y_data_3 = Pose_Y_data_3(size(Pose_Y_data_3,1)); -ref_Theta_data_3 = Theta_data_3(size(Theta_data_3,1)); -ref_Pose_data_3 =[ref_X_data_3;ref_Y_data_3]; - -%data 4: -% when using marker pose ,,,, -Pose_X_data_4 = Pose_Matrix_data_4(:,4); -Pose_Y_data_4 = Pose_Matrix_data_4(:,3); -Theta_data_4 = Pose_Matrix_data_4(:,5); - -% when using robot odometry ,,,, -% Pose_X = Pose_Matrix(:,2); -% Pose_Y = Pose_Matrix(:,3); -% Theta = Pose_Matrix(:,7); - -% Extracting reference values when the robot is manually docked! -ref_X_data_4 = Pose_X_data_4(size(Pose_X_data_4,1)); -ref_Y_data_4 = Pose_Y_data_4(size(Pose_Y_data_4,1)); -ref_Theta_data_4 = Theta_data_4(size(Theta_data_4,1)); -ref_Pose_data_4 =[ref_X_data_4;ref_Y_data_4]; - - -thresh_X = .001; -theta = 0:.001:2*pi; - -% needs to be adjusted manually if docking platform is replaced! -ref_x = .2; -ref_y = .00903123; - -x_circle = thresh_X*cos(theta) + ref_x; % ref_X needs to be recorded -y_circle = thresh_X*sin(theta) + ref_y; % ref_Y needs to be recorded - - -%% Velocity estimation - -% data 1: -Vel_X_data_1 = Vel_Matrix_data_1(:,2); -Vel_Y_data_1 = Vel_Matrix_data_1(:,3); -Omega_Z_data_1 = Vel_Matrix_data_1(:,7); - -% data 2: -Vel_X_data_2 = Vel_Matrix_data_2(:,2); -Vel_Y_data_2 = Vel_Matrix_data_2(:,3); -Omega_Z_data_2 = Vel_Matrix_data_2(:,7); - -% data 3: -Vel_X_data_3 = Vel_Matrix_data_3(:,2); -Vel_Y_data_3 = Vel_Matrix_data_3(:,3); -Omega_Z_data_3 = Vel_Matrix_data_3(:,7); - -% data 3: -Vel_X_data_4 = Vel_Matrix_data_4(:,2); -Vel_Y_data_4 = Vel_Matrix_data_4(:,3); -Omega_Z_data_4 = Vel_Matrix_data_4(:,7); - - -%% Plots - -% for the presenation all pose estimation(x,y,theta) in one plot - -% figure; -% plot(t_P_sec,Pose_X,'b',t_P_sec,Pose_Y,'r',t_P_sec,Theta,'g'); -% -% title('Marker Pose'); -% xlabel('Time [sec]'); -% ylabel('Pose'); -% legend('X [m]','Y [m]','\theta [rad]'); -% grid on - -% marker position -figure; -subplot(3,1,1); -plot(t_P_sec_data_1,Pose_X_data_1); -hold on -plot(t_P_sec_data_2,Pose_X_data_2,'r'); -hold on -plot(t_P_sec_data_3,Pose_X_data_3,'g'); -hold on -plot(t_P_sec_data_4,Pose_X_data_4,'m'); - - -title('Marker X-axis'); -% xlabel('Time [sec]'); -ylabel('X [m]'); -grid on - -subplot(3,1,2); -plot(t_P_sec_data_1,Pose_Y_data_1); -hold on -plot(t_P_sec_data_2,Pose_Y_data_2,'r'); -hold on -plot(t_P_sec_data_3,Pose_Y_data_3,'g'); -hold on -plot(t_P_sec_data_4,Pose_Y_data_4,'m'); - -title('Marker Y-axis'); -% xlabel('Time [sec]'); -ylabel('Y [m]'); -grid on - -subplot(3,1,3); -plot(t_P_sec_data_1,Theta_data_1); -hold on -plot(t_P_sec_data_2,Theta_data_2,'r'); -hold on -plot(t_P_sec_data_3,Theta_data_3,'g'); -hold on -plot(t_P_sec_data_3,Theta_data_3,'g'); - - -title('Marker \theta-axis'); -xlabel('Time [sec]'); -ylabel('\theta [rad]'); -grid on - -% control signals -figure; -subplot(3,1,1); - -plot(t_V_sec_data_1,Vel_X_data_1,'LineWidth',1.2); -hold on -plot(t_V_sec_data_2,Vel_X_data_2,'r','LineWidth',1.2); -hold on -plot(t_V_sec_data_3,Vel_X_data_3,'g','LineWidth',1.2); - -title('Control Signal X-axis'); -% xlabel('Time [sec]'); -ylabel('V_x [m/s]'); -grid on -% axis([0 46 -.01 .11]); - -subplot(3,1,2); -plot(t_V_sec_data_1,Vel_Y_data_1,'LineWidth',1.2); -hold on -plot(t_V_sec_data_2,Vel_Y_data_2,'r','LineWidth',1.2); -hold on -plot(t_V_sec_data_3,Vel_Y_data_3,'g','LineWidth',1.2); - -title('Control Signal Y-axis'); -% xlabel('Time [sec]'); -ylabel('V_y [m/s]'); -grid on -% axis([0 46 -.2 .1]); - -subplot(3,1,3); -plot(t_V_sec_data_1,Omega_Z_data_1,'LineWidth',1.2); -hold on -plot(t_V_sec_data_2,Omega_Z_data_2,'r','LineWidth',1.2); -hold on -plot(t_V_sec_data_3,Omega_Z_data_3,'g','LineWidth',1.2); - -title('Control Signal \theta-axis'); -xlabel('Time [sec]'); -ylabel('\omega [rad/s]'); -grid on -% axis([0 46 -.1 .15]); - -% Trajectory -% figure; -% plot(Pose_Y_data_1,Pose_X_data_1,'b',ref_Y_data_1,ref_X_data_1,'k*'); -% hold on -% plot(Pose_Y_data_2,Pose_X_data_2,'r',ref_Y_data_2,ref_X_data_2,'k*'); -% -% hold on -% plot(Pose_Y_data_3,Pose_X_data_3,'g',ref_Y_data_3,ref_X_data_3,'k*'); -% - -% -% for k = Pose_X_data_1(1):Pose_X_data_1(size(Pose_X_data_1,1)) -% x_arrow(k) = -% -% end -% -% x_arrow = linspace(Pose_X_data_1(1),Pose_X_data_1(size(Pose_X_data_1,1)),150); -% y_arrow = linspace(Pose_Y_data_1(1),Pose_Y_data_1(size(Pose_Y_data_1,1)),150); -% -% Vx = gradient(x_arrow,.01); -% Vy = gradient(y_arrow,.01); -% -% figure; -% plot(y_arrow,x_arrow,'b--','LineWidth',.5); -% % hold on -% % quiver(y_arrow,x_arrow,Vy,Vx,'r--','LineWidth',1.5); -% - - -figure; -subplot(1,3,1); -plot(Pose_Y_data_1,Pose_X_data_1,'b','LineWidth',2); -hold on -plot(Pose_Y_data_2,Pose_X_data_2,'r','LineWidth',2); -hold on -plot(Pose_Y_data_3,Pose_X_data_3,'g','LineWidth',2); -hold on -plot(y_circle,x_circle,'k--','LineWidth',3.4) - -title('Docking Trajectroy (Whole area)'); -xlabel('Y [m]'); -ylabel('X [m]'); -axis([-.3 .4 .18 1.4]); -grid on - -subplot(1,3,2); -plot(Pose_Y_data_1,Pose_X_data_1,'b','LineWidth',2); -hold on -plot(Pose_Y_data_2,Pose_X_data_2,'r','LineWidth',2); -hold on -plot(Pose_Y_data_3,Pose_X_data_3,'g','LineWidth',2); -hold on -plot(y_circle,x_circle,'k--','LineWidth',3.4); -title('Docking Trajectroy (SM zone)'); -xlabel('Y [m]'); -ylabel('X [m]'); -axis([-.01 0.06 .195 .32]); -grid on - -subplot(1,3,3); -plot(Pose_Y_data_1,Pose_X_data_1,'b','LineWidth',2); -hold on -plot(Pose_Y_data_2,Pose_X_data_2,'r','LineWidth',2); -hold on -plot(Pose_Y_data_3,Pose_X_data_3,'g','LineWidth',2); -hold on -plot(y_circle,x_circle,'k--','LineWidth',3.4); -title('Docking Trajectroy (reference area)'); -xlabel('Y [m]'); -ylabel('X [m]'); -axis([0.006 .012 .198 .204]); -grid on -legend('P_y = 0.86, I_y = 0, D_y = 0.002', 'P_y = 0.66, I_y = 0, D_y = 0.1','P_y = 0.86, I_y = 0, D_y = 0.1' ,'Reference Position'); - - -figure; -subplot(2,1,1); -plot(diff(TimeP_ros_data_1)/1e9,'g') -hold on -plot (diff(t_P_sec_data_1),'k--') -title('Position sampling time'); -ylabel('Sampling time'); -legend('ROS calc.','Real time calc. [sec]','Orientation','horizontal'); -% grid on -% axis([0 428 .05 .15]); - -subplot(2,1,2); -plot(diff(TimeV_ros_data_1)/1e9,'g'); -hold on -plot (diff(t_V_sec_data_1),'k--') -title('Velocity sampling time'); -xlabel('samples'); -ylabel('Sampling time'); -% legend('ROS calc.','Ordinary calc.','Orientation','horizontal'); -% grid on -% axis([0 428 -.005 .025]); -% -% subplot(3,1,3); -% plot(diff(TimeV_ros_data_1)/1e9,'g') -% hold on -% plot (diff(t_V_sec_data_1),'k--') -% xlabel('samples'); -% ylabel('time step'); -% axis([150 250 0 .02]); - -figure; -subplot(3,1,1); -plot(diff(Pose_X_data_1)); -title('X-Pose diff'); -xlabel('samples'); -ylabel('X difference [m]'); -grid on - -subplot(3,1,2); -plot(diff(Pose_X_data_1)); -title('Y-Pose diff'); -xlabel('samples'); -ylabel('Y difference [m]'); -grid on - -subplot(3,1,3); -plot(diff(Theta_data_1)); -title('\theta-Pose diff'); -xlabel('samples'); -ylabel('\theta difference [rad]'); -grid on \ No newline at end of file diff --git a/Files_4_thesis/Laser Scanner Results/ROStime_sectime.jpg b/Files_4_thesis/Laser Scanner Results/ROStime_sectime.jpg index 1903b0f199b0b67b6508feeac71758f1b59b8a1c..26f3ff03d5382f1c6de50af0a539cdafd20327e2 100644 Binary files a/Files_4_thesis/Laser Scanner Results/ROStime_sectime.jpg and b/Files_4_thesis/Laser Scanner Results/ROStime_sectime.jpg differ diff --git a/Files_4_thesis/Laser Scanner Results/obst_vs_angle.jpg b/Files_4_thesis/Laser Scanner Results/obst_vs_angle.jpg deleted file mode 100644 index 9250c19cabc7aa96365071e5e036d455bad818d0..0000000000000000000000000000000000000000 Binary files a/Files_4_thesis/Laser Scanner Results/obst_vs_angle.jpg and /dev/null differ diff --git a/Files_4_thesis/Laser Scanner Results/scanner_rob.jpg b/Files_4_thesis/Laser Scanner Results/scanner_rob.jpg index 472b83d00f0eab3f5eb1b526ef17c948d4374280..a3579692a2c9b1bcda2ac1a0338e4239e2513b12 100644 Binary files a/Files_4_thesis/Laser Scanner Results/scanner_rob.jpg and b/Files_4_thesis/Laser Scanner Results/scanner_rob.jpg differ diff --git a/Files_4_thesis/Report.docx b/Files_4_thesis/Report.docx index f1d67db941291be2d2110c35664acc028367d4e8..a0fc6f2fe1ff70d6d776a1efc3014dfcc9757c4f 100644 Binary files a/Files_4_thesis/Report.docx and b/Files_4_thesis/Report.docx differ diff --git a/Files_4_thesis/scanner_analysis.m b/Files_4_thesis/scanner_analysis.m index dcca41027ac1b2e26f52e8bda1ad222e4b786fad..18b17e84905aae9dea4dc56d3b49726f4bb965b7 100644 --- a/Files_4_thesis/scanner_analysis.m +++ b/Files_4_thesis/scanner_analysis.m @@ -237,26 +237,26 @@ for i = 1:points_out end figure; -% subplot(2,1,1); -plot(s_angle_out,s_val_out); +subplot(1,2,2); +plot(s_angle_out,s_val_out,'b','LineWidth',2); hold on plot(s_angle_out,dist_to_obst,'r','LineWidth',10); xlabel('Angle [rad]'); ylabel('Distance to Obstacle [m]'); title('Obstacle distance vs Angle'); -legend('Obstacle distance','Laser scanner safety line 10 cm') +% legend('Obstacle distance','Laser scanner safety line 10 cm') grid on; -axis([-2.2 2.2 0 5]); +axis([-2.23 2.23 -1 10]); -% subplot(2,1,2) -figure; -plot(X_out,Y_out); +subplot(1,2,1) +% figure; +plot(X_out,Y_out,'b','LineWidth',2); hold on plot(X_obst_out,Y_obst_out,'r-','LineWidth',4) xlabel('X [m]'); ylabel('Y [m]'); title('Scanner Analysis in robot coordinate system ( X_r - Y_r )'); -legend('Obstacles','Laser scanner safety curve (r = 10 cm)'); +legend('Obstacles','Laser scanner safety margin (r = 10 cm)'); grid on; axis([-1.2 5 -3.5 1.5]);