I want to custom my statespace like the example"Motion Planning with RRT for Fixed-Wing UAV",but the following error occurs"Abstract classes cannot be instantiated."
3 次查看(过去 30 天)
显示 更早的评论
properties (SetAccess = protected)%设置属性的特性为保护特性
%UniformDistribution - Uniform distribution for sampling
UniformDistribution %采样时利用均匀分布
%NormalDistribution - Normal distribution for sampling
NormalDistribution %采样时利用正态分布
%WorkspaceGoalRegion Bounding box for goal region
WorkspaceGoalRegion %设置该属性的目的是:当采样到目标区域(逼近目标)时表示搜索成功
%DubinsPathSettings Dubin Path Settings for path planning
DubinsPathSettings
%AirSpeed Air speed configuration used in the state space
AirSpeed %state space里定义airspeed配置
uavModelName
Height
Temp
Sound
Press
AirDensity
end
properties (Constant)%常量
%DefaultMaxRollAngle Default values for Max Roll Angle
DefaultMaxRollAngle=pi/6 %默认最大滚动角
%DefaultAirSpeed Default values for AirSpeed
DefaultAirSpeed=20 %默认空速
%DefaultFlightPathAngleLimit Default values for FlightPathAngleLimit
DefaultFlightPathAngleLimit= [-0.1 0.1] %默认飞行路径角度限制
%DefaultRandomDefaultRandomStateBounds Default values for State Bounds
DefaultRandomDefaultRandomStateBounds = ...
[-40, 50; ...
-40, 50; ...
-40 50; ...
-pi,pi] %默认状态边界
DefalutuavModelName='multirotor'
DefalutHeight=65
DefalutTemp=287.7275
DefalutSound=340.0446
DefalutPress=1.0055e+05
DefalutAirDensity=1.2174
end
methods
function obj = myCustomUAVStateSpace(varargin)
%State Space Constructor for myCustomUAVStateSpace object
name = 'myCustomUAVStateSpace';
numStateVariables = 9;
%没有在methods里定义DefaultRandomStateBounds,只是在properties定义了默认随机状态边界,用圆点表示法调用状态边界属性
% Call the constructor of the base class
obj@nav.StateSpace(name, numStateVariables, myCustomUAVStateSpace.DefaultRandomStateBounds);
% Create the probability distributions for sampling.
obj.NormalDistribution = matlabshared.tracking.internal.NormalDistribution(numStateVariables);
obj.UniformDistribution = matlabshared.tracking.internal.UniformDistribution(numStateVariables);
if nargin ~= 0
[mxRoll,arspeed,flightpathangle,uavName,height,temp,sound,press,airdensity]=myCustomUAVStateSpace.parseStateSpaceConstuctor(varargin{:});
end
if (nargin ==0)
mxRoll=obj.DefaultMaxRollAngle;
arspeed=obj.DefaultAirSpeed;
flightpathangle=obj.DefaultFlightPathAngleLimit;
uavName=obj.DefalutuavModelName;
height=obj.DefalutHeight;
temp=obj.DefalutTemp;
sound=obj.DefalutSound;
press=obj.DefalutPress;
airdensity=obj.DefalutAirDensity;
%bounds=obj.DefaultRandomDefaultRandomStateBounds;
end
obj.AirSpeed = arspeed;
obj.uavModelName=uavName;
obj.Height=height;
obj.Temp=temp;
obj.Sound=sound;
obj.Press=press;
obj.AirDensity=airdensity;
obj.DubinsPathSettings=uavDubinsConnection('MaxRollAngle',mxRoll,'AirSpeed',arspeed,'FlightPathAngleLimit',flightpathangle);
%obj.DefaultRandomStateBounds = bounds;
end
0 个评论
采纳的回答
Jianxin Sun
2022-3-3
Hi Wenjun,
The error you received is about missing implmenetation in your state space class. In this example, the UAV state space inherits from nav.StateSpace class, which requires the following methods to be implemented:
methods (Abstract)
%DISTANCE Distance between two states
dist = distance(obj, state1, state2)
%INTERPOLATE Interpolate between two states
state = interpolate(obj, state1, state2, ratios)
%sampleGaussian Sample state using Gaussian distribution
state = sampleGaussian(obj, meanState, stdDev)
%sampleUniform Sample state using uniform distribution
state = sampleUniform(obj, varargin)
%enforceStateBounds Ensure that state lies within state bounds
boundedState = enforceStateBounds(obj, state)
%COPY Create deep copy of state space object
copyObj = copy(obj)
end
You can take the ExampleHelperUAVStateSpace implementation as an example.
Thanks,
Jianxin
0 个评论
更多回答(1 个)
Wenjun Li
2022-3-4
2 个评论
Jianxin Sun
2022-3-4
Hi Wenjun,
Please run the following command to view all the missing function implementation in your class:
meta.abstractDetails('myCustomUAVStateSpace')
You will need to implement all the mehtods listed by the output.
Thanks,
Jianxin
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Motion Planning 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!