Advertisement
Ostu

Untitled

Jan 10th, 2023
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.10 KB | None | 0 0
  1. %%
  2. sampleTime = 0.05;
  3. initPose = [path(1,:)'; 0];
  4. tVec = 0:sampleTime:100;
  5.  
  6. % rower jednokolowy
  7. unicycle = unicycleKinematics("VehicleInputs","VehicleSpeedHeadingRate");
  8.  
  9. % naped roznicowy
  10. diffDrive = differentialDriveKinematics("VehicleInputs","VehicleSpeedHeadingRate");
  11. diffDrive.WheelSpeedRange = [-10 10]*2*pi;
  12.  
  13. % rower bicykl
  14. bicycle = bicycleKinematics("VehicleInputs","VehicleSpeedHeadingRate","MaxSteeringAngle",pi/8);
  15.  
  16. % controller
  17. controller3 = controllerPurePursuit("Waypoints",path,"DesiredLinearVelocity",4,"MaxAngularVelocity",2*pi);
  18. controller2 = controllerPurePursuit("Waypoints",path,"DesiredLinearVelocity",4,"MaxAngularVelocity",2*pi);
  19. controller1 = controllerPurePursuit("Waypoints",path,"DesiredLinearVelocity",4,"MaxAngularVelocity",2*pi);
  20.  
  21. % trajektorie
  22. [tUnicycle,unicyclePose] = ode45(@(t,y)derivative(unicycle,y,exampleHelperMobileRobotController(controller1,y,path(end,:)',1)),tVec,initPose);
  23. [tDiffDrive,diffDrivePose] = ode45(@(t,y)derivative(diffDrive,y,exampleHelperMobileRobotController(controller2,y,path(end,:)',1)),tVec,initPose);
  24. [tBicycle,bicyclePose] = ode45(@(t,y)derivative(bicycle,y,exampleHelperMobileRobotController(controller3,y,path(end,:)',1)),tVec,initPose);
  25.  
  26. %wyniki
  27. unicycleTranslations = [unicyclePose(:,1:2),zeros(length(unicyclePose),1)];
  28. unicycleRot = axang2quat([repmat([0 0 1],length(unicyclePose),1),unicyclePose(:,3)]);
  29.  
  30. diffDriveTranslations = [diffDrivePose(:,1:2),zeros(length(diffDrivePose),1)];
  31. diffDriveRot = axang2quat([repmat([0 0 1],length(diffDrivePose),1),diffDrivePose(:,3)]);
  32.  
  33. bicycleTranslations = [bicyclePose(:,1:2) zeros(length(bicyclePose),1)];
  34. bicycleRot = axang2quat([repmat([0 0 1],length(bicyclePose),1),bicyclePose(:,3)]);
  35.  
  36. path
  37. show(prm)
  38. hold on
  39. plotTransforms(unicycleTranslations(1:10:end,:),unicycleRot(1:10:end,:),'MeshFilePath','groundvehicle.stl',"MeshColor","r");
  40. plotTransforms(bicycleTranslations(1:10:end,:),bicycleRot(1:10:end,:),'MeshFilePath','groundvehicle.stl',"MeshColor","b");
  41. plotTransforms(diffDriveTranslations(1:10:end,:),diffDriveRot(1:10:end,:),'MeshFilePath','groundvehicle.stl',"MeshColor","g");
  42. view(0,90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement