Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuttlefish
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
squidworks
cuttlefish
Commits
72017d14
Commit
72017d14
authored
5 years ago
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
bugfix not checking for speeds > cruise speed
parent
73cbed4c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hunks/adhoc/saturn.js
+26
-10
26 additions, 10 deletions
hunks/adhoc/saturn.js
with
26 additions
and
10 deletions
hunks/adhoc/saturn.js
+
26
−
10
View file @
72017d14
...
@@ -29,7 +29,7 @@ p[0] and s[0] are always current state ... when we len > 1 we have werk 2 do
...
@@ -29,7 +29,7 @@ p[0] and s[0] are always current state ... when we len > 1 we have werk 2 do
*/
*/
let
JD
=
(
positions
,
speeds
,
deviation
,
accel
,
minSpeed
)
=>
{
let
JD
=
(
positions
,
speeds
,
deviation
,
accel
,
minSpeed
,
cruise
)
=>
{
//console.log('positions', positions)
//console.log('positions', positions)
let
calcJunctionSpeed
=
(
p0
,
p1
,
p2
,
jd
,
a
)
=>
{
let
calcJunctionSpeed
=
(
p0
,
p1
,
p2
,
jd
,
a
)
=>
{
// junction speed at p1, arrival from p0 exit to p2
// junction speed at p1, arrival from p0 exit to p2
...
@@ -61,14 +61,14 @@ let JD = (positions, speeds, deviation, accel, minSpeed) => {
...
@@ -61,14 +61,14 @@ let JD = (positions, speeds, deviation, accel, minSpeed) => {
// walk for minspeeds
// walk for minspeeds
for
(
let
s
in
speeds
)
{
for
(
let
s
in
speeds
)
{
if
(
speeds
[
s
]
<
minSpeed
)
speeds
[
s
]
=
minSpeed
if
(
speeds
[
s
]
<
minSpeed
)
speeds
[
s
]
=
minSpeed
if
(
speeds
[
s
]
>
cruise
)
speeds
[
s
]
=
cruise
}
}
// that's it for us
// that's it for us
return
speeds
return
speeds
}
}
let
ReversePass
=
(
positions
,
speeds
,
accel
,
minSpeed
)
=>
{
let
ReversePass
=
(
positions
,
speeds
,
accel
,
minSpeed
,
debug
)
=>
{
// link, walking back from last
// link, walking back from last
let
debug
=
false
// this makes sure we can completely decelerate, through moves, to the last point at zero
// this makes sure we can completely decelerate, through moves, to the last point at zero
for
(
let
i
=
positions
.
length
-
2
;
i
>
0
;
i
--
)
{
for
(
let
i
=
positions
.
length
-
2
;
i
>
0
;
i
--
)
{
if
(
debug
)
console
.
log
(
`reverse pass for
${
i
}
\n`
,
positions
[
i
],
positions
[
i
+
1
])
if
(
debug
)
console
.
log
(
`reverse pass for
${
i
}
\n`
,
positions
[
i
],
positions
[
i
+
1
])
...
@@ -91,9 +91,8 @@ let ReversePass = (positions, speeds, accel, minSpeed) => {
...
@@ -91,9 +91,8 @@ let ReversePass = (positions, speeds, accel, minSpeed) => {
}
}
}
}
let
ForwardPass
=
(
positions
,
speeds
,
accel
,
minSpeed
)
=>
{
let
ForwardPass
=
(
positions
,
speeds
,
accel
,
minSpeed
,
debug
)
=>
{
// link, walk forwards: can we accel to these velocities in time?
// link, walk forwards: can we accel to these velocities in time?
let
debug
=
false
for
(
let
i
=
0
;
i
<
positions
.
length
-
2
;
i
++
){
for
(
let
i
=
0
;
i
<
positions
.
length
-
2
;
i
++
){
if
(
debug
)
console
.
log
(
`forwards pass for
${
i
}
\n`
,
positions
[
i
],
positions
[
i
+
1
])
if
(
debug
)
console
.
log
(
`forwards pass for
${
i
}
\n`
,
positions
[
i
],
positions
[
i
+
1
])
if
(
debug
)
console
.
log
(
`current exit to calculate is`
,
speeds
[
i
+
1
])
if
(
debug
)
console
.
log
(
`current exit to calculate is`
,
speeds
[
i
+
1
])
...
@@ -114,13 +113,13 @@ let ForwardPass = (positions, speeds, accel, minSpeed) => {
...
@@ -114,13 +113,13 @@ let ForwardPass = (positions, speeds, accel, minSpeed) => {
// here is assuming positions[0] is current position, for which speed is the current velocity
// here is assuming positions[0] is current position, for which speed is the current velocity
}
}
let
RampPass
=
(
positions
,
speeds
,
ramps
,
a
,
cruise
)
=>
{
let
RampPass
=
(
positions
,
speeds
,
ramps
,
a
,
cruise
,
debug
)
=>
{
let
debug
=
false
for
(
let
i
=
0
;
i
<
positions
.
length
-
2
;
i
++
){
for
(
let
i
=
0
;
i
<
positions
.
length
-
2
;
i
++
){
if
(
debug
)
console
.
log
(
`ramp pass for
${
i
}
`
)
if
(
debug
)
console
.
log
(
`ramp pass for
${
i
}
`
)
let
pi
=
positions
[
i
]
let
pi
=
positions
[
i
]
let
pf
=
positions
[
i
+
1
]
let
pf
=
positions
[
i
+
1
]
let
vi
=
speeds
[
i
]
let
vi
=
speeds
[
i
]
if
(
vi
>
cruise
)
console
.
warn
(
`vi at
${
i
}
> cruise during RampPass`
)
let
vf
=
speeds
[
i
+
1
]
let
vf
=
speeds
[
i
+
1
]
let
d
=
vLen
(
math
.
subtract
(
positions
[
i
+
1
],
positions
[
i
]))
let
d
=
vLen
(
math
.
subtract
(
positions
[
i
+
1
],
positions
[
i
]))
let
maxEntry
=
Math
.
sqrt
(
Math
.
pow
(
speeds
[
i
+
1
],
2
)
+
2
*
a
*
d
)
let
maxEntry
=
Math
.
sqrt
(
Math
.
pow
(
speeds
[
i
+
1
],
2
)
+
2
*
a
*
d
)
...
@@ -138,6 +137,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -138,6 +137,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
else
if
(
maxEntry
<=
vi
){
}
else
if
(
maxEntry
<=
vi
){
if
(
debug
)
console
.
log
(
'
\\
'
)
if
(
debug
)
console
.
log
(
'
\\
'
)
ramps
.
push
({
ramps
.
push
({
...
@@ -147,6 +147,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -147,6 +147,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
else
if
(
vi
===
cruise
&&
vf
===
cruise
){
}
else
if
(
vi
===
cruise
&&
vf
===
cruise
){
if
(
debug
)
console
.
log
(
'
--
'
)
if
(
debug
)
console
.
log
(
'
--
'
)
ramps
.
push
({
ramps
.
push
({
...
@@ -156,6 +157,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -156,6 +157,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
else
if
(
vi
===
cruise
)
{
}
else
if
(
vi
===
cruise
)
{
if
(
debug
)
console
.
log
(
'
--
\\
'
)
if
(
debug
)
console
.
log
(
'
--
\\
'
)
let
dcDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vf
,
2
))
/
(
2
*
a
)
let
dcDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vf
,
2
))
/
(
2
*
a
)
...
@@ -168,6 +170,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -168,6 +170,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pInter
pf
:
pInter
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
// seg 2,
// seg 2,
ramps
.
push
({
ramps
.
push
({
vi
:
cruise
,
vi
:
cruise
,
...
@@ -176,6 +179,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -176,6 +179,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pInter
,
pi
:
pInter
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
else
if
(
vf
===
cruise
){
}
else
if
(
vf
===
cruise
){
if
(
debug
)
console
.
log
(
'
/--
'
)
if
(
debug
)
console
.
log
(
'
/--
'
)
let
acDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vi
,
2
))
/
(
2
*
a
)
let
acDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vi
,
2
))
/
(
2
*
a
)
...
@@ -188,6 +192,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -188,6 +192,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pInter
pf
:
pInter
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
// seg2
// seg2
ramps
.
push
({
ramps
.
push
({
vi
:
cruise
,
vi
:
cruise
,
...
@@ -196,10 +201,11 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -196,10 +201,11 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pInter
,
pi
:
pInter
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
else
{
}
else
{
let
dcDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vf
,
2
))
/
(
2
*
a
)
let
dcDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vf
,
2
))
/
(
2
*
a
)
let
acDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vi
,
2
))
/
(
2
*
a
)
let
acDist
=
(
Math
.
pow
(
cruise
,
2
)
-
Math
.
pow
(
vi
,
2
))
/
(
2
*
a
)
if
(
acDist
+
dcDist
>
d
){
if
(
acDist
+
dcDist
<
d
){
if
(
debug
)
console
.
log
(
'
/--
\\
'
)
if
(
debug
)
console
.
log
(
'
/--
\\
'
)
let
pa
=
math
.
add
(
pi
,
vScalar
(
vUnitBetween
(
pi
,
pf
),
acDist
))
let
pa
=
math
.
add
(
pi
,
vScalar
(
vUnitBetween
(
pi
,
pf
),
acDist
))
let
pb
=
math
.
add
(
pf
,
vScalar
(
vUnitBetween
(
pf
,
pi
),
dcDist
))
let
pb
=
math
.
add
(
pf
,
vScalar
(
vUnitBetween
(
pf
,
pi
),
dcDist
))
...
@@ -211,6 +217,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -211,6 +217,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pa
pf
:
pa
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble seg1/3
'
,
ramps
[
ramps
.
length
-
1
])
ramps
.
push
({
ramps
.
push
({
vi
:
cruise
,
vi
:
cruise
,
vf
:
cruise
,
vf
:
cruise
,
...
@@ -218,6 +225,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -218,6 +225,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pa
,
pi
:
pa
,
pf
:
pb
pf
:
pb
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble seg2/3
'
,
ramps
[
ramps
.
length
-
1
])
ramps
.
push
({
ramps
.
push
({
vi
:
cruise
,
vi
:
cruise
,
vf
:
vf
,
vf
:
vf
,
...
@@ -225,6 +233,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -225,6 +233,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pb
,
pi
:
pb
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble seg3/3
'
,
ramps
[
ramps
.
length
-
1
])
}
else
{
}
else
{
if
(
debug
)
console
.
log
(
'
/
\\
'
)
if
(
debug
)
console
.
log
(
'
/
\\
'
)
let
vPeak
=
Math
.
sqrt
(((
2
*
a
*
d
+
Math
.
pow
(
vi
,
2
)
+
Math
.
pow
(
vf
,
2
))
/
2
))
let
vPeak
=
Math
.
sqrt
(((
2
*
a
*
d
+
Math
.
pow
(
vi
,
2
)
+
Math
.
pow
(
vf
,
2
))
/
2
))
...
@@ -237,6 +246,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -237,6 +246,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pi
,
pi
:
pi
,
pf
:
pInter
pf
:
pInter
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
ramps
.
push
({
ramps
.
push
({
vi
:
vPeak
,
vi
:
vPeak
,
vf
:
vf
,
vf
:
vf
,
...
@@ -244,6 +254,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
...
@@ -244,6 +254,7 @@ let RampPass = (positions, speeds, ramps, a, cruise) => {
pi
:
pInter
,
pi
:
pInter
,
pf
:
pf
pf
:
pf
})
})
if
(
ramps
[
ramps
.
length
-
1
].
t
<
0
)
console
.
warn
(
'
trouble
'
,
ramps
[
ramps
.
length
-
1
])
}
}
}
// end BIGSWITCH
}
// end BIGSWITCH
}
}
...
@@ -333,12 +344,13 @@ export default function Saturn() {
...
@@ -333,12 +344,13 @@ export default function Saturn() {
console
.
time
(
'
lookahead
'
)
console
.
time
(
'
lookahead
'
)
// we can incorporate this update when we rewrite the loop accordingly
// we can incorporate this update when we rewrite the loop accordingly
let
speeds
=
[
speed
]
let
speeds
=
[
speed
]
JD
(
positions
,
speeds
,
deviation
,
accel
,
minSpeed
)
JD
(
positions
,
speeds
,
deviation
,
accel
,
minSpeed
,
feed
)
//console.log('jd writes speeds', speeds)
//console.log('jd writes speeds', speeds)
//console.log(`have ${speeds.length} speeds and ${positions.length} positions`)
//console.log(`have ${speeds.length} speeds and ${positions.length} positions`)
// now we need to link these together,
// now we need to link these together,
ReversePass
(
positions
,
speeds
,
accel
,
minSpeed
)
ReversePass
(
positions
,
speeds
,
accel
,
minSpeed
)
ForwardPass
(
positions
,
speeds
,
accel
,
minSpeed
)
ForwardPass
(
positions
,
speeds
,
accel
,
minSpeed
)
// are any of these non-permissible?
console
.
timeLog
(
'
lookahead
'
)
console
.
timeLog
(
'
lookahead
'
)
// that's kinda tough (25ms), means we need some double-loop action (can't do this every time segmment)
// that's kinda tough (25ms), means we need some double-loop action (can't do this every time segmment)
// now that we have this, we need to break it into motion packets
// now that we have this, we need to break it into motion packets
...
@@ -346,9 +358,13 @@ export default function Saturn() {
...
@@ -346,9 +358,13 @@ export default function Saturn() {
// inside of single-slope segments: i.e. have a start velocity, end velocity, and distance.
// inside of single-slope segments: i.e. have a start velocity, end velocity, and distance.
// then we can do another pass through to adjust these times to suit our period. ok.
// then we can do another pass through to adjust these times to suit our period. ok.
let
ramps
=
[]
// an arr of objs
let
ramps
=
[]
// an arr of objs
RampPass
(
positions
,
speeds
,
ramps
,
accel
,
feed
)
RampPass
(
positions
,
speeds
,
ramps
,
accel
,
feed
,
true
)
console
.
timeEnd
(
'
lookahead
'
)
console
.
timeEnd
(
'
lookahead
'
)
console
.
log
(
`have
${
ramps
.
length
}
ramps for
${
positions
.
length
}
positions`
)
console
.
log
(
`have
${
ramps
.
length
}
ramps for
${
positions
.
length
}
positions`
)
console
.
log
(
'
times
'
)
for
(
let
r
of
ramps
){
console
.
log
(
r
.
t
)
}
// run once,
// run once,
throw
new
Error
(
'
halt
'
)
throw
new
Error
(
'
halt
'
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment