ROS Turtlesim
This post shows you how to run turtlesim in ROS Noetic OS.
Perform the TurtleSim simulation in ROS and make the circular movement and square movement of the turtle.
Instructions:
Step 1: Open a Terminal and start the roscore
$ roscore
Step 2: Open another Terminal
To open turtlesim, give the following command.
$ rosrun turtlesim turtlesim_node
Open another Terminal
$ rosrun turtlesim turtle_teleop_key
Open the first Terminal and run the command
$ rosrun turtlesim turtlesim_node
Open the Second Terminal, go to your workspace
$ cd pradeep_ws/
$ source ./devel/setup.bash
$ rosrun ros_tutorial1 circular_movement.py
Code: circular_movement.py
#!/usr/bin/env python3
# license removed for brevity
import rospy
from geometry_msgs.msg import Twist
def circular_movement_node():
pub = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=10)
rospy.init_node('tbsim_driver', anonymous=True)
rate = rospy.Rate(1)
while not rospy.is_shutdown():
robot_velocity =Twist()
robot_velocity.linear.x =3.0
robot_velocity.angular.z=1.8
pub.publish(robot_velocity)
rate.sleep()
if __name__ == '__main__':
try:
circular_movement_node()
except rospy.ROSInterruptException:
pass
Output: Square and Circular Movement.
ROS Turtlesim |
Comments
Post a Comment