==================== Commandline Commands ==================== .. contents:: :local: Commandline Variables ===================== .. code-block:: bash echo $ # To display value ROS_DISTRO # Distro name e.g. melodic ROS_ETC_DIR # ROS_LISP_PACKAGE_DIRECTORIES # common-lisp folder e.g. ~/catkin_ws/devel/share/common-lisp ROS_HOSTNAME # ros hostname e.g. localhost ROS_MASTER_URI # ros master url e.g. http://localhost:11311 ROS_PACKAGE_PATH # package path's e.g. ~/catkin_ws/src:/opt/ros/$(ROS_DISTRO)/share ROS_PYTHON_VERSION # python version 2 or 3 e.g. 2 ROS_ROOT # ros installation e.g. /opt/ros/$(ROS_DISTRO)/share/ros ROS_VERSION # ros version 1 or 2 e.g. 1 Useful commands =============== ROS tools ------------- ``roscore`` ^^^^^^^^^^^^ Launch ROS ``master`` core .. code-block:: bash roscore ``rosversion`` ^^^^^^^^^^^^^^ .. code-block:: bash rosversion -d # Print ROS distro name rosversion # Print package vrosnode ``rosparam`` ^^^^^^^^^^^^ Nodes use the parameter server to store and retrieve parameters at runtime. http://wiki.ros.org/rosparam .. code-block:: bash rosparam list # list parameter names rosparam set / # set parameter rosparam get / # get parameter rosparam delete / # delete parameter rosparam dump # dump parameter to file rosparam load # load parameter from file ``rosnode`` ^^^^^^^^^^^^ Work with ``nodes`` .. code-block:: bash rosnode list # list all nodes rosnode ping / # check node connectivity rosnode info / # print information about node rosnode machine # list nodes running on a particular machine rosnode kill / # kill a running node ``rostopic`` ^^^^^^^^^^^^ Work with ``topics`` .. code-block:: bash rostopic list # list all topics rostopic info / # print information about active topic rostopic echo / # print messages to screen rostopic pub / msg/MessageType "data:value" # pubish data to topic rostopic type / # print topic or field type rostopic find # find topics by type rostopic bw / # display bandwidth used by topic rostopic hz / # display publishing rate of topic ``roslaunch`` ^^^^^^^^^^^^^^ To start a launch file which can contain multiple ``nodes``. .. code-block:: bash roslaunch # Launch ros launch file ``rosrun`` ^^^^^^^^^^ To run a ``node`` .. code-block:: bash rosrun # Start a ros node rosrun __name:= # Start another instance of a node, the parameter *INSTANCE_NAME* can be whatever you want, but it must be unique. ``rosservice`` ^^^^^^^^^^^^^^^^ Work with ``services`` .. code-block:: bash rosservice list # list active services rosservice info # print information about service rosservice uri # print service ROSRPC ``rosbag`` ^^^^^^^^^^ ROS offers the possibility to record the data published on topics into ``bag`` files : #. create a directory to store the bag files: .. code-block:: bash ~/ mkdir ros_bag_files && cd ros_bag_files #. run the *record* command : .. code-block:: bash rosbag record -O .bag #. play the bag file : .. code-block:: bash rosbag play .bag #. Compress a bag file : .. code-block:: bash # Option 1 : use BZ2 compression -> slow but bigger compression rate rosbag compress .bag # Option 2 : use LZ4 compression -> much faster, but smaller compression rate rosbag compress --lz4 .bag #. Decompress a compressed bag file : .. code-block:: bash rosbag decompress .bag #. Repair a broken bag file (happens when there is a *.bag.active* file instead of a *.bag* file): .. code-block:: bash rosbag reindex .bag.active rosbag fix .bag.active .bag #. Shorten a bag file : .. code-block:: bash rosbag filter .bag .bag "t.secs >= " Many options are available for the *rosbag* command, see `this page `_ for more details. .. note:: To play a bag with several pointclouds at different position, it is better to have the following topics recorded: * ``/cloud`` * ``/tf_static`` The `/tf_static` is helpful to visualize in RViz .. code-block:: bash rosbag record -O cloud.bag /cloud /tf_static ``rosmsg`` ^^^^^^^^^^ Display information about ros ``messages``. .. code-block:: bash rosmsg list # List all messages rosmsg info # Show message description rosmsg package # List messages in a package rosmsg packages # List packages that contain messages Other Commands ^^^^^^^^^^^^^^ .. code-block:: bash roscd # move to the folder of the package rosinstall # install a ROS package rosdep `` #. update both CMakeLists.txt and package.xml note : *run_depend* has to be replaced by the *exec_depend* #. write source code in the source folder of the package : #. build the catkin workspace with the alias command : ``cm`` #. launch the master as explained [here](ros-commands.md#roscore). #. now launch the node as explained [here](#roslaunch) and [here](rosrun). .. code-block:: bash catkin_create_pkg # create a package, must be called inside a catkin workspace Build ^^^^^^ .. code-block:: bash cm catkin_make # build the whole workspace catkin_make # build a single package Install ^^^^^^^^ .. code-block:: bash catkin_make install # installs all executables catkin_make install # installs single executables Python modules ^^^^^^^^^^^^^^ Tips : * put the script in a folder called *scripts* * make sure to run ``chmod +x .py`` so that the script is recognized as an executable by ROS Update services with RQT ========================= #. launch *RQT* from a new terminal : run ``rqt`` #. Search for the plugin *Service Caller* #. Choose the service that you want to update #. Fill the *expression* field with an expected parameter of this service #. Call the service and the response is displayed :tag:`ROS`