-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs/heads/488 feature split up acting controller #508
Changes from 5 commits
ed8b710
ae9f0e7
4b90716
5760c6d
4fb8afb
9cb4c9e
efee92c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,21 @@ | ||
<!----> | ||
<launch> | ||
<arg name="role_name" default="hero" /> | ||
<arg name="control_loop_rate" default="0.05" /> | ||
<arg name="control_loop_rate" default="0.05" /> | ||
|
||
<node pkg="acting" type="velocity_controller.py" name="velocity_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="acting" type="stanley_controller.py" name="stanley_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<!--Passthrough | ||
all messages the control package needs--> | ||
<node pkg="acting" type="passthrough.py" name="passthrough" output="screen"> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="acting" type="pure_pursuit_controller.py" name="pure_pursuit_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="acting" type="vehicle_controller.py" name="vehicle_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> <!-- leaderboard expects commands every 0.05 seconds OTHERWISE IT LAGS REALLY BADLY--> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="acting" type="MainFramePublisher.py" name="MainFramePublisher" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<!-- UNCOMMENT THIS TO USE THE DEBUG_NODE FOR ACTING-TESTING --> | ||
<!-- <node pkg="acting" type="Acting_Debug_Node.py" name="Acting_Debug_Node" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
--> | ||
|
||
<!-- If you want a live rqt_plots to show up automatically, include them like following example-plot for Velocity-Controller-Testing --> | ||
<!--node pkg="rqt_plot" type="rqt_plot" output="screen" name="velocity_test" args="/carla/hero/Speed /paf/hero/target_velocity /paf/hero/throttle /paf/hero/brake"/--> | ||
|
||
</launch> | ||
<include file="$(find control)/launch/control.launch"> | ||
<arg name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
</include> | ||
</launch> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,87 @@ | ||||||||||||||||||||||||
#!/usr/bin/env python | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import ros_compatibility as roscomp | ||||||||||||||||||||||||
from ros_compatibility.node import CompatibleNode | ||||||||||||||||||||||||
from rospy import Publisher, Subscriber | ||||||||||||||||||||||||
from std_msgs.msg import Float32 | ||||||||||||||||||||||||
from geometry_msgs.msg import PoseStamped | ||||||||||||||||||||||||
from nav_msgs.msg import Path | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
from dataclasses import dataclass | ||||||||||||||||||||||||
from typing import Type, Dict | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
@dataclass | ||||||||||||||||||||||||
class passthrough: | ||||||||||||||||||||||||
pub_name: str | ||||||||||||||||||||||||
sub_name: str | ||||||||||||||||||||||||
topic_type: Type | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Rename class to follow Python naming conventions. The class name should be in PascalCase as per PEP 8 conventions. -class passthrough:
+class Passthrough: 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
class Passthrough(CompatibleNode): | ||||||||||||||||||||||||
"""This nodes sole purpose is to pass through all messages that control needs. | ||||||||||||||||||||||||
The purpose of this is that Control-Package should not have any global dependencies, | ||||||||||||||||||||||||
but is only dependent on the acting package. | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
role_name = "hero" # Legacy will change soon | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded role_name value The comment indicates this is legacy code that will change soon. Consider making this configurable through ROS parameters instead of hardcoding. - role_name = "hero" # Legacy will change soon
+ def __init__(self):
+ super().__init__('passthrough')
+ self.role_name = self.get_parameter_or('role_name', 'hero').value
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Topics for velocity controller. | ||||||||||||||||||||||||
target_velocity = passthrough( | ||||||||||||||||||||||||
pub_name="/paf/acting/target_velocity", | ||||||||||||||||||||||||
sub_name=f"/paf/{role_name}/target_velocity", | ||||||||||||||||||||||||
topic_type=Float32, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
# Topics for steering controllers | ||||||||||||||||||||||||
trajectory = passthrough( | ||||||||||||||||||||||||
pub_name="/paf/acting/trajectory", | ||||||||||||||||||||||||
sub_name=f"/paf/{role_name}/trajectory", | ||||||||||||||||||||||||
topic_type=Path, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
position = passthrough( | ||||||||||||||||||||||||
pub_name="/paf/acting/current_pos", | ||||||||||||||||||||||||
sub_name=f"/paf/{role_name}/current_pos", | ||||||||||||||||||||||||
topic_type=PoseStamped, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
heading = passthrough( | ||||||||||||||||||||||||
pub_name="/paf/acting/current_heading", | ||||||||||||||||||||||||
sub_name=f"/paf/{role_name}/current_heading", | ||||||||||||||||||||||||
topic_type=Float32, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
passthrough_topics = [target_velocity, trajectory, position, heading] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def __init__(self): | ||||||||||||||||||||||||
self.publishers: Dict[str, Publisher] = {} | ||||||||||||||||||||||||
self.subscribers: Dict[str, Subscriber] = {} | ||||||||||||||||||||||||
for topic in self.passthrough_topics: | ||||||||||||||||||||||||
self.publishers[topic.pub_name] = self.new_publisher( | ||||||||||||||||||||||||
topic.topic_type, topic.pub_name, qos_profile=1 | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
self.subscribers[topic.pub_name] = self.new_subscription( | ||||||||||||||||||||||||
topic.topic_type, | ||||||||||||||||||||||||
topic.sub_name, | ||||||||||||||||||||||||
callback=self.publishers[topic.pub_name].publish, | ||||||||||||||||||||||||
qos_profile=1, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def main(args=None): | ||||||||||||||||||||||||
"""Start the node. | ||||||||||||||||||||||||
This is the entry point, if called by a launch file. | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
roscomp.init("passthrough", args=args) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
try: | ||||||||||||||||||||||||
node = Passthrough() | ||||||||||||||||||||||||
node.spin() | ||||||||||||||||||||||||
except KeyboardInterrupt: | ||||||||||||||||||||||||
pass | ||||||||||||||||||||||||
finally: | ||||||||||||||||||||||||
roscomp.shutdown() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
if __name__ == "__main__": | ||||||||||||||||||||||||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
project(control) | ||
|
||
|
||
find_package(catkin REQUIRED) | ||
|
||
catkin_python_setup() | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
rospy | ||
std_msgs | ||
) | ||
catkin_package() | ||
|
||
|
||
include_directories( | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<launch> | ||
<arg name="role_name" default="hero" /> | ||
<arg name="control_loop_rate" default="0.05" /> | ||
|
||
|
||
<node pkg="control" type="velocity_controller.py" name="velocity_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="control" type="stanley_controller.py" name="stanley_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="control" type="pure_pursuit_controller.py" name="pure_pursuit_controller" | ||
output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
<node pkg="control" type="vehicle_controller.py" name="vehicle_controller" output="screen"> | ||
<param name="control_loop_rate" value="$(arg control_loop_rate)" /> <!-- leaderboard expects | ||
commands every 0.05 seconds OTHERWISE IT LAGS REALLY BADLY--> | ||
<param name="role_name" value="$(arg role_name)" /> | ||
</node> | ||
|
||
</launch> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<name>control</name> | ||
<version>0.0.0</version> | ||
<description>The control package for PAF Carla</description> | ||
|
||
<maintainer email="[email protected]">Vinzenz Malke</maintainer> | ||
|
||
|
||
<!-- One license tag required, multiple allowed, one license per tag --> | ||
<!-- Commonly used license strings: --> | ||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> | ||
<license>TODO</license> | ||
|
||
|
||
<exec_depend>message_runtime</exec_depend> | ||
<buildtool_depend>catkin</buildtool_depend> | ||
|
||
|
||
<export> | ||
</export> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
from distutils.core import setup | ||
from catkin_pkg.python_setup import generate_distutils_setup | ||
|
||
setup_args = generate_distutils_setup(packages=["control"], package_dir={"": "src"}) | ||
setup(**setup_args) |
vinzenzm marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having a "passthrough" class in upper and lowercase is VERY confusing, but i see one is a dataclass and the other is not.
could you please explain why it is not possible to name the dataclass different ?