Service and Topic

Service

Note: myCobot Pro 600 and myCobot Pro 630 devices do not support Service usage.

Service is a request-response communication mechanism. One node can provide a service, and another node can request the service and wait for a response. Services are usually used to perform time-consuming operations or tasks that require interaction, such as performing calculations and obtaining data.

Related commands and instructions:

Command Detailed description
rosservice list Display active service information
rosservice info [service name] Display information of a specified service
rosservice type [service name] Display service type
rosservice find [service type] Find services of a specified service type
rosservice uri [service name] Display ROSRPC URI services
rosservice args [service name] Display service parameters
rosservice call [service name] [parameters] Request services with input parameters

Topic

Topic is a communication mechanism in publish-subscribe mode. Nodes can publish messages to a topic or subscribe to a topic to receive messages. Multiple nodes can publish and subscribe to the same topic at the same time to broadcast and receive information. Topic is mainly used for data transmission with low real-time requirements, such as sensor data, status information, etc.

Related commands and instructions:

Command Detailed description
rostopic list Display the active topic directory
rostopic echo [topic name] Display the message content of the specified topic in real time
rostopic find [type name] Display topics using the specified type of message
rostopic type [topic name] Display the message type of the specified topic
rostopic bw [topic name] Display the message bandwidth of the specified topic
rostopic hz [topic name] Display the message data publishing cycle of the specified topic
rostopic info [topic name] Display the information of the specified topic
rostopic pub [topic name] [message type] [parameters] Publish a message with the specified topic name

Difference between service and topic:

topic service
Synchronicity Asynchronous Synchronous
Communication model Publish/Subscribe Request/Response
Underlying protocol ROSTCP/ROSUDP ROS service protocol RPC
Feedback mechanism No Yes
Buffer Yes No
Real-time Weak Strong
Node relationship Many-to-many One-to-many
Applicable scenarios Data transmission Logical processing

You can go to service and topic to learn more about the use of these two functions

Introduction to msg and srv

  • msg: msg files are simple text files that describe the fields of ROS messages. They are used to generate source code for messages in different languages ​​(c++ or python, etc.).

  • srv: srv files are used to describe services. It consists of two parts: request and response. msg files are stored in the msg directory of the package, while srv files are stored in the srv directory.

rosmsg

rosmsg is a command-line tool for displaying information about ROS message types.

rosmsg demo:

rosmsg show # Display message description
rosmsg info # Display message information
rosmsg list # List all messages
rosmsg md5 # Display md5 encrypted messages
rosmsg package # Display all messages under a certain function package
rosmsg packages # List function packages containing messages
  • rosmsg list Will list all msg in the current ROS

  • rosmsg packages List all packages containing messages

  • rosmsg package List all msg under a certain package

//rosmsg package # Package name
rosmsg package turtlesim
  • rosmsg show Display message description
//rosmsg show # Message name
rosmsg show turtlesim/Pose
# Result:
float32 x
float32 y
float32 theta
float32 linear_velocity
float32 angular_velocity
  • rosmsg info Same as rosmsg show

  • rosmsg md5 A verification algorithm to ensure the consistency of data transmission

rossrv

rossrv is a command line tool used to display information about ROS service types, and its syntax is highly similar to rosmsg.

rossrv show # Display service message details
rossrv info # Display service message related information
rossrv list # List all service information
rossrv md5 # Display md5 encrypted service message
rossrv package # Display all service messages under a certain package
rossrv packages # Display all packages containing service messages
  • rossrv list Will list all srv messages in the current ROS

  • rossrv packages List all packages containing service messages

  • rossrv package List all msg under a certain package

//rossrv package # Package name
rossrv package turtlesim
  • rossrv show Display message description
//rossrv show # Message name
rossrv show turtlesim/Spawn
# Result:
float32 x
float32 y
float32 theta
string name
---
string name
  • rossrv info The same function as rossrv show

  • rossrv md5 Use md5 verification (encryption) for service data

Introduction to URDF

  • Unified Robot Description Format, abbreviated as URDF. The urdf function package in ROS contains a C++ parser for URDF. The URDF file uses XML format to describe the robot model.

  • URDF cannot be used alone and needs to be combined with Rviz or Gazebo. URDF is just a file that needs to be rendered into a graphical robot model in Rviz or Gazebo.

urdf file description

Code example:

Here only part of the code is intercepted for display:

