Skip to content

Commit

Permalink
Alignment course fine tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
pvaiko committed Dec 29, 2021
1 parent 5642add commit dcf843d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions scripts/ai/AIDriveStrategyFieldWorkCourse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function AIDriveStrategyFieldWorkCourse:start(course, startIx)
if distance > 2 * self.turningRadius then
self:debug('Start waypoint is far (%.1f m), use an alignment course to get there.', distance)
alignmentCourse = AlignmentCourse(self.vehicle, self.vehicle:getAIDirectionNode(), self.turningRadius,
course, startIx, math.min(0, -self.frontMarkerDistance)):getCourse()
course, startIx, math.min(-2, -self.frontMarkerDistance)):getCourse()
end
if alignmentCourse then
self.ppc:setShortLookaheadDistance()
Expand Down Expand Up @@ -384,7 +384,6 @@ function AIDriveStrategyFieldWorkCourse:onLastWaypointPassed()
self:debug('Alignment to first waypoint ended, start work, first lowering implements.')
self.state = self.states.WAITING_FOR_LOWER
self:lowerImplements()
self.ppc:setNormalLookaheadDistance()
self:startRememberedCourse()
else
self:debug('Last waypoint of the course reached.')
Expand Down
1 change: 0 additions & 1 deletion scripts/ai/CpMathUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ end
function CpMathUtil.getSeries(from, to, step)
local nValues = math.max(1, math.floor(math.abs((from - to) / step)))
local delta = (to - from) / nValues
CpUtil.info('%.1f %.1f %.1f', nValues, delta, step)
local value = from
local series = {}
for i = 0, nValues do
Expand Down
2 changes: 2 additions & 0 deletions scripts/ai/turns/TurnManeuver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ function AlignmentCourse:init(vehicle, vehicleDirectionNode, turningRadius, cour
print(course:getWaypointAngleDeg(ix))
local goal = State3D(x, -z, CourseGenerator.fromCpAngle(math.rad(course:getWaypointAngleDeg(ix))))

-- have a little reserve to make sure vehicles can always follow the course
turningRadius = turningRadius * 1.1
local solution = PathfinderUtil.dubinsSolver:solve(start, goal, turningRadius)

local alignmentWaypoints = solution:getWaypoints(start, turningRadius)
Expand Down
2 changes: 1 addition & 1 deletion scripts/pathfinder/Dubins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function DubinsSolution:getLength(turnRadius)
end

function DubinsSolution:getWaypoints(start, turnRadius)
return dubins_path_sample_many(self.pathDescriptor, 2)
return dubins_path_sample_many(self.pathDescriptor, 1)
end


Expand Down
2 changes: 2 additions & 0 deletions scripts/test/CpMathUtilTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ lu.assertItemsEquals(s, {1, 10})
s = CpMathUtil.getSeries(10, 1, 100)
lu.assertItemsEquals(s, {1, 10})

s = CpMathUtil.getSeries(0, 10.5, 1)
lu.assertItemsEquals(s, {0, 1.05, 2.1, 3.15, 4.2, 5.25, 6.3, 7.35, 8.4, 9.45, 10.5})

0 comments on commit dcf843d

Please sign in to comment.