Ros
1 May 2023

Introduction to ROS

ROS Basics

Introduction to ROS

image

Keypoints:

  • What’s ROS
  • Core concepts
  • Command line tools

What’s ROS

  • ROS is robot operating system.
  • ROS is the most popular open-source framework for writing robot software and the de facto standard for robot software development.
  • ROS is:
    • a telemetry system that allows you to communicate with your robot, a development environment that allows you to write robot software;
    • a set of tools that allows you to visualize and debug your robot, such as TF, RViz, Gazebo, and RQT;
    • with many application packages, such as navigation, SLAM, manipulation, moveit and so on;
    • a ecosystem that allows you to share your code with others and use others’ code.

Core concepts

  • Nodes: A node is a process that performs computation. Nodes are combined together into a graph and communicate with one another using streaming topics, RPC services, and the Parameter Server. Nodes are typically written in C++ or Python, but other language implementations are supported. Different ROS implementations can communicate with each other which is in different language or different computer through a common ROS Master.

  • ROS Master: The ROS Master provides naming and registration services to the rest of the nodes in the ROS system. Without the Master, nodes would not be able to find each other, exchange messages, or invoke services. The ROS Master also facilitates parameter server, which allows nodes to store parameters at a global location and share them among each other.

  • Topics: Nodes can publish or subscribe to a topic. A topic is a bus over which nodes exchange messages unsynchronously. Topics have anonymous publish/subscribe semantics, which decouples the production of information from its consumption. In general, nodes are not aware of who they are communicating with. Instead, nodes that are interested in data subscribe to the relevant topic; nodes that generate data publish to the relevant topic. There can be multiple publishers and subscribers to a topic.

  • Messages: Nodes communicate with each other by passing messages. A message is a simple data structure, comprising typed fields. Standard primitive types (integer, floating point, boolean, etc.) are supported, as are arrays of primitive types. Messages can include arbitrarily nested structures and arrays (much like C structs).

  • Services: While topics enable nodes to send data to each other, services allow nodes to call functions on each other. A service is defined by a pair of message structures: one for the request and one for the response. A providing node offers a service under a string name, and a client calls the service by sending the request message and awaiting the reply. Services are synchronous: the service call only returns once the service has completed. Servers can manage multiple requests simultaneously. Clients can also make persistent connections to services, allowing for streaming communication.

  • Parameters: The Parameter Server is a shared, multi-variate dictionary that is accessible via network APIs. It is intended to store settings such as configuration parameters. More about static parameters.

Command line tools

  • roscore : to launch ros master.

  • rosrun : to run a specific node.
  • rqt_graph: to visualize ros nodes and their connection.
  • rosnode: to get information about ros nodes.
    • rosnode list: to list all ros nodes.

    • rosnode info: to get information about a specific node.

  • rostopic: to get information about ros topics.
    • rostopic list: to list all ros topics.

    • rostopic info: to get information about a specific topic.
    • rostopic echo: to print messages to the screen.
    • rostopic pub: to publish messages to a topic.
      • Format: rostopic pub topic_name message_name data
      • Example: rostopic pub /turtle1/cmd_vel geometry_msgs/Twist "linear: rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
  • rosmsg: to get information about ros messages.
    • rosmsg show: to get information about a specific message.
  • rosservice: to get information about ros services.
    • rosservice list: to list all ros services.
    • rosservice info: to get information about a specific service.
    • rosservice call: to call a specific service.
  • rosbag: to record and playback messages.
    • rosbag record: to record messages.
      • rosbag record -a: to record all messages.
      • Format: rosbag record -a -O bag_file_name
      • Example: rosbag record -O subset /turtle1/cmd_vel /turtle1/pose : to record specific messages (i.e /turtle1/cmd_vel /turtle1/pose) and store it as subset.bag.
    • rosbag play: to playback messages.
      • Format: rosbag play bag_file_name
      • Example: rosplay subset.bag

Tags:
0 comments