Skip to main content

Connecting the Robot to ROS

  • Chapter
  • First Online:
Introduction to Intelligent Robot System Design

Abstract

The robot operating system (ROS) is a widely used framework that enables the underlying code to be reused in different systems, thereby, developers can focus on the implementation of robot application functions. This chapter first introduces the origin, architecture, and features of ROS. Thereafter, instructions for installing ROS and setting environment variables are explained in detail, followed by instructions for the ROS files and communication mechanism. Based on the above content, readers will be able to write a ROS program and familiarize themselves with the ROS workspace and packages and the writing and running of nodes. Additionally, several common ROS components are presented, including visualization tools to facilitate the debugging of the robot system and rosbag for data logging to facilitate the testing of algorithms. This chapter concludes by describing the connection of a robot to ROS and familiarizing readers with the ROS framework by explaining the controlling of Spark robot.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 84.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Linux common commands, https://www.cnblogs.com/xuxinstyle/p/9609551.html

Author information

Authors and Affiliations

Authors

Appendices

Further Reading

The mathematical knowledge of coordinate system transforms.

2.1.1 Description of a Position

$$ AP=\left[\begin{array}{c}{p}_x\\ {}{p}_y\\ {}{p}_z\end{array}\right] $$

The aforementioned expression represents a coordinate system, {A}, with three mutually orthogonal unit vectors with solid heads. A point P is represented as a vector and can equivalently be considered as a position in space, or simply as an ordered set of three numbers. The individual elements of a vector are assigned the subscripts x, y, and z. In summary, the position of a point in space is described using a position vector.

2.1.2 Description of an Orientation

Often, we will find it necessary not only to represent a point in space but also to describe the orientation of a body in space. In order to describe the orientation of a body, we will attach a coordinate system to the body and then give a description of this coordinate system relative to the reference system. There, one way to describe the body-attached coordinate system{B} is to write the unit vectors of its three principal axes^2 in terms of the coordinate system{A}. We name it with the notation \( {}_{\mathrm{B}}{}^{\mathrm{A}}\mathrm{R} \):

$$ {}_B{}^AR=\left[{}^A{{\hat{X}}_B}^A{{\hat{Y}}_B}^A{\hat{Z}}_B\right]=\left[\begin{array}{ccc}{\hat{X}}_B\cdot {\hat{X}}_A& {\hat{Y}}_B\cdot {\hat{X}}_A& {\hat{Z}}_B\cdot {\hat{X}}_A\\ {}{\hat{X}}_B\cdot {\hat{Y}}_A& {\hat{Y}}_B\cdot {\hat{Y}}_A& {\hat{Z}}_B\cdot {\hat{Y}}_A\\ {}{\hat{X}}_B\cdot {\hat{Z}}_A& {\hat{Y}}_B\cdot {\hat{Z}}_A& {\hat{Z}}_B\cdot {\hat{Z}}_A\end{array}\right] $$

The matrix has the following property:

$$ {}_B{}^AR={{}_A{}^BR}^{-1}={{}_A{}^BR}^T $$

2.1.3 Description of a Frame

Normally, the situation of a position and an orientation pair arises so often in robotics that we define an entity called a frame, which is a set of four vectors giving position and orientation information. For example, frame{B} is described by \( {}_{\mathrm{B}}{}^{\mathrm{A}}\mathrm{R} \)and APBORG, where APBORG is the vector that locates the origin of the frame {B}:

$$ \left\{B\right\}=\left\{{}_B{}^AR,{{}^AP}_{BORG}\right\} $$

2.1.4 Transformation from One Frame to Another

We know the description of a vector with respect to some frame {B}, and we would like to know its description with respect to another frame, {A}. We now consider the general case of transformation. Here, the origin of frame {B} is not coincident with that of frame {A} but has a general vector offset. The vector that locates {B}'s origin is called APBORG. Also, {B} is rotated with respect to {A}, as described by \( {}_{\mathrm{B}}{}^{\mathrm{A}}\mathrm{R} \). Given BP, we wish to compute AP as in figure below.

A three-dimensional coordinate system of X wedge subscript A, Y wedge subscript A, and Z wedge subscript A for left parenthesis A right parenthesis with lines of A subscripts P and P subscript BORG, along with the coordinate system of X, Y, and Z wedge subscript B with a line of B subscript P.

We can first change BP to its description relative to an intermediate frame that has the same orientation as {A}, but whose origin is coincident with the origin of {B}. We then account for the translation between origins by simple vector addition and obtain the following:

$$ {}^AP={}_B{}^AR{}^BP{+}^A{P}_{BORG} $$

Then, we introduce a transformation from one frame to another as an operator in matrix form as below formula.

$$ {}^AP={{}_B{}^AT}^BP $$

The above formula has below structure; the 4*4 matrix in this structure is called a homogeneous transform matrix. It can be seen as a simple matrix representation of the rotation and translation of general transformations.

$$ \left[\begin{array}{c}{}^AP\\ {}1\end{array}\right]=\left[\begin{array}{cc}{}_B{}^AR& {{}^AP}_{BORG}\\ {}0\kern0.5em 0\kern0.5em 0& 1\end{array}\right]\left[\begin{array}{c}{}^BP\\ {}1\end{array}\right] $$

Exercises

  1. 1.

    What does a ROS package contain? Which two of these components are indispensable in forming the smallest unit of a package?

  2. 2.

    What is the framework of the workspace? How many folders does it contain?

  3. 3.

    What are the three communication mechanisms of ROS? Explain their features and differences.

  4. 4.

    Using ROS can realize multi-node deployment on different control machines for distributed communication, thereby decoupling the system. In a LAN, the IP address of the ROS master node is 192.168.0.101, and the subnet mask is 255.255.255.0, how many computer controllers can be deployed in the LAN for communication?

  5. 5.

    Briefly describe the difference between a topic and a service.

  6. 6.

    What is the meaning of the coordinate TF? Give examples of robot application scenarios where coordinate TF might be used.

  7. 7.

    According to the principle of TF transformation, for a 7-DOF robotic arm, the homogeneous transformation matrix of the i-axis coordinate system {i} relative to the (i-1)-axis coordinate system {i  − 1} is expressed as \( {}_i{}^{i-1}T \). How to solve the transformation matrix \( {}_{7\ }{}^{0\ }T \) of the end coordinate system {7} relative to the base coordinate system {0}.

  8. 8.

    The expression of TF can be represented by the Euler angle and Quaternion; please derive the transformation formula between them.

  9. 9.

    What is the difference between Gazebo and rviz?

  10. 10.

    What are the external devices of ROS? Which communication mechanism of ROS is used to communicate with the robot controller?

  11. 11.

    Write ROS nodes to obtain computer camera data, publish the data as a topic, and then, display the topic content at the terminal.

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Peng, G., Lam, T.L., Hu, C., Yao, Y., Liu, J., Yang, F. (2023). Connecting the Robot to ROS. In: Introduction to Intelligent Robot System Design. Springer, Singapore. https://doi.org/10.1007/978-981-99-1814-0_2

Download citation

Publish with us

Policies and ethics