ROS in TF (coordinate transformation) using the principle

July 2, 2019 21:43:05

ROS in TF

The official website of proposals for new work directly tf2, because it has a cleaner interface, and a better user experience. (Since ROS Hydro, tf the first generation has been "abandoned" in favor of tf2)

TF Introduction

TF (TransForm), that is, coordinate transformation, including the transformation of both the position and attitude. Distinction coordinate conversion and coordinate transformation.

Coordinate transformation is represented by a coordinate in a different coordinate system, the coordinate systems relative pose of different coordinate systems.

ROS robot model contains a large number of members, each member system call link (such as a hand, a head, a joint, a link), each link corresponding to a top frame (coordinate system) , represented by frame member of the coordinate system, frame and link are bound together.

TF is a popular name, in fact, it has many meanings:

  1. May be taken as a standard specification defines a set of standard data formats and data structures of the coordinate transformation. tf is essentially a tree data structure, namely "tf Tree" .
  2. tf can also be seen as a topic /tf, save the topic in the news is tf tree data structure format of the . Maintenance of the entire robot or even coordinate transformation map. Maintain and update the whole topic of the robot coordinate system is /tf, /tfthe content of the topic represents the whole robot tf tree, rather than just a conversion relationship of the two coordinate systems, so, /tfthe topic is the need to maintain a lot of nodes, each node maintains the relationship between the two frame.
  3. tf can also be seen as a package, which it contains a lot of tools. Such as visualization, see tf, debug tf etc. between the joints.
  4. tf containing part of the API interface, for programming the node. TF publisher and subscriber of the package, allows developers to more easily build and maintain a subscription to TF tree in some coordinate system conversion relationship by TF interface.

tf is a tree structure, maintain the relationship between the coordinate system on the topic of communication mechanisms to continue to publish coordinate the relationship between different link. As a tree structure, to ensure that his son has a node in the coordinate system continuously release position and orientation relationship between them, in order to make the tree intact. Only the relationship between father and son pose the correct coordinate system can be released, in order to ensure communication between any two frame.

If a link failure occurred, it will lead to error system error. So complete tf tree can not place any faults, so that we can find out the relationship between any two frame.

Between each two adjacent frame release position and orientation relationship between them by a node, this node is called the broadcaster. broadcaster is a publisher publisher, if the relative motion between the two frame, broadcaster will release relevant information.

TF principle

TF tree structure

TF is the object of the library system according to any one point of coordinate transformation between the coordinate systems of all implementations. That is, if given the coordinates of a point in a coordinate system, you can get coordinates of this point in any other coordinate system.

To achieve the above object, it is necessary to provide the current ROS systems pose any transformation between two coordinate systems.

So what is TF way to describe the pose transformation between any two records with coordinates of it?

There is a problem here. Suppose there are n coordinate system, then the relationship between them with a combination of c (n, 2) a. If such an exhaustive number will be very much, so it will not adopt this method.

For more rational and more efficiently represent the transformation between coordinate systems. TF forms using a Multi-tree to describe the coordinate system of the ROS system, each node in the tree is a coordinate system. Characteristic is that each tree node TF as long as a parent node, i.e., each coordinate system using the coordinate system has a parent, child can have multiple principles coordinate system.

TF coordinate system specifications

Each has a parent coordinate system coordinates, the coordinate system can have multiple children. TF tree is in the form of parent-child coordinate system is organized, the top is the parent coordinate system is down sub-coordinate system.

TF tree in a coordinate system having a parent-child relationship is adjacent, are connected by lines with arrows. TF by arrows in the tree represents a parent-child relationship.

FIG TF on the tree represented base_linkcoordinate system is base_footprintthe coordinate system of the sub, base_cover_linkthe coordinate system is base_footprintthe coordinate system of the sub.

Description Specification:

  1. source, target frame is a coordinate transformation concept of time, source coordinate system is the coordinate transformation source, target is the target coordinates. This time, the transformation represents the coordinate transformation .
  2. parent, child Frame is described coordinate transformation concept when, parent is the original coordinate system, child is converted coordinate system, this time the conversion described in the coordinate system conversion , but also child described coordinates in parent coordinate system .
  3. a frame coordinate transformation to a b frame (frame transform), b frame also shown in a frame is described, also it represents a point of the coordinates into coordinates in a frame in the b frame in the coordinate transformation .
  4. From parent to child coordinate system conversion (frame transform) from a point equivalent to a child coordinate system to the coordinate system of the parent coordinate conversion , the coordinate system is equal to child posture described in Frame parent coordinate system.

DETAILED TF represents a communication with a TF Tree Tree

TF tree establishment and maintenance of communication mechanism is based on Topic.

According to the principle TF tree, which is transformed by the establishment and maintenance of the relationship between father and son each coordinate system transformation to maintain relationships of all coordinate systems of the entire system. Each parent coordinate system to the coordinate system transformation child relationship is by publisher node is called broadcastor to sustained release.

