import rclpy
from geometry_msgs.msg import Twist
from rclpy.node import Node
import time
class TurtleMover(Node):
def __init__(self):
super().__init__('turtle_mover')
self.publisher_ = self.create_publisher(Twist, '/turtle1/cmd_vel', 10)
self.timer = self.create_timer(0.1, self.timer_callback)
self.msg = Twist()
def timer_callback(self):
self.move_in_circle()
def move_in_circle(self):
# 원을 그리기 위한 속도 설정
self.msg.linear.x = 2.0 # 직선 속도
self.msg.angular.z = 12.0 # 각속도 (회전 속도)
self.publisher_.publish(self.msg)
def main(args=None):
rclpy.init(args=args)
turtle_mover = TurtleMover()
rclpy.spin(turtle_mover)
turtle_mover.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
'**Autonomous driving tech. > *ROS2( using gazebo )' 카테고리의 다른 글
[Gazebo] 2D SLAM by using rviz2 (0) | 2024.12.20 |
---|---|
Obstacle avoidance algorithm (1) | 2024.12.20 |
[Gazebo] Teleoperation practice (0) | 2024.12.15 |
[Gazebo] Receiving LiDAR point cloud data (0) | 2024.12.14 |
[Gazebo] Ubuntu를 사용하여 vcxsrv 화면에 띄우고 사물 추가해보기 (0) | 2024.12.12 |