-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multi-threaded executor for lane_chaning algortihm
- Loading branch information
Giuseppe Quaratino
committed
May 23, 2024
1 parent
e69f94d
commit 9bc2857
Showing
4 changed files
with
122 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import rclpy | ||
|
||
from odom_sub import OdomSubscriber | ||
from lane_change import LaneChange | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
odom_sub = OdomSubscriber() | ||
lane_change = LaneChange(odom_sub) | ||
|
||
executor = rclpy.executors.MultiThreadedExecutor() | ||
executor.add_node(odom_sub) | ||
executor.add_node(lane_change) | ||
|
||
executor.spin() | ||
|
||
odom_sub.destroy_node() | ||
lane_change.destroy_node() | ||
|
||
rclpy.shutdown() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from tf_transformations import euler_from_quaternion | ||
|
||
from nav_msgs.msg import Odometry | ||
|
||
class OdomSubscriber(Node): | ||
def __init__(self): | ||
super().__init__('Odometry_Subscriber_Node') | ||
|
||
self.odometry_subscriber = self.create_subscription( | ||
Odometry, | ||
'/encoder_odom', # This will change if we switch to filtered odom | ||
self.odom_callback, | ||
10) | ||
self.odometry_subscriber | ||
|
||
self.xpos = 0.0 | ||
self.ypos = 0.0 | ||
self.yaw = 0.0 | ||
self.vel = 0.0 | ||
|
||
def odom_callback(self, msg): | ||
self.xpos = msg.pose.pose.position.x | ||
self.ypos = msg.pose.pose.position.y | ||
|
||
quaternion = ( | ||
msg.pose.pose.orientation.x, | ||
msg.pose.pose.orientation.y, | ||
msg.pose.pose.orientation.z, | ||
msg.pose.pose.orientation.w, | ||
) | ||
euler = euler_from_quaternion(quaternion) # euler = [R, P, Y] | ||
|
||
self.yaw = euler[2] | ||
self.vel = msg.twist.twist.linear.x | ||
|
||
self.get_logger().info("Odom topic received") | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
odom_sub = OdomSubcriber() | ||
|
||
rclpy.spin(odom_sub) | ||
|
||
odom_sub.destroy_node() | ||
rclpy.shutdown() | ||
|
||
if __name__ == '__main__': | ||
main() |