Using ROS nodes (v)

Source: Internet
Author: User

Start Roscore First

In order to obtain the node information, you can use the Rosnode command

$ rosnode

Obtained an acceptable list of parameters

Use the Rosrun command to start a new node, as shown below

$ Rosrun Turtlesim  

We can see a new window appears, with a small turtle in the middle, such as:

A new node appears

Using themes to interact with nodes

Now use a node and let the node do the following:

$ Rosrun Turtlesim  

Through the topic of the node subscription, we can use the arrow keys to move the turtle, such as:

Why do the little turtles move when Turtle_teleop_key executes?

Use the following command to view a list of topics

Using the echo parameter, you can view the information emitted by the node. Run the following command line and use the keyboard to start the message

$ rostopic Echo/turtle1/cmd_vel

See similar display

Use the command line to wipe good-looking message types

Rostopic  Type  

If you want to see the message field, use the following command:

$ rosmsg Show Geometry_msgs/twist

These tools allow us to publish topics directly using Rostopic Pub [topic] [Msg_type] [args] command

$ rostopic Pub-1 /turtle1/cmd_vel  '[2.0, 0.0, 0.0]'[0.0, 0.0, 1.8]'

Parametric analysis:

Rostopic Pub This command will post a message to a given topic.

-1 (single dash) This parameter option causes Rostopic to exit immediately after publishing a message.

/turtle1/command_velocity This is the name of the topic to which the message is posted.

Turtlesim/velocity This is the type of message being published.

--(double dash) This tells the command option parser that the next parameter section is not a command option. This must be added when the argument contains a dash-(for example, a minus sign).

2.0 1.8 As mentioned earlier, there are two floating-point elements in a turtlesim/velocity message: linear and angular. In this example, 2.0 is the value of linear, and 1.8 is the value of angular. These parameters are actually written in the YAML syntax format, which is described in more detail in the YAML documentation.

The Little Turtle draws a circle:

You may have noticed that the turtle has stopped moving. This is because the turtle needs a stable command flow of 1Hz to keep the movement state. We can use the rostopic pub-r command to publish a stable command flow

Rostopic pub/turtle1/cmd_vel geometry_msgs/twist-r 1--' [2.0, 0.0, 0.0] ' [0.0, 0.0, 1.8] '

.. Using Rostopic Hz

The rostopic Hz command can be used to see how often data is published. Usage: rostopic Hz [topic]

Let's take a look at how fast turtlesim_node released /turtle/pose :

Rostopic Hz/turtle1/pose

Now we can see that Turtlesim is releasing data to turtle at about 60Hz.

Using ROS nodes (v)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.