Although it is issued by Topic communication mechanism parent coordinate system to the coordinate system transformation child, but not so that each pair of father and son have released a coordinate system topic, in fact, issued only one topic is /topicthe topic of a collection of all his son's release transformation between the coordinate system.

That TF mechanism is not to let each pair of father and son have released a coordinate system topic, but all the parent-child coordinate systems to the collection to a topic, the topic of data transfer is a message to all parent-child coordinate system transformation relations, is a large array of parent-child relationship of coordinate system transformation.

Tf using the converted tflisener can be monitored from any two coordinate systems. TF is the premise of the tree to get it two Unicom.

TF establish tree

You need to specify the first parent coordinate system at the beginning of the establishment of TF tree (parent frame) as the first coordinate system. such as map coordinate system of the robot system.

The first time released a coordinate transformation from the existing parent frame to a new child frame, which would add a tree branch, then that is maintenance.

TF tree establishment and maintenance relies sendtransform interfaces tfbroadcastor class tf provided.

transformBroadcaster()Class is a publisher, and the effect is to encapsulate sendTransform publish function.

TF tree maintenance

During operation to continuously update the existing parent frame to coordinate transformation of existing child frame, thus ensuring the latest position and orientation conversion relationship.

As a tree structure, to ensure that his son has a node in the frame continually release position and orientation relationship between the two frame, in order to make the tree intact. Only pose a parent-child relationship of each frame can be correctly release, in order to ensure communication between any two frame.

Use TF tree

Once properly set up a TF tree, ensure that each parent-child coordinate system can get normal maintenance, it can be provided by using the TF subscriber, subscription conversion relationship of any two coordinate systems.

How to get any coordinate system conversion relationship according TF tree?

If you want to get the conversion relationship of any two coordinate systems, in fact, the subscriber is charged /tfmessages on the topic, the message is a collection of all the published transform the relationship between father and son coordinate system. Subscribe to receive the entire TF tree is actually the current time, and then search for the tree to find the path to a conversion based on a different coordinate system of the parent-child relationship. This path can be connected from the conversion of these two coordinate systems required by the parent-child relationship passage, thereby multiplying the required final transformation relationship of these two coordinate systems by the continuous path on the transformation matrix.

TF publisher and subscriber of the package, allows developers to more easily build and maintain a subscription to TF tree in some coordinate system conversion relationship by TF interface. Tflisener tf listening with a certain specified from a frame to a B frame is converted to.

Summary (reference network resources):

The basic principle is, tfbroadcastor class, there are a publisher, tflisener class, there are a subscriber, a publication called the /tftopic, and a subscription to this topic, the message transmitted message contains the information of every parent frameid and child frameid of. This mechanism means that all tb will release a particular parent to child transformation, and all tl will receive all of these transformations, then use the data structure of a tfbuffercore tl maintains a complete tree structure and status. Based on this, tl when using the tree will be used to obtain waitfortransform lookuptransform or transformation between coordinate systems.

So even as long as a tflisener (that is, only listen transform the relationship between two coordinate systems), it is necessary to establish a connection with all tfbroadcastor, we must collect /tfthe entire TF on the tree, the tree is also responsible for the search, to find a path of transformation, then the final transformation relationship obtained by multiplying the two coordinate systems by the transformation matrix.

TF features

advantage:

  1. Details of the various numerical calculation, you need not worry, tf library can help you
  2. The interface is very simple, and will be broadcast listening on the line;
  3. Problems finding very accurate, and that is the need to maintain the relationship between the coordinate system, in particular the relationship between father and son coordinate system
  4. It provides many tools program
  5. Consider the time-dependent transformation
  6. Support tf-prefix, can be used in multi-robot. By having different robot using a different prefix, to distinguish between robots. If only one robot generally use/

Disadvantages:

  1. Tree is very simple, but sometimes very clumsy. For flat coordinate system, we need to find a common ancestor from bottom to top, and then look down from the ancestors, and to determine the relationship between the two.
  2. Each subscriber relationship in order to obtain a two coordinate systems have the same search tree, such expenses are too high, mainly network transmission load is relatively large.
  3. Difficult to meet real-time requirements, which is more obviously. This is why TF will save 10 seconds of each transform data
  4. Although the overall relatively easy to use, but many of the details are difficult to understand. For example, now () and time (0); for example, technical documentation in terms of some of the terms; for example, the use of robots in the habit, and aircraft, inertial navigation, where the vehicle habits vary widely, can not be taken for granted when used.

TF message: message between two frame

Each broadcaster node between father and son will have to coordinate dissemination of information to maintain the relationship between the coordinate conversion. TransformStampde.msgIt is /tfthe topic of the message. The short message format is used to represent the relationship between the relative coordinate transformation between two tf frame.

Description:

