ROS installation instructions
我安装 版本的是
ROS Melodic Morenia
Released May, 2018
LTS, supported until May, 2023
Recommended for Ubuntu 18.04
source /opt/ros//setup.bash
source /opt/ros/melodic/setup.bash
设置每次打开终端,自动source设置文件
echo “source /opt/ros/melodic/setup.bash” >> ~/.bashrc
source ~/.bashrc
printenv | grep ROS
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=melodic
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ catkin_make
build
devel. Inside the ‘devel’ folder you can see that there are now several setup.*sh files. Sourcing any of these files will overlay this workspace on top of your environment.
src : 里面有CmakeLists.txt
source devel/setup.bash echo $ROS_PACKAGE_PATH /home/lsy/catkin_ws/src:/opt/ros/melodic/share
Packages: Packages are the software organization unit of ROS code. Each package can contain libraries, executables, scripts, or other artifacts.
Manifests (package.xml): A manifest is a description of a package. It serves to define dependencies between packages and to capture meta information about the package like version, maintainer, license, etc…
rospack find [package_name]
roscd <package-or-stack>[/subdir]
rosls <package-or-stack>[/subdir]
cd ~/catkin_ws/src catkin_create_pkg <package_name> [depend1] [depend2] [depend3] catkin_create_pkg beginner_tutorials std_msgs rospy roscpp cd ~/catkin_ws catkin_make
rospack depends1 beginner_tutorials rospack depends beginner_tutorials
$ catkin_make $ catkin_make install # (optionally) $ catkin_make --source my_src $ catkin_make install --source my_src # (optionally)
The above commands will build any catkin projects found in the src folder.
客户端库:
rospy = python client library
roscpp = c++ client library
roscore = ros+core : master (provides name service for ROS) + rosout (stdout/stderr) + parameter server (parameter server will be introduced later)
rosnode = ros+node : ROS tool to get information about a node.
rosrun = ros+run : runs a node from a given package.
rosrun [--prefix cmd] [--debug] PACKAGE EXECUTABLE [ARGS] rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key
rqt_graph
rosrun rqt_graph rqt_graph
rostopic
lsy@lsy-GS65-Stealth-9SD:~/catkin_ws/src$ rostopic rostopic is a command-line tool for printing information about ROS Topics. Commands: rostopic bw display bandwidth used by topic rostopic delay display delay of topic from timestamp in header rostopic echo print messages to screen rostopic find find topics by type rostopic hz display publishing rate of topic rostopic info print information about active topic rostopic list list active topics rostopic pub publish data to topic rostopic type print topic or field type
rosmsg
lsy@lsy-GS65-Stealth-9SD:~/catkin_ws/src$ rostopic type /turtle1/cmd_vel geometry_msgs/Twist lsy@lsy-GS65-Stealth-9SD:~/catkin_ws/src$ rosmsg show geometry_msgs/Twist geometry_msgs/Vector3 linear float64 x float64 y float64 z geometry_msgs/Vector3 angular float64 x float64 y float64 z
rostopic pub [topic] [msg_type] [args] rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
节点可以通过服务来通信。Services allow nodes to send a request and receive a response.
rosservice
rosservice list print information about active services rosservice call call the service with the provided args rosservice type print service type rosservice find find services by service type rosservice uri print service ROSRPC uri rosservice type [service] rosservice call [service] [args]
rosparam
rosparam set set parameter rosparam get get parameter rosparam load load parameters from file rosparam dump dump parameters to file rosparam delete delete parameter rosparam list list parameter names
using rqt_console and rqt_logger_level for debugging and roslaunch for starting many nodes at once.
roslaunch
roslaunch beginner_tutorials turtlemimic.launch lsy@lsy-GS65-Stealth-9SD:~/catkin_ws/src/beginner_tutorials$ rosrun turtlesim draw_square mimic turtlesim_node turtle_teleop_key
一次性启动多个节点
<launch> <group ns="turtlesim1"> <node pkg="turtlesim" name="sim" type="turtlesim_node"/> </group> <group ns="turtlesim2"> <node pkg="turtlesim" name="sim" type="turtlesim_node"/> </group> <node pkg="turtlesim" name="mimic" type="mimic"> <remap from="input" to="turtlesim1/turtle1"/> <remap from="output" to="turtlesim2/turtle1"/> </node> </launch>
不用输入完整目录
rosed [package_name] [filename]
msg
: msg files are simple text files that describe the fields of a ROS message. They are used to generate source code for messages in different languages.每行一个类型
Header header string child_frame_id geometry_msgs/PoseWithCovariance pose geometry_msgs/TwistWithCovariance twist
srv
: an srv file describes a service. It is composed of two parts: a request and a response.int64 A int64 B --- int64 Sum
既使简单的功能,生成的文件页特别复杂
固定流程。
CmakLists.txt
还行吧。约束很多
rosbag record -a rosbag info 2022-03-20-19-10-22.bag rosbag play 2022-03-20-19-10-22.bag rosbag play -r 2 2022-03-20-19-10-22.bag
rostopic
ros_readbagfile
:更快