To view the configuration of environment variables:
[Email protected]:~$ Export | grep ROS
Declare-x roslisp_package_directories= ""
Declare-x ros_distro= "Kinetic"
Declare-x ros_etc_dir= "/opt/ros/kinetic/etc/ros"
Declare-x ros_master_uri= "http://localhost:11311"
Declare-x ros_package_path= "/opt/ros/kinetic/share"
Declare-x ros_root= "/opt/ros/kinetic/share/ros"
After apt installs, configure the command:
[Email protected]:~$ Source/opt/ros/kinetic/setup.bash
To create a Catkin workspace:
$ mkdir-p ~/CATKIN_WS/SRC
$ CD ~/CATKIN_WS/SRC
Compile all the files in the workspace:
$ CD ~/catkin_ws/
$ catkin_make
Build, devel, add src, total three folders.
Set the current workspace at the top of the ROS working environment:
[Email protected]:~/catkin_ws$ Source Devel/setup.bash
See if the environment variable Ros_package_path contains our workspace directory:
[Email protected]:~/catkin_ws$ echo $ROS _package_path
/home/wangsan/catkin_ws/src:/opt/ros/kinetic/share
OK, the above let our work environment to build complete.
Ros-tutorials packages required in the installation tutorial:
$ sudo apt-get install ros-kinetic-ros-tutorials
To obtain the path information for the package:
[Email protected]:~/catkin_ws$ rospack Find Roscpp
/opt/ros/kinetic/share/roscpp
Switch directly to the path of the package:
[Email protected]:~/catkin_ws$ roscd roscpp
[Email protected]:/opt/ros/kinetic/share/roscpp$ pwd
/opt/ros/kinetic/share/roscpp
ROSCD can only switch to the path of the Ros package contained in the environment variable Ros_package_path:
[Email protected]:/opt/ros/kinetic/share/roscpp$ echo $ROS _package_path
/home/wangsan/catkin_ws/src:/opt/ros/kinetic/share
Separated by a colon between different paths.
Switch directly into the package subdirectory:
[Email protected]:~$ roscd Roscpp/cmake
[Email protected]:/opt/ros/kinetic/share/roscpp/cmake$ pwd
/opt/ros/kinetic/share/roscpp/cmake
Switch to the Ros save journal file directory, but did not perform any Ros program, the system error said that the directory does not exist:
[Email protected]:/opt/ros/kinetic/share/roscpp/cmake$ roscd Log
No Active Roscore
List directories by package name, rather than by absolute path:
[Email protected]:~$ Rosls roscpp_tutorials
CMake launch Package.xml SRV
tab Auto-Complete input:
[Email protected]:~$ roscd roscpp_tut<<< now press TAB >>>
Create a Catkin package beginner_tutorials in the Catkin workspace that depends on the package std_msgs Rospy roscpp:
[Email protected]:~/catkin_ws/src$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
To view the first-level dependencies of the Beginner_tutorials package:
[Email protected]:~/catkin_ws/src$ rospack depends1 beginner_tutorials
Roscpp
Rospy
Std_msgs
You can also go to the package path to view Package.xml
$ ROSCD Beginner_tutorials
$ cat Package.xml
<package> ... <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend> ... </package>
Recursive detection of all dependent packages:
[Email protected]:~/catkin_ws/src$ Rospack depends beginner_tutorialscpp_commonrostimeroscpp_traitsroscpp_ Serializationcatkingenmsggenpymessage_runtimegencppgeneusgennodejsgenlispmessage_ Generationrosbuildrosconsolestd_msgsrosgraph_msgsxmlrpcpproscpprosgraphrospackroslibrospy
# # # Custom package.xml, including
- Description Label
- Maintainer label
- License label
- Dependency labels
[Email protected]:~/catkin_ws/src/beginner_tutorials$Catpackage.xml<?xml version="1.0"?><package> <name>beginner_tutorials</name> <version>0.1.0</version> <description>the beginner_tutorials package</description> <maintainer email="[email protected]">wangsan</maintainer> <license>TODO</license> <!--<url type="website">http://wiki.ros.org/beginner_tutorials</url> --<!--<author email="[email protected]">wangsan</author> <buildtool_depend>catkin</buildtool_depend> <build_depend> Roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</ build_depend> <run_depend>roscpp</run_depend> <run_depend>rospy</run_depend> <run_ Depend>std_msgs</run_depend></package>
To compile our package:
[Email protected]:~/catkin_ws$ catkin_make
Open the Ros Core service and run the first command before running all ROS programs:
$ roscore
List the nodes that are running:
$ Rosnode List
Returns information for a specific node (Rosout is used to collect and record node debug output information):
Info /rosout
Run a node within the package without needing to know the absolute path:
$ rosrun Turtlesim Turtlesim_node
appear to have been Xiao Wang eight, turn off, and then restart, will appear another small Wang eight ...
Change node Name:
$ rosrun Turtlesim Turtlesim_node __name:=my_turtle
Test node:
Ping My_turtle
Keyboard to control the movement of the turtle, run another node in the Turtlesim:
$ rosrun Turtlesim Turtle_teleop_key
Rqt_graph is able to create a dynamic graph that displays the current system health, first installing the RPT package:
sudo Install ros-kinetic-sudoinstall ros-kinetic-rqt-common-plugins
To open a dynamic graph of the current system health:
$ rosrun rqt_graph rqt_graph
Use the Help options to view Rostopic subcommands:
$ rostopic-h
Show the data published on a topic:
Echo /turtle1/cmd_vel
To view the parameters required by the LIST subcommand:
$ rostopic List-h
Displays detailed information about the topics and their types of publications and subscriptions:
$ rostopic List-v
To view the message type of the topic you are publishing:
$ rostopic Type/turtle1/cmd_vel
Geometry_msgs/twist
To see the details of the message:
$ rosmsg Show Geometry_msgs/twist
If you know the data type, you can also publish the data to the current broadcast topic, let Xiao Wang eight press the command to move:
$ rostopic Pub-1'[2.0, 0.0, 0.0]'[0.0, 0.0, 1.8]'
-1: Exit immediately after publishing the message
/turtle1/cmd_vel: Topic name
Geometry_msgs/twist: Message Type
--: Tell the parser that it is not the parameter option of the command later
Let Xiao Wang eight always swim, swim, swim:
1 ' [2.0, 0.0, 0.0] ' ' [0.0, 0.0, 1.8] '
To see how often data is published:
$ rostopic Hz/turtle1/pose
Draw a graph of data changes on a topic:
$ rosrun Rqt_plot Rqt_plot
ROS Beginner Tutorial Command Summary