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 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Jianxin Sun
Jianxin Sun el 3 de Mzo. de 2022
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

Más respuestas (1)

Wenjun Li
Wenjun Li el 4 de Mzo. de 2022
Hi Jianxin,
Thank you for your patience! I tried to modify my state space as your suggested, but I still get the same error"Abstract classes cannot be instantiated".Then this is my modifications :
function copyObj = copy(obj)
%copyObj copies one object to another
copyObj=myCustomUAVStateSpace;
copyObj.DubinsPathSettings=copy(obj.DubinsPathSettings);
copyObj.WorkspaceGoalRegion=obj.WorkspaceGoalRegion;
copyObj.PWGRGuidedSampling=obj.PWGRGuidedSampling;
copyObj.AirSpeed=obj.AirSpeed;
copyObj.uavModelName=obj.uavModelName;
copyObj.Height=obj.Height;
copyObj.Temp=obj.Temp;
copyObj.Sound=obj.Sound;
copyObj.Press=obj.Press;
copyObj.AirDensity=obj.AirDensity;
copyObj.DefaultRandomStateBounds = obj.DefaultRandomStateBounds;
copyObj.UniformDistribution = obj.UniformDistribution.copy;
copyObj.NormalDistribution = obj.NormalDistribution.copy;
end
end
methods (Static, Access = protected)
function [mxRoll,arspeed,flightpathangle,bnds,uavName,height,temp,sound,press,airdensity] = parseStateSpaceConstuctor(varargin)
%parseConstructor Parses the inputs to the constructor
p = matlabshared.autonomous.core.internal.NameValueParser({'MaxRollAngle', 'AirSpeed','FlightPathAngleLimit','Bounds','uavModelName','Height','Temp','Sound','Press','AirDensity'},...
{myCustomUAVStateSpace.DefaultMaxRollAngle, myCustomUAVStateSpace.DefaultAirSpeed,myCustomUAVStateSpace.DefaultFlightPathAngleLimit,myCustomUAVStateSpace.DefaultRandomDefaultRandomStateBounds,myCustomUAVStateSpace.DefalutuavModelName,myCustomUAVStateSpace.DefalutHeight,myCustomUAVStateSpace.DefalutTemp,myCustomUAVStateSpace.DefalutSound,myCustomUAVStateSpace.DefalutPress,myCustomUAVStateSpace.DefalutAirDensity});
if nargin == 0
p.parse(varargin{:});
else
p.parse(varargin{1:end});
end
mxRoll = p.parameterValue('MaxRollAngle');
arspeed = p.parameterValue('AirSpeed');
flightpathangle=p.parameterValue('FlightPathAngleLimit');
bnds=p.parameterValue('Bounds');
uavName=p.parameterValue('uavModelName');
height=p.parameterValue('Height');
temp=p.parameterValue('Temp');
sound=p.parameterValue('Sound');
press=p.parameterValue('Press');
airdensity=p.parameterValue('AirDensity');
end
end
end
Your answer will be very important to my future work, I would be very grateful if you could reply my question.
Thanks,
Wenjun
  2 comentarios
Jianxin Sun
Jianxin Sun el 4 de Mzo. de 2022
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
Wenjun Li
Wenjun Li el 5 de Mzo. de 2022
Hi Jianxin,
Thank you so much!I have solved the problem by using your suggestion.But when I use my customized state space to perform navigation,the following errors occurs:
ss=myCustomUAVStateSpace("MaxRollAngle",pi/6,...
"AirSpeed",25,...
"FlightPathAngleLimit",[-0.1,0.1],...
"Bounds",[-40,50;-40,50;-40,50;-inf,Inf;-Inf,Inf;-Inf,Inf;-Inf,Inf],...
"Sound",340.0,...
"Press",1.0055e+05,...
"AirDensity",1.2174);
Error using StateSpace
Expected StateBounds to be of size 7x2, but it is of size 1x1.
validateattributes(bounds, {'double'}, ...
obj.StateBoundsInternal = obj.validateStateBounds(bounds, ...
obj.StateBounds = bounds;
But I define bounds of 7*2, I don't understand why this problem occurs?I would appreciate if you could help me with this question.Please forgive me for interrupting again and again.I'm looking forward your reply!
Thanks,
Wenjun

Iniciar sesión para comentar.

Categorías

Más información sobre Motion Planning en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by