<?xml version="1.0"?>
<robot  xmlns:xacro="http://www.ros.org/wiki/xacro" name="mycobot_ai_with" >

  <xacro:property name="width" value=".2" />

  <link name="env">
  <inertial>
    <origin xyz="0 0 0" rpy="0 0 0"/>
      <mass value="10"/>
      <inertia
        ixx="1.0" ixy="0.0" ixz="0.0"
        iyy="1.0" iyz="0.0"
        izz="1.0"/>
  </inertial>
    <visual>
      <geometry>
         <!--- 0.0 0 -0.04  1.5708 3.14159-->
       <mesh filename="package://mycobot_description/urdf/mycobot/suit_env.dae"/>
      </geometry>
      <origin xyz = "0 0 0.0" rpy = "1.5708 0 -1.5708"/>
    </visual>
  </link>

  <link name="joint1">
    <inertial>
    <origin xyz="0 0 0.1" rpy="0 0 0"/>
      <mass value="0.2"/>
      <inertia
        ixx="1.0" ixy="0.0" ixz="0.0"
        iyy="1.0" iyz="0.0"
        izz="1.0"/>
  </inertial>
    <visual>
      <geometry>
         <!--- 0.0 0 -0.04  1.5708 3.14159-->
       <mesh filename="package://mycobot_description/urdf/mycobot/joint1.dae"/>
      </geometry>
      <origin xyz = "0.0 0 0.02 " rpy = " 0 0 -1.5708"/>
    </visual>
    <collision>
      <geometry>
         <!--- 0.0 0 -0.04  1.5708 3.14159-->
       <mesh filename="package://mycobot_description/urdf/mycobot/joint1.dae"/>
        </geometry>
        <origin xyz = "0.0 0 0.02 " rpy = " 0 0 -1.5708"/>
    </collision>
  </link>

  <joint name="vision_joint" type="fixed">
    <axis xyz="0 0 0"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="env"/>
    <child link="joint1"/>
    <origin xyz= "0 0 0" rpy = "0 0 0"/>
  </joint>

<link name="world"/>
<joint name="fixed" type="fixed">
  <parent link="world"/>
  <child link="env"/>
</joint>

</robot>

It can be seen that the urdf file is not complicated, mainly composed of the two parts of link and joint that are repeated continuously.

The link element describes a rigid body with inertia, visual characteristics, and collision properties

Attributes

name:

Name used to describe the link itself

Elements

  • <inertial> (optional)

  • Inertial properties of the link

  • <origin> (optional, defaults to identity if not specified)
  • Defines the reference coordinates of the inertial reference frame relative to the link coordinate system. The coordinates must be defined at the center of gravity of the link, and the coordinate axes may not be parallel to the principal axes of inertia.
  • xyz (optional, defaults to zero vector) Represents the offsets in the x, y, z x,y,zx,y,z directions, in meters.
  • rpy (optional: defaults to identity if not specified) Represents the rotation of the coordinate axis in the RPY direction, in radians.
  • <mass> Mass properties of the link
  • <inertia> 3×3 rotational inertia matrix, consisting of six independent quantities: ixx, ixy, ixz, iyy, iyz, izz.
  • <visual> (optional)
  • Visual properties of the link. Used to specify the shape of the link display (rectangle, cylinder, etc.). The same link can have multiple visual elements, and the shape of the link is formed by two of the multiple elements. In general, if the model is more complex, it can be drawn by soildwork and then generate stl calls. Simple shapes such as adding end effectors can be written directly. At the same time, the position of the geometric shape can be adjusted here according to the gap between the theoretical model and the actual model.
  • <namel> (optional) The name of the connecting rod geometry.
  • <origin> (optional, defaults to identity if not specified)
  • The coordinate system of the geometric shape relative to the coordinate system of the connecting rod.
  • xyz (optional: defaults to zero vector) Indicates the offset in the x, y, z x,y,zx,y,z direction, in meters.
  • rpy (optional: defaults to identity if not specified) Indicates the rotation of the coordinate axis in the RPY direction, in radians.

  • <geometry> (required)

  • The shape of the visual object, which can be one of the following:
  • <box> Rectangle, elements include length, width, and height. The origin is at the center.
  • <cylinder> Cylinder, elements contain radius, length. Origin center.
  • <sphere> Sphere, elements contain radius. Origin at center.
  • <mesh> Mesh, determined by file, and scale is provided to define its boundaries. Collada .dae files are recommended, .stl files are also supported, but must be a local file.
  • <material> (optional)
  • Material of the visual component. Can be defined outside the link tag, but must be in the robot tag. When defined outside the link tag, the link name must be referenced.
  • <color> (optional) Color, composed of red/green/blue/alpha, size range [0,1].
  • <texture> (optional) Material properties, defined by file.
  • <collision> (optional)
  • Collision properties of the link. Collision properties are different from the visual properties of the link, and a simple collision model is often used to simplify calculations. The same link can have multiple collision attribute tags. The collision attribute representation of the link is composed of the set of geometric shapes it defines.
  • <name> (optional) Specifies the name of the link geometry
  • <origin> (optional, defaults to identity if not specified)
  • The reference coordinate system of the collision component relative to the reference coordinate system of the link coordinate system.
  • xyz (optional, defaults to zero vector) Represents the offset in the x, y, z x,y,zx,y,z direction, in meters.
  • rpy (optional, defaults to identity if not specified) Represents the rotation of the coordinate axis in the RPY direction, in radians.
  • <geometry> Same as the geometry element description above

