working turtlebot3 sim

This commit is contained in:
Your Name 2023-07-05 11:36:16 +02:00
parent 0893234690
commit 4d41485c47
3 changed files with 65 additions and 14 deletions

View File

@ -41,6 +41,9 @@ class TwistPublisher(Node):
self.publisher_ = self.create_publisher( self.publisher_ = self.create_publisher(
Twist, "/diff_cont/cmd_vel_unstamped", 1 Twist, "/diff_cont/cmd_vel_unstamped", 1
) )
self.publisher_2 = self.create_publisher(Twist, "/cmd_vel", 1)
self.create_subscription(Joy, "/joy", self.joy_callback, 1) self.create_subscription(Joy, "/joy", self.joy_callback, 1)
self.timer = self.create_timer(1 / publish_frequency_hz, self.timer_callback) self.timer = self.create_timer(1 / publish_frequency_hz, self.timer_callback)
@ -67,9 +70,10 @@ class TwistPublisher(Node):
self.update_smooth_window() self.update_smooth_window()
self.calc_smooth_speed() self.calc_smooth_speed()
msg.linear.x = self.linear msg.linear.x = self.linear_out
msg.angular.z = self.angular msg.angular.z = self.angular_out
self.publisher_.publish(msg) self.publisher_.publish(msg)
self.publisher_2.publish(msg)
self.get_logger().info( self.get_logger().info(
"Linear_window: {}, Linear_out: {}, Angular_window: {}, Angular_out: {}".format( "Linear_window: {}, Linear_out: {}, Angular_window: {}, Angular_out: {}".format(
self.linear_window, self.linear_window,

View File

@ -1,16 +1,19 @@
from launch import LaunchDescription from launch import LaunchDescription
from launch_ros.actions import Node from launch_ros.actions import Node
def generate_launch_description(): def generate_launch_description():
return LaunchDescription([ return LaunchDescription(
Node( [
package='dcaitirobot', Node(
executable='joy', package="dcaitirobot",
name='joystick', executable="joy",
), name="joystick",
Node( ),
package='dcaitirobot', Node(
executable='twistcalc', package="dcaitirobot",
name='twistcalc', executable="twistcalc",
) name="twistcalc",
]) ),
]
)

View File

@ -0,0 +1,44 @@
from pathlib import Path
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from ament_index_python import get_package_share_directory
def generate_launch_description():
return LaunchDescription(
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
str(Path(__file__).parent.absolute() / "remote_control_launch.py")
)
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
str(
(
Path(
get_package_share_directory("turtlebot3_gazebo")
).absolute()
/ "launch"
/ "turtlebot3_world.launch.py"
)
)
)
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
str(
(
Path(get_package_share_directory("slam_toolbox")).absolute()
/ "launch"
/ "online_async_launch.py"
)
)
),
launch_arguments=[("use_sim_time", "True")],
),
]
)