14 August 2024

ROS Turtle Sim | ROS Noetic Tutorial 3

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
ROS Turtlesim




0 comments:

Post a Comment

Powered by Blogger.

About Me

Featured Post

5G Network Simulation in NS3 using mmWave | NS3 Tutorial 2024

5G Network Simulation in NS3 Using mmWave This post shows the installation of ns3mmwave in Ubuntu 24.04 and simulates 5G networks in ns3. In...

Contact form

Name

Email *

Message *

Total Pageviews

Search This Blog

Pages

Pages

Pages - Menu

Most Popular

Popular Posts