ROS TF tree is actually represented by the relationship between the coordinate system of the entire system, rather than simply relying on a plurality twenty-two parent-child relationship between the conversion coordinates to describe. Here TransformStampde.msgTF tree message type of message fragments i.e., wherein a pair of parent-child coordinate systems pose described embodiment, the message type TF tree-based TransformStampde.msgmessage, and therefore first introduced TransformStampde.msg. TransformStampde.msgEssentially as described in short tf TF tree Transform.

In particular message types are as follows:

geometry_msgs/TransformStamped(Showing that the message type belongs to geometry_msgsthe package, the package rather than tf)

std_mags/Header header
        uint32 seq
        time stamp
        string frame_id
string child_frame_id
geometry_msgs/Transform transform
        geometry_msgs/Vector3 translation
                float64 x
                float64 y
                float64 z
        geometry_msgs/Quaternion rotation
                float64 x
                float64 y
                flaot64 z
                float64 w

Message explain:

The message indicates that the conversion between the coordinate system of the current and its sub frame_id coordinates child_frame_id. Pose specific conversion by geometry_msgs/Transformthe message type defined, the message type indicates a three-dimensional vector translation, rotation expressed by a four-tuple.

TF message: TF Tree message type

/tfTopic content represents the whole robot tf tree, rather than just a conversion relationship of the two coordinate systems, so, /tfthe topic is the need to maintain a lot of nodes, each node maintains a parent-child relationship between the two frame. That is a /tftopic above, there may be a number of node sends a message to it.

This is equivalent to TF tree between the frame TF many mosaic. Just said TransformStampde.msgthe message type indicates the relationship between two TF frame, next to introduce the real /tftransmission on the topic TF tree message types.

TF tree tf2 corresponding message type tf2_msgs/TFMessage.msg. Showing that the message is located tf2_msgswithin the package.

tf2_msgs / TFMessage specific format of the message:

geometry_msgs/TransformStamped[] transforms
        std_msgs/Header header
                uint32 seq
                time stamp
                string frame_id
        string child_frame_id
        geometry_msgs/Transform transform
                geometry_msgs/Vector3 translation
                        float64 x
                        float64 y
                        float64 z
                geometry_msgs/Quaternion rotation
                        float64 x
                        float64 y
                        flaot64 z
                        float64 w

TF can be seen that the tree type message is actually a TransformStampedvariable length array type definition. That is the essence of a number of TF between the two message frame TransformStampedis described robot TF entire tree type message form tf2_msgs/TFMessage.msg.

TF interface roscpp in the rospy

Whether roscpp in the library or rospy in both TF, TF provides many useful interface. Here only a general description, when the specific use of the longer reference specific information.

Provide the type of structure:

  1. Definition of data types (classes): vector points quaternion, 3 * 3 rotation matrix, and the like pose
  2. Data Conversion: given the rotation matrix, the transfer function between quaternions, Euler angles, the rotation shaft
  3. Function of the operation point, vector angle, and the like of the quaternion
  4. TF class, a good package publisher and subscriber interface. You can publish coordinate system conversion related to the /tfperiod of the transform on the topic; can also subscribe to /tftopics, and get to the coordinate system from the source to the target coordinate system transformation between the two coordinate systems.

transformBroadcaster()Class is a publisher, and the effect is to encapsulate sendTransform publish function. In actual use, we need to build in a Node in tf :: TransformBroadcaster class, and then call sendTransform (), will transform posted to /tfthe period transform.

TransformListenerFrom the class is /tfreceived on the class.

TF package related command-line use

  1. Use the command line to display all of the current method frame:

    rosrun tf tf_monitor #显示当前坐标变换树的信息,主要是名称和实时的时间延时
    rostopic echo /tf #以TransformStamped消息类型的数组显示所有父子frame的位姿转换关系

    Mainly above data show

  2. Pdf create a map based on the current tf tree:

     $ rosrun tf view_frames

    The tool first subscription /tf, the subscription for 5 seconds, tf according to information received this time, plotted as a tf tree, and then create as a pdf map.

    TF will show tree frame and all of the parent-child relationship and the two frame Broadcaster, Average rate in graphical form, etc.

  3. View the current tf tree:

     $ rosrun rqt_tf_tree rqt_tf_tree

    The command also queries tf tree, but the difference from the first command is the command is dynamic query the current tf tree, any current changes can immediately see, for example, when to disconnect when connected to capture the these then displayed by rqt plug.

  4. Check transform the relationship between the two frame:

     $ rosrun tf tf_echo[source_frame][target_frame]

    The display will continue to pose a coordinate system transformation between the source and target coordinate system.

    The instructions can query into the relationship between any two of the frame.

Reference material

https://sychaichangkun.gitbooks.io/ros-tutorial-icourse163/content/chapter8/8.3.html (basic handout )

http://blog.exbot.net/archives/1686(TF understanding )

Guess you like

Origin www.cnblogs.com/sxy370921/p/11726691.html