Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
traffic-scratch
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mehtank
traffic-scratch
Commits
120ac9a6
Commit
120ac9a6
authored
8 years ago
by
mehtank
Browse files
Options
Downloads
Patches
Plain Diff
Use numpy absolute
parent
11799234
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bestrobot.py
+16
-26
16 additions, 26 deletions
bestrobot.py
with
16 additions
and
26 deletions
bestrobot.py
+
16
−
26
View file @
120ac9a6
from
scipy
import
log
,
sqrt
,
linspace
,
logspace
,
meshgrid
,
zeros
from
scipy
import
log
,
sqrt
,
linspace
,
logspace
,
meshgrid
,
zeros
,
absolute
from
scipy.optimize
import
minimize
def
isstable
(
model
):
return
2
*
model
[
1
]
*
model
[
2
]
+
model
[
2
]
*
model
[
2
]
-
2
*
model
[
0
]
def
tflogmag
((
f
,
g
,
h
),
w
):
def
tf
((
f
,
g
,
h
),
w
):
"""
Return the complex value of linearized transfer function T(jw)
"""
return
(
g
*
1j
*
w
+
f
)
/
(
-
w
*
w
+
(
g
+
h
)
*
1j
*
w
+
f
)
def
tflogmag
(
model
,
w
):
"""
Return the log of the magnitude of the linearized transfer function
log[ |T(jw)| ]
"""
#f,g,h = model.f, model.g, model.h
return
log
((
g
*
g
*
w
*
w
+
f
*
f
)
/
((
f
-
w
*
w
)
**
2
+
(
g
+
h
)
**
2
*
w
*
w
))
/
2
return
log
(
absolute
(
tf
(
model
,
w
)))
def
htflogmag
(
(
f
,
g
,
h
)
,
w
):
def
htflogmag
(
model
,
w
):
"""
Return the log of the magnitude of the linearized headway transfer function
log[ |1-T(jw)| ]
"""
#f,g,h = model.f, model.g, model.h
return
log
((
h
*
h
*
w
*
w
+
w
*
w
*
w
*
w
)
/
((
f
-
w
*
w
)
**
2
+
(
g
+
h
)
**
2
*
w
*
w
))
/
2
return
log
(
absolute
(
1
-
tf
(
model
,
w
)))
def
kstable
(
human
,
robot
,
w
,
eta
=
2
):
"""
...
...
@@ -39,18 +43,13 @@ def ksafe(human, robot, w, eta=2):
TOL
=
1e-6
def
maxk
stable
(
human
,
robot
,
eta
=
2
):
def
maxk
fn
(
human
,
robot
,
eta
,
kfn
):
f
,
g
,
h
=
human
maxw
=
sqrt
(
2
*
f
-
2
*
g
*
h
-
h
*
h
)
return
minimize
(
lambda
w
:
kstable
(
human
,
robot
,
w
),
1
,
bounds
=
[(
TOL
,
maxw
-
TOL
)])
#.fun[0]
def
maxksafe
(
human
,
robot
,
eta
=
2
):
f
,
g
,
h
=
human
maxw
=
sqrt
(
2
*
f
-
2
*
g
*
h
-
h
*
h
)
return
minimize
(
lambda
w
:
ksafe
(
human
,
robot
,
w
,
eta
),
1
,
bounds
=
[(
TOL
,
maxw
-
TOL
)])
#.fun[0]
maxw
=
sqrt
(
-
isstable
(
human
))
return
minimize
(
lambda
w
:
kfn
(
human
,
robot
,
w
,
eta
),
1
,
bounds
=
[(
TOL
,
maxw
-
TOL
)])
#.fun[0]
def
maxk
(
human
,
robot
,
eta
):
return
min
(
maxk
stable
(
human
,
robot
),
maxk
safe
(
human
,
robot
,
eta
))
return
min
(
maxk
fn
(
human
,
robot
,
eta
,
kstable
),
maxk
fn
(
human
,
robot
,
eta
,
ksafe
))
'''
def bestrobotstable(human):
...
...
@@ -84,21 +83,12 @@ if __name__ == "__main__":
hmodel
.
go
(
0.5
)
human
=
(
hmodel
.
f
,
hmodel
.
g
,
hmodel
.
h
)
maxw
=
sqrt
(
2
*
hmodel
.
f
-
2
*
hmodel
.
g
*
hmodel
.
h
-
hmodel
.
h
*
hmodel
.
h
)
# print "maxw = ", maxw
resw
=
sqrt
(
-
isstable
(
human
))
# print "resw = ", resw
robot
=
(
0.018
,
0
,
0.19
)
# print 2*robot[0] - 2*robot[1]*robot[2] - robot[2]*robot[2]
maxw
=
sqrt
(
-
isstable
(
human
))
eta
=
2
print
bestrobot
(
human
,
eta
)
import
IPython
IPython
.
embed
()
'''
ws = linspace(TOL, maxw-TOL, 101)
kst = kstable(human, robot, ws)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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