-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleHelperSimulinkRobotROS.m
83 lines (71 loc) · 3.48 KB
/
ExampleHelperSimulinkRobotROS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
classdef ExampleHelperSimulinkRobotROS < handle
%ExampleHelperSimulinkRobotROS Setup robot simulator for Simulink
%examples
%
% This class is included only for demonstration purposes. The name of
% this class and its functionality may change without notice in a
% future release, or the class itself may be removed.
%
% See also ExampleHelperRobotSimulator
% Copyright 2015-2016 The MathWorks, Inc.
properties (Access = public)
%Simulator - Robot Simulator
% See also ExampleHelperRobotSimulator.
Simulator
end
methods
function obj = ExampleHelperSimulinkRobotROS(varargin)
%ExampleHelperSimulinkRobotROS Configure robot simulator for
%simulink example.
switch nargin
case 1
% Setup for Path Following with Obstacle Avoidance
% Example in Simulink
validatestring(varargin{1}, {'ObstacleAvoidance'});
% Setup RobotSimulator with simple map
obj.Simulator = ExampleHelperRobotSimulator('simpleMap');
% Set robot's maximum speed
obj.Simulator.Robot.MaxLinearVelocity = 2;
obj.Simulator.Robot.MaxAngularVelocity = 1;
% Set robot's initial pose
obj.Simulator.setRobotPose([2,4,0]);
% Set robot's size (bounding radius)
obj.Simulator.setRobotSize(0.5);
% Enable ROS interface for simulator
obj.Simulator.enableROSInterface(true);
% Disable Laser sensor
obj.Simulator.enableLaser(true);
% Disable velocity command timeout, i.e. the robot will follow the latest
% velocity command indefinitely.
obj.Simulator.Robot.enableLimitedCommandTime(true);
% Enable trajectory plot
obj.Simulator.showTrajectory(true);
otherwise
% Setup RobotSimulator with empty map
map = robotics.BinaryOccupancyGrid(false(50), 1);
map.GridLocationInWorld = [-25, -25];
obj.Simulator = ExampleHelperRobotSimulator(map);
% Set robot's maximum speed
obj.Simulator.Robot.MaxLinearVelocity = 2;
obj.Simulator.Robot.MaxAngularVelocity = 1;
% Set robot's initial pose
obj.Simulator.setRobotPose([0,0,0]);
% Set robot's size (bounding radius)
obj.Simulator.setRobotSize(2);
% Enable ROS interface for simulator
obj.Simulator.enableROSInterface(true);
% Disable Laser sensor
obj.Simulator.enableLaser(false);
% Disable velocity command timeout, i.e. the robot will follow the latest
% velocity command indefinitely.
obj.Simulator.Robot.enableLimitedCommandTime(false);
% Turn grid on
grid(obj.Simulator.Axes, 'on');
end
end
function delete(obj)
%delete Clean up robot simulator.
delete(obj.Simulator)
end
end
end