Reading Notes (ROS Book ⑤) "ROS Robot Development: Practical Case Analysis" Carol Fairchild Thomas L. Harman

I found this book on WeChat Reading. It is relatively easy to understand in terms of language description, and it also has cases related to drones, which I am more concerned about.

The following is excerpted from my WeChat reading notes.

◆ 1.6.1 ROS node

>> Generally speaking, a node is a process that performs certain actions. The ROS node itself is actually a software module. In addition to specific software functions, it also has the function of registering to connect to the ROS node server and communicating with other nodes in the ROS network. The design concept of ROS nodes is that each node is an independent module and interacts with each other through the communication capabilities of ROS.

>> For nodes, they can run code independently to complete their job tasks, or they can communicate with other nodes by sending or receiving messages. Messages contain data, commands, or other information necessary for the application.

◆ 1.6.2 ROS topic

>> For nodes, some nodes mainly provide information to other nodes, such as providing camera image data to nodes. Such nodes publish information, which is received by other nodes. These published information are called topics in ROS . Topics define the types of messages that will be sent by this topic. The node delivering the data publishes the name of the topic and the type of message to be sent. Nodes can subscribe to topics, and nodes subscribed to topics will be able to receive messages delivered by topics.

>> Continuing to take the camera as an example, the camera node can publish image data on the camera/image_raw topic. Image data from the camera/image_raw topic can be used by nodes that display images on the computer screen. The node that receives the information is said to have subscribed to the published topic. In the above example, the published topic is camera/image_raw. In other cases, nodes subscribe to and publish to one or more topics simultaneously.

◆ 1.6.4 ROS Node Manager

>> In the above screen output, readers can see that the computer-related information lists the ROS distribution name (kinetic) and version number parameter information, as well as some other information. The Master is defined by a Uniform Resource Identifier (URI), which determines the location information of the Master. In this example, the Master runs on a laptop computer and is used to execute the roscore command.

>> In the screen output obtained by the roscore command shown above, the parameters related to Master are as follows:
 

/rosdistro:kinetic

/rosversion:1.12.7

Kinetic is the ROS distribution used in this book. When Kinetic changes or new feature packages are added, version numbers such as 1.12.7 will be released. You can check the version information of ROS used by readers by entering the roscore command.

◆ 1.6.5 ROS commands to determine nodes and topics

>> After executing the roscore command, the terminal window used to execute the roscore command must always be running (that is, the window cannot be closed), but it can be minimized. In another terminal window, execute the rosnode list command, and the running nodes will be displayed in the window.

>> It should be noted that the /rosout node and /rosout topic have the same name. In ROS, the rosout node subscribes to the /rosout topic . All running nodes will publish their debugging information to the /rosout topic. There is no need to worry about these messages here, but these messages will be very useful for debugging a program.

>> In the system, the rosout node is connected to every running node. The /rosout_agg topic also receives messages, but it only receives messages from the rosout node, so there is no need to establish contact with all other nodes, thus saving system startup time.

◆ 1.7.1 Start turtlesim node

>> After the ROS node manager has completed starting, you can minimize this window, but it cannot be closed because to communicate between nodes, the ROS node manager must be running.

◆ 1.7.2 turtlesim node

>>/turtlesim here is the node we want to use. Note that there is a difference between node naming and function package naming. /turtlesim is the node, turtlesim is the function package .

>> To view related content about the publishing topics, subscription topics and services of the turtlesim node, enter the following command:

$ rosnode info/turtlesim

>>The execution results are as follows:

 

 >> Figure 1.6 shows the relationship between turtlesim nodes and topics. The ovals are nodes, and the rectangular boxes are topics.

◆ 1.7.3 turtlesim topics and news

>> To view the topic type of each topic, enter the following command (take the /turtle1/color_sensor topic as an example):

$ rostopic type /turtle1/color_sensor

The execution output is:

turtlesim/Color
turtlesim/Pose

>> The message type representing the /turtle1/color_sensor topic is turtlesim/Color. Please refer to the ROS message type naming format:

[package name]/[message type]

>> In summary, the relationship between the topics and messages of the /turtlesim node is shown in Table 1.1.

Table 1.1 Topics and messages

>> The table shows the topics, topic types, message formats and data values ​​of the two topics of the /turtlesim node, as well as the commands used and other related information.

◆ 1.7.4 Control turtle movement by publishing /turtle1/cmd_vel topic

>> You can control the turtle to make circular motion through the following commands:

$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

The above command controls the turtle to perform circular motion at a linear speed of 2m/s and an angular speed of 1.8 rad/s. The command specifies the topic, message type, repeat option (-r), and speed values.

>> The command line of ROS and Ubuntu has a tab completion function. Enter the command to the data value and press the Tab key. The format of the data value will be displayed. You can delete the data value format by using the backspace key and enter the corresponding value according to the prompts. .

◆ 1.7.6 turtlesim parameter server

>> For example, if you want to change the background color of the turtle to red, use the rosparam set command to set the blue and green data values ​​to 0, and set the red data value to the maximum value of 255. It should be noted that the clear option of rosservice must be executed before changing the color. 1.rosparam get command

The default turtle background color is blue. You can use the rosparam get/ command to get the values ​​of all parameters on the entire parameter server. As follows:

$ rosparam get /

The execution output is:

2.rosparam set command

As mentioned before, to change the color of the turtle background to red, you need to execute the rosparam set command:

You will see that the background color changes to red. You can also use the rosparam get/ command to determine the result of parameter settings.

◆ 1.7.7 ROS service to control turtle movement

>> We can use the rosservice remote control port option to move the turtle. The format of the command is: rosservice call<service name><service arguments>, where service arguments contain the turtle's position coordinates x, y and azimuth angle. For example, to move the turtle to coordinates [1, 1] with an azimuth angle of 0, you need to enter the following command:

$ rosservice call /turtle1/teleport_absolute 1 1 0

◆ 1.9 Summary of this chapter

>> Gazebo, a simulation tool that can simulate the external environment in which the robot can move and simulate the physical characteristics of the robot.

◆ 7.1 Introduction to quadcopter

>> A quadcopter is a type of unmanned aerial vehicle (UAV) in the broad concept. It uses four engines and propellers to provide upward power.

>> You can see that the Crazyflie has four propellers (rotors), which are used to provide upward power in the vertical direction when the aircraft takes off and maintains its height. First of all, we should have the concept that this kind of aircraft is a rotorcraft because its lift is generated by the rotor (as shown in Figure 7.1) rather than the wings of the aircraft. Secondly, the quadcopter is not a helicopter, because the helicopter is controlled by the main propeller and the tail rotor. The function of the tail rotor is to make the aircraft rotate with the rotation angle of the main horizontal propeller to maintain the balance of the aircraft. This is different from a quadcopter.

The flight control of a quadcopter is achieved by changing the rotational speed of one or more propellers. Its propeller is a fixed-pitch propeller, which means that the angle relative to the aircraft body cannot be changed.

◆ 9.4 Crazyflie Control

>> As you can see in this book, the cmd_vel topic (geometry_msgs/Twist message) is a common control method for ROS robots, whether they are ground or aerial robots. For TurtleBot, it uses mobile_base_commands/velocity and cmd_vel_mux/input/navi for movement. As for Crazyflie, it controls the flight of the quadcopter by publishing the crazyflie/cmd_vel topic.

Guess you like

Origin blog.csdn.net/qq_38250687/article/details/122542379