Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CSE-478wi
lab2
Commits
79e1a521
Commit
79e1a521
authored
Feb 02, 2020
by
Kay Ke
Browse files
Rename controlnode -> control_node
parent
b68ed6c3
Changes
2
Show whitespace changes
Inline
Side-by-side
src/controlnode.py
→
src/control
_
node.py
View file @
79e1a521
...
...
@@ -7,12 +7,11 @@ from nav_msgs.msg import Odometry
from
std_msgs.msg
import
Empty
from
std_msgs.msg
import
Header
,
Float32
from
std_srvs.srv
import
Empty
as
SrvEmpty
from
lab2.msg
import
XYHVPath
from
lab2.srv
import
FollowPath
from
ta_
lab2.msg
import
XYHVPath
from
ta_
lab2.srv
import
FollowPath
from
visualization_msgs.msg
import
Marker
import
mpc
import
nonlinear
import
pid
import
purepursuit
import
utils
...
...
@@ -20,7 +19,6 @@ import utils
controllers
=
{
"PID"
:
pid
.
PIDController
,
"PP"
:
purepursuit
.
PurePursuitController
,
"NL"
:
nonlinear
.
NonLinearController
,
"MPC"
:
mpc
.
ModelPredictiveController
,
}
...
...
@@ -49,7 +47,7 @@ class ControlNode:
self
.
path_event
.
wait
()
self
.
reset_lock
.
acquire
()
ip
=
self
.
inferred_pose
if
ip
is
not
None
and
self
.
controller
.
ready
():
if
ip
is
not
None
and
self
.
controller
.
is_
ready
():
index
=
self
.
controller
.
get_reference_index
(
ip
)
pose
=
self
.
controller
.
get_reference_pose
(
index
)
error
=
self
.
controller
.
get_error
(
ip
,
index
)
...
...
@@ -60,6 +58,7 @@ class ControlNode:
if
next_ctrl
is
not
None
:
self
.
publish_ctrl
(
next_ctrl
)
if
self
.
controller
.
path_complete
(
ip
,
error
):
print
(
"Path Completed!"
)
self
.
path_event
.
clear
()
self
.
reset_lock
.
release
()
rate
.
sleep
()
...
...
@@ -86,13 +85,16 @@ class ControlNode:
rospy
.
Service
(
"/controller/follow_path"
,
FollowPath
,
self
.
cb_path
)
rospy
.
Subscriber
(
rospy
.
get_param
(
"~pose_topic"
,
"/sim_car_pose/pose"
),
PoseStamped
,
self
.
cb_pose
,
queue_size
=
10
)
car_pose_topic
=
\
(
'/car_pose'
if
int
(
rospy
.
get_param
(
'/controller/use_sim_pose'
))
==
1
else
'/pf/inferred_pose'
)
rospy
.
Subscriber
(
car_pose_topic
,
PoseStamped
,
self
.
cb_pose
,
queue_size
=
10
)
self
.
rp_ctrls
=
rospy
.
Publisher
(
rospy
.
get_param
(
"~ctrl_topic"
,
default
=
"/
vesc/high_level
/ackermann_cmd_mux/input/nav
_0
"
default
=
"/
mux
/ackermann_cmd_mux/input/nav
igation
"
),
AckermannDriveStamped
,
queue_size
=
2
)
...
...
@@ -162,9 +164,6 @@ class ControlNode:
rospy
.
loginfo
(
"End state reset"
)
return
[]
def
cb_odom
(
self
,
msg
):
self
.
inferred_pose
=
utils
.
rospose_to_posetup
(
msg
.
pose
.
pose
)
def
cb_path
(
self
,
msg
):
print
"Got path!"
path
=
msg
.
path
.
waypoints
...
...
src/main.py
View file @
79e1a521
#!/usr/bin/env python
import
controlnode
import
control
_
node
import
threading
import
signal
if
__name__
==
'__main__'
:
node
=
controlnode
.
ControlNode
(
"controller"
)
node
=
control
_
node
.
ControlNode
(
"controller"
)
signal
.
signal
(
signal
.
SIGINT
,
node
.
shutdown
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment