Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
air_navigation_examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lucas Lindahl
air_navigation_examples
Commits
62213801
Commit
62213801
authored
2 months ago
by
Lucas Lindahl
Browse files
Options
Downloads
Patches
Plain Diff
Updated TestController
parent
dff96869
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
air_navigation_examples/__init__.py
+41
-6
41 additions, 6 deletions
air_navigation_examples/__init__.py
air_navigation_examples/__pycache__/__init__.cpython-310.pyc
+0
-0
0 additions, 0 deletions
air_navigation_examples/__pycache__/__init__.cpython-310.pyc
with
41 additions
and
6 deletions
air_navigation_examples/__init__.py
+
41
−
6
View file @
62213801
import
air_navigation
import
air_navigation
import
sys
import
sys
from
air_project_interfaces
import
Humans
import
rclpy
from
rclpy.node
import
Node
import
math
class
TestController
(
air_navigation
.
Controller
):
class
TestController
(
air_navigation
.
Controller
):
def
__init__
(
self
):
def
__init__
(
self
):
print
(
"
TestController constructor
"
)
print
(
"
✅
TestController constructor
START
"
)
super
().
__init__
()
super
().
__init__
()
print
(
"
✅ TestController constructor END
"
)
# Use the controller's internal ROS 2 node methods
self
.
create_subscription
(
Humans
,
'
/humans
'
,
self
.
humans_callback
,
10
)
self
.
closest_human_distance
=
float
(
'
inf
'
)
print
(
"
✅ Subscribed to /humans using internal node
"
)
def
humans_callback
(
self
,
msg
):
min_dist
=
float
(
'
inf
'
)
for
human
in
msg
.
humans
:
dist
=
math
.
sqrt
(
human
.
position
.
x
**
2
+
human
.
position
.
y
**
2
)
min_dist
=
min
(
min_dist
,
dist
)
self
.
closest_human_distance
=
min_dist
print
(
f
"
👥 Closest human at
{
min_dist
:
.
2
f
}
meters
"
)
def
configure
(
self
,
name
):
def
configure
(
self
,
name
):
print
(
"
TestController configure
"
)
print
(
"
TestController configure
"
)
...
@@ -20,17 +44,28 @@ class TestController(air_navigation.Controller):
...
@@ -20,17 +44,28 @@ class TestController(air_navigation.Controller):
def
computeVelocityCommands
(
self
,
pose
,
velocity
,
goal
):
def
computeVelocityCommands
(
self
,
pose
,
velocity
,
goal
):
print
(
"
TestController computeVelocityCommands:
"
,
pose
,
velocity
,
goal
)
print
(
"
TestController computeVelocityCommands:
"
,
pose
,
velocity
,
goal
)
base_speed
=
1.0
slow_down_radius
=
2.0
if
self
.
closest_human_distance
<
slow_down_radius
:
scale
=
self
.
closest_human_distance
/
slow_down_radius
speed
=
max
(
0.1
,
base_speed
*
scale
)
else
:
speed
=
base_speed
print
(
f
"
🚗 Adjusted speed:
{
speed
:
.
2
f
}
"
)
t
=
air_navigation
.
TwistStamped
()
t
=
air_navigation
.
TwistStamped
()
t
.
twist
.
linear
.
x
=
1.0
t
.
twist
.
linear
.
x
=
speed
t
.
twist
.
angular
.
z
=
2
.0
t
.
twist
.
angular
.
z
=
0
.0
return
t
return
t
def
setPlan
(
self
,
path
):
def
setPlan
(
self
,
path
):
print
(
"
TestController setPlan:
"
,
path
)
print
(
"
TestController setPlan:
"
,
path
)
def
setSpeedLimit
(
self
,
speed_limit
,
percentage
):
def
setSpeedLimit
(
self
,
speed_limit
,
percentage
):
print
(
"
TestController setSpeedLimit:
"
,
speed_limit
,
percentage
)
print
(
"
TestController setSpeedLimit:
"
,
speed_limit
,
percentage
)
class
TrajectoryCritic
(
air_navigation
.
TrajectoryCritic
):
class
TrajectoryCritic
(
air_navigation
.
TrajectoryCritic
):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
...
...
This diff is collapsed.
Click to expand it.
air_navigation_examples/__pycache__/__init__.cpython-310.pyc
0 → 100644
+
0
−
0
View file @
62213801
File added
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