Controller VFH Ranges and Angles - How do I get the same sized inputs from ROS Topic '/scan'?
3 views (last 30 days)
Show older comments
I have been playing with my demo and I followed a tutorial in MatLab for ControllerVFH using a script. Now I am attempting to duplicate this in Simulink to no avail.
- I have a TurtleBot3 with Lidar running
- I can see the topic in Simulink
So looking at the ControllerVFH block it needs the Ranges which I assume means all the distance readings from each angle as the Lidar spins. In my case, I have a 360 degree Lidar. So again, I assume the size of this input is 360. Next, in my MatLab FCN block I am attempting to take the AngleMin, AngleMax and AngleIncrement and create an input for Angles that should be equally matched in size to Ranges.
function angles = fcn(AngleMin, AngleMax, AngleIncrement, numRanges)
if numRanges > 0
angleMin = double(AngleMin);
angleMax = double(AngleMax);
angleIncrement = double(AngleIncrement);
assert(numRanges < 360);
angles=double(zeros(numRanges,1));
for ii=1:numRanges
angles(ii) = double(angleMin) + double(ii-1)*(angleIncrement);
end
else
angles = 0;
end
When I run this simulation however, I get an error:
A runtime error occurred in the block 'LidarScan/Vector Field Histogram' during simulation.
Caused by:
Expected inputs 'ranges' and 'angles' to have the same number of elements.
Error in validateLaserScan.m (line 27)
'shared_robotics:validation:SizeMismatch', rangesArgName, anglesArgName);
Error in validateLidarScan.m (line 37)
Error in VectorFieldHistogram.m (line 35)
Error in VectorFieldHistogramBase.m (line 292)
This has been a two day struggle fest. Does anyone have an idea what I am doing wrong?
0 Comments
Answers (0)
See Also
Categories
Find more on Motion Planning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!