For detailed elements and the functions of each element, please go to the official document for viewing

joint section

The joint section describes the kinematics and dynamics of the joint and specifies the safety limits of the joint.

Properties of joint:

name:

Specifies a unique name for the joint

type:

Specifies the type of joint, where type can be one of the following:

  • revolute - A hinge joint that rotates along an axis with a range specified by upper and lower limits.
  • continuous - A continuous hinge joint that rotates around an axis with no upper and lower limits.
  • prismatic - A sliding joint that slides along an axis with a range specified by upper and lower limits.
  • fixed - This is not a true joint as it cannot move. All degrees of freedom are locked. This type of joint does not require axis, calibration, dynamics, limits or safety_controller.
  • floating - This joint allows motion in all 6 degrees of freedom.
  • planar - This joint allows motion in a plane perpendicular to the axis.

Elements of joint

  • <origin> (optional, defaults to identity if not specified) Transformation from parent link to child link, joint is located at the origin of child link. Modifying this parameter can adjust the position of the link, which can be used to adjust the error between the actual model and the theoretical model, but it is not recommended to modify it drastically, because this parameter affects the position of the link stl, which is easy to affect the collision detection effect.

  • xyz (optional: defaults to zero vector) Represents the offset in the x, y, z x, y, z axis direction, in meters.

  • rpy (optional: defaults to zero vector) Represents the angle of rotation around a fixed axis: roll around the x axis, pitch around the y axis, yaw around the z axis, expressed in radians.
  • <parent> (required)

  • The name of the parent link is a mandatory attribute.

  • link The name of the parent link is the name of this link in the robot structure tree.

  • <child> (required)

  • The name of the child link is a mandatory attribute.

  • link The name of the child link, which is the name of this link in the robot structure tree.

  • <axis> (optional: defaults to (1,0,0))

  • The axis of the joint in the joint coordinate system. This is the axis of rotation (revolute joint), the axis along which the prismatic joint moves, and the standard plane of the planar joint. This axis is specified in the joint coordinate system. Modifying this parameter can adjust the axis around which the joint rotates. It is often used to adjust the direction of rotation. If the model's rotation direction is opposite to the actual direction, just multiply by -1. Fixed and floating joints do not need this element.

  • xyz (required) The x, y, z components of the axial vector, as a normalized vector.

  • <calibration> (optional)

  • The reference point of the joint, used to calibrate the absolute position of the joint.

  • rising (optional) The reference point triggers a rising edge when the joint moves in the positive direction.

  • falling (optional)

The reference point triggers a falling edge when the joint moves in the forward direction.

  • <dynamics> (optional)

  • This element is used to specify the physical properties of the joint. Its value is used to describe the modeling properties of the joint, especially during simulation.

<limit> (required when the joint is a revolute or translation joint)

  • This element is the kinematic constraint of the joint.

  • lower (optional, defaults to 0)

Attribute that specifies the lower limit of the joint's range of motion (in radians for revolute joints and meters for prismatic joints). This attribute is ignored for continuous joints.

  • upper (optional, defaults to 0)

Attribute that specifies the upper limit of the joint's range of motion (in radians for revolute joints and meters for prismatic joints). This attribute is ignored for continuous joints.

  • effort (required)

Attribute that specifies the maximum force with which the joint is applied.

  • velocity (required)

Attribute that specifies the maximum velocity with which the joint is applied.

<mimic>(optional)

  • This tag is used to specify a defined joint to mimic an existing joint. The value of this joint can be calculated using the following formula:

value = multiplier * other_joint_value + offset

  • joint(required) The name of the joint to be mimicked.

  • multiplier(optional) Specifies the multiplier factor in the above formula.

  • offset(optional) Specifies the offset term in the above formula. The default value is 0

<safety_controller> (optional)

  • This element is a safety control limit. The data under this element will be read into move_group, but it is actually invalid. move_group will skip this limit and directly read the parameter content under limit. At the same time, setting this element may cause planning failure.

  • soft_lower_limit (optional, default is 0) This attribute specifies the lower limit of the joint safety control boundary, which is the starting limit of the joint safety control. This value needs to be greater than the lower value in the limit above.

  • soft_upper_limit (optional, default is 0) This attribute specifies the upper limit of the joint safety control boundary, which is the starting limit of the joint safety control. This value needs to be less than the upper value in the limit above.
  • k_position (optional, default is 0) This attribute is used to describe the relationship between position and velocity.
  • k_velocity (required) This attribute is used to describe the relationship between force and velocity.

For detailed elements and their functions, please visit http://wiki.ros.org/urdf/XML/joint for more information.

results matching ""

    No results matching ""