├── CreatingMaps ├── CreateMapsFromArrays.mlx ├── CreateMapsFromImages.mlx ├── CreateMapsFromScans.mlx ├── Data │ ├── MapBuilderSession_fullmap.mat │ ├── MapBuilderSession_turtleBotMaze.mat │ ├── MaskedImage.mat │ ├── ROSBag_turtleBotMaze.bag │ ├── SignFollowerMap_TopImage.PNG │ ├── createImageMask.m │ └── turtleBotMazeMap.mat ├── Images │ ├── SLAM1.jpg │ ├── SLAM2.jpg │ ├── SLAM3.jpg │ ├── SLAM4.jpg │ ├── SLAM5.jpg │ └── SLAM6.jpg ├── PlotROSBag.mlx ├── SimulateROSBag.GIF ├── SimulateROSBag.slx ├── SimulateROSBag_lidar.GIF ├── SimulateROSBag_lidar.slx ├── driveTurtlebot.GIF └── driveTurtlebot.slx ├── MSRA_UGV_Navigation.JPG ├── PathPlanning ├── DerivePathPRM.mlx ├── avoidObstaclesROS.GIF ├── avoidObstaclesROS.slx ├── avoidObstaclesSim.GIF ├── avoidObstaclesSim.slx ├── convertMapToMatrix.m ├── followWaypointsROS.GIF ├── followWaypointsROS.slx ├── followWaypointsSim.GIF ├── followWaypointsSim.slx ├── pathFollowingSchedulerROS.GIF ├── pathFollowingSchedulerROS.slx ├── pathFollowingSchedulerSim.GIF ├── pathFollowingSchedulerSim.slx ├── pathFollowingSystemROS.GIF ├── pathFollowingSystemROS.slx ├── pathFollowingSystemSim.GIF ├── pathFollowingSystemSim.slx ├── planPath.GIF ├── planPath.slx ├── planPathROS.GIF ├── planPathROS.slx └── turtleBotMazeMap.mat ├── README.md ├── SECURITY.md ├── SLAM ├── LidarSlam.m ├── LidarSlam_interp.m ├── Lidar_Slam_ROS_Node.slx └── Lidar_Slam_Sim.slx ├── TrajectoryGeneration ├── InterpolatePath.mlx ├── followWaypointsPolyTraj.GIF ├── followWaypointsPolyTraj.slx ├── followWaypointsTrapVelTraj.GIF ├── followWaypointsTrapVelTraj.slx ├── smoothPathSim.GIF └── smoothPathSim.slx ├── license.txt └── startUGVNavigationDemo.mlx /CreatingMaps/CreateMapsFromArrays.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/CreateMapsFromArrays.mlx -------------------------------------------------------------------------------- /CreatingMaps/CreateMapsFromImages.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/CreateMapsFromImages.mlx -------------------------------------------------------------------------------- /CreatingMaps/CreateMapsFromScans.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/CreateMapsFromScans.mlx -------------------------------------------------------------------------------- /CreatingMaps/Data/MapBuilderSession_fullmap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/MapBuilderSession_fullmap.mat -------------------------------------------------------------------------------- /CreatingMaps/Data/MapBuilderSession_turtleBotMaze.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/MapBuilderSession_turtleBotMaze.mat -------------------------------------------------------------------------------- /CreatingMaps/Data/MaskedImage.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/MaskedImage.mat -------------------------------------------------------------------------------- /CreatingMaps/Data/ROSBag_turtleBotMaze.bag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/ROSBag_turtleBotMaze.bag -------------------------------------------------------------------------------- /CreatingMaps/Data/SignFollowerMap_TopImage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/SignFollowerMap_TopImage.PNG -------------------------------------------------------------------------------- /CreatingMaps/Data/createImageMask.m: -------------------------------------------------------------------------------- 1 | function [BW,maskedRGBImage] = createImageMask(RGB) 2 | %createMask Threshold RGB image using auto-generated code from colorThresholder app. 3 | % [BW,MASKEDRGBIMAGE] = createMask(RGB) thresholds image RGB using 4 | % auto-generated code from the colorThresholder app. The colorspace and 5 | % range for each channel of the colorspace were set within the app. The 6 | % segmentation mask is returned in BW, and a composite of the mask and 7 | % original RGB images is returned in maskedRGBImage. 8 | % Copyright 2021, The MathWorks, Inc 9 | 10 | % Auto-generated by colorThresholder app on 11-Nov-2020 11 | %------------------------------------------------------ 12 | 13 | 14 | % Convert RGB image to chosen color space 15 | I = rgb2hsv(RGB); 16 | 17 | % Define thresholds for channel 1 based on histogram settings 18 | channel1Min = 0.000; 19 | channel1Max = 1.000; 20 | 21 | % Define thresholds for channel 2 based on histogram settings 22 | channel2Min = 0.000; 23 | channel2Max = 1.000; 24 | 25 | % Define thresholds for channel 3 based on histogram settings 26 | channel3Min = 0.000; 27 | channel3Max = 1.000; 28 | 29 | % Create mask based on chosen histogram thresholds 30 | sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ... 31 | (I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ... 32 | (I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max); 33 | 34 | % Create mask based on selected regions of interest on point cloud projection 35 | I = double(I); 36 | [m,n,~] = size(I); 37 | polyBW = false([m,n]); 38 | I = reshape(I,[m*n 3]); 39 | 40 | % Convert HSV color space to canonical coordinates 41 | Xcoord = I(:,2).*I(:,3).*cos(2*pi*I(:,1)); 42 | Ycoord = I(:,2).*I(:,3).*sin(2*pi*I(:,1)); 43 | I(:,1) = Xcoord; 44 | I(:,2) = Ycoord; 45 | clear Xcoord Ycoord 46 | 47 | % Project 3D data into 2D projected view from current camera view point within app 48 | J = rotateColorSpace(I); 49 | 50 | % Apply polygons drawn on point cloud in app 51 | polyBW = applyPolygons(J,polyBW); 52 | 53 | % Combine both masks 54 | BW = sliderBW & polyBW; 55 | 56 | % Invert mask 57 | BW = ~BW; 58 | 59 | % Initialize output masked image based on input image. 60 | maskedRGBImage = RGB; 61 | 62 | % Set background pixels where BW is false to zero. 63 | maskedRGBImage(repmat(~BW,[1 1 3])) = 0; 64 | 65 | end 66 | 67 | function J = rotateColorSpace(I) 68 | 69 | % Translate the data to the mean of the current image within app 70 | shiftVec = [0.091376 0.051557 0.609949]; 71 | I = I - shiftVec; 72 | I = [I ones(size(I,1),1)]'; 73 | 74 | % Apply transformation matrix 75 | tMat = [-0.433425 -0.406693 0.000000 0.705211; 76 | -0.003791 0.004773 0.825002 -0.500499; 77 | 0.374154 -0.471070 0.008360 3.653497; 78 | 0.000000 0.000000 0.000000 1.000000]; 79 | 80 | J = (tMat*I)'; 81 | end 82 | 83 | function polyBW = applyPolygons(J,polyBW) 84 | 85 | % Define each manually generated ROI 86 | hPoints(1).data = [0.258532 -0.228779; 87 | 0.358697 -0.573136; 88 | 0.716040 -0.314868; 89 | 0.521125 -0.037768]; 90 | 91 | % Iteratively apply each ROI 92 | for ii = 1:length(hPoints) 93 | if size(hPoints(ii).data,1) > 2 94 | in = inpolygon(J(:,1),J(:,2),hPoints(ii).data(:,1),hPoints(ii).data(:,2)); 95 | in = reshape(in,size(polyBW)); 96 | polyBW = polyBW | in; 97 | end 98 | end 99 | 100 | end 101 | -------------------------------------------------------------------------------- /CreatingMaps/Data/turtleBotMazeMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Data/turtleBotMazeMap.mat -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM1.jpg -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM2.jpg -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM3.jpg -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM4.jpg -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM5.jpg -------------------------------------------------------------------------------- /CreatingMaps/Images/SLAM6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/Images/SLAM6.jpg -------------------------------------------------------------------------------- /CreatingMaps/PlotROSBag.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/PlotROSBag.mlx -------------------------------------------------------------------------------- /CreatingMaps/SimulateROSBag.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/SimulateROSBag.GIF -------------------------------------------------------------------------------- /CreatingMaps/SimulateROSBag.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/SimulateROSBag.slx -------------------------------------------------------------------------------- /CreatingMaps/SimulateROSBag_lidar.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/SimulateROSBag_lidar.GIF -------------------------------------------------------------------------------- /CreatingMaps/SimulateROSBag_lidar.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/SimulateROSBag_lidar.slx -------------------------------------------------------------------------------- /CreatingMaps/driveTurtlebot.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/driveTurtlebot.GIF -------------------------------------------------------------------------------- /CreatingMaps/driveTurtlebot.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/CreatingMaps/driveTurtlebot.slx -------------------------------------------------------------------------------- /MSRA_UGV_Navigation.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/MSRA_UGV_Navigation.JPG -------------------------------------------------------------------------------- /PathPlanning/DerivePathPRM.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/DerivePathPRM.mlx -------------------------------------------------------------------------------- /PathPlanning/avoidObstaclesROS.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/avoidObstaclesROS.GIF -------------------------------------------------------------------------------- /PathPlanning/avoidObstaclesROS.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/avoidObstaclesROS.slx -------------------------------------------------------------------------------- /PathPlanning/avoidObstaclesSim.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/avoidObstaclesSim.GIF -------------------------------------------------------------------------------- /PathPlanning/avoidObstaclesSim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/avoidObstaclesSim.slx -------------------------------------------------------------------------------- /PathPlanning/convertMapToMatrix.m: -------------------------------------------------------------------------------- 1 | function [occMatrix, resolution, origin] = convertMapToMatrix(map) 2 | % This function returns map information from an occupancy map object as 3 | % variables of double data type to be used as input to Simulink® blocks for 4 | % simulation and code generation. 5 | % 6 | % Copyright 2021, The MathWorks, Inc 7 | 8 | occMatrix = occupancyMatrix(map,'ternary'); 9 | resolution = map.Resolution; 10 | origin = map.GridLocationInWorld; 11 | 12 | end -------------------------------------------------------------------------------- /PathPlanning/followWaypointsROS.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/followWaypointsROS.GIF -------------------------------------------------------------------------------- /PathPlanning/followWaypointsROS.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/followWaypointsROS.slx -------------------------------------------------------------------------------- /PathPlanning/followWaypointsSim.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/followWaypointsSim.GIF -------------------------------------------------------------------------------- /PathPlanning/followWaypointsSim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/followWaypointsSim.slx -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSchedulerROS.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSchedulerROS.GIF -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSchedulerROS.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSchedulerROS.slx -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSchedulerSim.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSchedulerSim.GIF -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSchedulerSim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSchedulerSim.slx -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSystemROS.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSystemROS.GIF -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSystemROS.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSystemROS.slx -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSystemSim.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSystemSim.GIF -------------------------------------------------------------------------------- /PathPlanning/pathFollowingSystemSim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/pathFollowingSystemSim.slx -------------------------------------------------------------------------------- /PathPlanning/planPath.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/planPath.GIF -------------------------------------------------------------------------------- /PathPlanning/planPath.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/planPath.slx -------------------------------------------------------------------------------- /PathPlanning/planPathROS.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/planPathROS.GIF -------------------------------------------------------------------------------- /PathPlanning/planPathROS.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/planPathROS.slx -------------------------------------------------------------------------------- /PathPlanning/turtleBotMazeMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/PathPlanning/turtleBotMazeMap.mat -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Autonomous Navigation for Mobile Robots and UGV 2 | 3 | 4 | [![View Autonomous Navigation for Mobile Robots and UGV on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/95998-autonomous-navigation-for-mobile-robots-and-ugv) 5 | 6 | 7 | This GitHub® repository contains MATLAB® and Simulink® examples for developing autonomous navigation software stacks for mobile robots and unmanned ground vehicles (UGV). The examples contained in this submission demonstrate how to interact with ROS-enabled robots and equivalent simulations to design and test a software stack for autonomous navigation of a Turtlebot3. 8 | 9 | 10 | 11 | Topics covered in this collection of scripts and models include: 12 | ## Creating Maps for Autonomous Navigation 13 | * Create Maps from Numerical Arrays 14 | * Create Maps from Images 15 | * Control ROS-Based Robots to Acquire Lidar Scans 16 | * Import and Plot ROS Data from a rosbag 17 | * Integrate rosbag Recordings Into Simulations 18 | * Create Maps From Lidar Scans using SLAM 19 | ## Motion Planning and Path Following 20 | * Simulate Waypoint Following Controller Using Pure Pursuit 21 | * Command ROS Robot to Follow Waypoints Using Pure Pursuit 22 | * Generate Path Between Two Locations Using a PRM Planner 23 | * Simulate Path Planning and Following 24 | * Test Path Planner + Follower in ROS Robot 25 | * Simulate Obstacle Avoidance Using VFH Controller 26 | * Test Obstacle Avoidance on ROS Robot 27 | * Simulate Complete Path Navigation Stack 28 | * Test Complete Path Navigation Stack in ROS Robot 29 | * Simulate Path Re-Planning Scheduler Using Stateflow® 30 | * Test Re-Planning Scheduler in ROS Robot 31 | ## Trajectory Generation 32 | * Interpolate Smooth Paths from Critical Navigation Waypoints 33 | * Simulate Smooth Path Navigation 34 | * Navigate Environment Using a Polynomial Trajectory 35 | * Navigate Environment Using a Trapezoidal Velocity Trajectory 36 | ## Localization and SLAM 37 | * Design and test SLAM in Robots powered by ROS 38 | * Generate Custom SLAM ROS Nodes 39 | 40 | 41 | 42 | To learn more about the MATLAB/Simulink toolboxes used in this submission, visit the following documentation pages: 43 | 44 | - [Robotics System Toolbox™](https://www.mathworks.com/help/robotics/examples.html) 45 | - [Navigation Toolbox™](https://www.mathworks.com/help/nav/examples.html) 46 | - [ROS Toolbox](https://www.mathworks.com/help/ros/examples.html) 47 | 48 | 49 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Vulnerabilities 2 | 3 | If you believe you have discovered a security vulnerability, please report it to 4 | [security@mathworks.com](mailto:security@mathworks.com). Please see 5 | [MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html) 6 | for additional information. -------------------------------------------------------------------------------- /SLAM/LidarSlam.m: -------------------------------------------------------------------------------- 1 | classdef LidarSlam < matlab.System 2 | 3 | 4 | % Public, tunable properties 5 | properties 6 | 7 | end 8 | 9 | properties(DiscreteState) 10 | 11 | end 12 | 13 | % Pre-computed constants 14 | properties(Access = private) 15 | slamAlg = lidarSLAM(20); 16 | scanprevious= lidarScan(0,0); 17 | end 18 | 19 | methods(Access = protected) 20 | function setupImpl(obj) 21 | % Give computing constants 22 | % Tune these parameters according to your system and environment 23 | mapResolution = 18; 24 | maxLidarRange = 8; 25 | LoopClosureThreshold = 2; 26 | LoopClosureSearchRadius = 2; 27 | maxNumScans = 400; 28 | obj.slamAlg = lidarSLAM(mapResolution, maxLidarRange, maxNumScans); 29 | obj.slamAlg.LoopClosureThreshold = LoopClosureThreshold; 30 | obj.slamAlg.LoopClosureSearchRadius = LoopClosureSearchRadius; 31 | %Seupp the empty map here 32 | end 33 | 34 | 35 | function [slamStatus,pose] = stepImpl(obj,ranges,angles) 36 | % Implement algorithm. Calculate y as a function of input u and 37 | % discrete states. 38 | 39 | scan = lidarScan(ranges,angles) 40 | if (obj.slamAlg.PoseGraph.NumNodes<1000) 41 | % Its a design choise, more nodes mean you will get finer map but atan expnese on increase computational load 42 | 43 | addScan(obj.slamAlg, scan(end)); % adding most recent scans to the slamAlg ie lidarSLAM algortithm 44 | 45 | 46 | slamStatus = int8(0) 47 | else 48 | slamStatus = int8(1) 49 | 50 | end 51 | obj.scanprevious= scan; 52 | nodes = obj.slamAlg.PoseGraph.NumNodes 53 | 54 | 55 | coder.varsize('scans', [1,50], [0 1]); 56 | [scans,poses] = scansAndPoses(obj.slamAlg); 57 | pose=poses(end,:); 58 | 59 | 60 | end 61 | 62 | 63 | 64 | function resetImpl(obj) 65 | % Initialize / reset discrete-state properties 66 | end 67 | 68 | function [out1, out2] = getOutputSizeImpl(~) 69 | % Return size for each output port 70 | out1 = [1 1]; 71 | out2 = [1 3]; 72 | %out3 = [1000 1000]; % ask for variable size array 73 | end 74 | 75 | function [out1, out2] = getOutputDataTypeImpl(~) 76 | % Return data type for each output port 77 | out1 = "int8"; 78 | out2 = "double"; 79 | %out3 = "double"; 80 | end 81 | 82 | function [out1, out2] = isOutputComplexImpl(~) 83 | % Return true for each output port with complex data 84 | out1 = false; 85 | out2 = false; 86 | %out3 = false; 87 | end 88 | 89 | function [out1, out2] = isOutputFixedSizeImpl(~) 90 | % Return true for each output port with fixed size 91 | out1 = true; 92 | out2 = true; 93 | %out3 = false; 94 | end 95 | 96 | 97 | 98 | 99 | 100 | 101 | function sts = getSampleTimeImpl(obj) 102 | % Define sample time type and parameters 103 | sts = obj.createSampleTime("Type", "Discrete", ... 104 | "SampleTime", 0.5); 105 | end 106 | 107 | end 108 | 109 | 110 | end 111 | -------------------------------------------------------------------------------- /SLAM/LidarSlam_interp.m: -------------------------------------------------------------------------------- 1 | classdef LidarSlam_interp < matlab.System 2 | % 3 | % 4 | % 5 | 6 | % Public, tunable properties 7 | properties 8 | 9 | end 10 | 11 | properties(DiscreteState) 12 | 13 | end 14 | 15 | % Pre-computed constants 16 | properties(Access = private) 17 | slamAlg = lidarSLAM(20); 18 | end 19 | 20 | methods(Access = protected) 21 | function setupImpl(obj) 22 | % Give computing constants 23 | % Tune these parameters according to your system and environment 24 | mapResolution = 18; 25 | maxLidarRange = 8; 26 | LoopClosureThreshold = 2; 27 | LoopClosureSearchRadius = 2; 28 | maxNumScans = 15; 29 | obj.slamAlg = lidarSLAM(mapResolution, maxLidarRange,maxNumScans); 30 | obj.slamAlg.LoopClosureThreshold = LoopClosureThreshold; 31 | obj.slamAlg.LoopClosureSearchRadius = LoopClosureSearchRadius; 32 | end 33 | 34 | function [slamStatus,pose, mapData] = stepImpl(obj,ranges,angles) 35 | % Implement algorithm. Calculate y as a function of input u and 36 | % discrete states. 37 | scan = lidarScan(ranges,angles); 38 | if (obj.slamAlg.PoseGraph.NumNodes<1000) 39 | % Its a design choise, more nodes mean you will get finer map but atan expnese on increase computational load 40 | 41 | addScan(obj.slamAlg, scan); % adding most recent scans to the slamAlg ie lidarSLAM algortithm 42 | slamStatus = int8(0); 43 | else 44 | slamStatus = int8(1); 45 | 46 | end 47 | nodes = obj.slamAlg.PoseGraph.NumNodes; 48 | 49 | 50 | [scans,poses] = scansAndPoses(obj.slamAlg); 51 | pose=poses(end,:); 52 | 53 | 54 | mapResolution=18; 55 | maxLidarRange = 8; 56 | map = buildMap(scans, poses, mapResolution, maxLidarRange); 57 | mapData = occupancyMatrix(map); 58 | 59 | 60 | 61 | 62 | 63 | end 64 | 65 | 66 | 67 | function resetImpl(obj) 68 | % Initialize / reset discrete-state properties 69 | end 70 | 71 | function [out1, out2, out3] = getOutputSizeImpl(~) 72 | % Return size for each output port 73 | out1 = [1 1]; 74 | out2 = [1 3]; 75 | out3 = [1000 1000]; % ask for variable size array 76 | end 77 | 78 | function [out1, out2, out3] = getOutputDataTypeImpl(~) 79 | % Return data type for each output port 80 | out1 = "int8"; 81 | out2 = "double"; 82 | out3 = "double"; 83 | end 84 | 85 | function [out1, out2, out3] = isOutputComplexImpl(~) 86 | % Return true for each output port with complex data 87 | out1 = false; 88 | out2 = false; 89 | out3 = false; 90 | end 91 | 92 | function [out1, out2, out3] = isOutputFixedSizeImpl(~) 93 | % Return true for each output port with fixed size 94 | out1 = true; 95 | out2 = true; 96 | out3 = false; 97 | end 98 | 99 | 100 | 101 | 102 | 103 | 104 | function sts = getSampleTimeImpl(obj) 105 | % Define sample time type and parameters 106 | sts = obj.createSampleTime("Type", "Discrete", ... 107 | "SampleTime", 0.5); 108 | end 109 | 110 | end 111 | 112 | 113 | end 114 | -------------------------------------------------------------------------------- /SLAM/Lidar_Slam_ROS_Node.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/SLAM/Lidar_Slam_ROS_Node.slx -------------------------------------------------------------------------------- /SLAM/Lidar_Slam_Sim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/SLAM/Lidar_Slam_Sim.slx -------------------------------------------------------------------------------- /TrajectoryGeneration/InterpolatePath.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/InterpolatePath.mlx -------------------------------------------------------------------------------- /TrajectoryGeneration/followWaypointsPolyTraj.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/followWaypointsPolyTraj.GIF -------------------------------------------------------------------------------- /TrajectoryGeneration/followWaypointsPolyTraj.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/followWaypointsPolyTraj.slx -------------------------------------------------------------------------------- /TrajectoryGeneration/followWaypointsTrapVelTraj.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/followWaypointsTrapVelTraj.GIF -------------------------------------------------------------------------------- /TrajectoryGeneration/followWaypointsTrapVelTraj.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/followWaypointsTrapVelTraj.slx -------------------------------------------------------------------------------- /TrajectoryGeneration/smoothPathSim.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/smoothPathSim.GIF -------------------------------------------------------------------------------- /TrajectoryGeneration/smoothPathSim.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/TrajectoryGeneration/smoothPathSim.slx -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021, The MathWorks, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /startUGVNavigationDemo.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/autonomous-navigation-ugv/0660bf5064302ac5279d701dd9eb698d5ada6019/startUGVNavigationDemo.mlx --------------------------------------------------------------------------------