【ROS】创建工作空间及功能包

启动turtlesim小海龟仿真器:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
rqt_graph    //系统的可视化窗口

查看服务:

rosservice list
/clear
/haha/set_pen
/haha/teleport_absolute
/haha/teleport_relative
/kill         // 杀死一个小海龟
/reset
/rosout/get_loggers
/rosout/set_logger_level
/rostopic_4323_1613649732311/get_loggers
/rostopic_4323_1613649732311/set_logger_level
/rqt_gui_py_node_5110/get_loggers
/rqt_gui_py_node_5110/set_logger_level
/spawn         // 产生一个小海龟
/teleop_turtle/get_loggers
/teleop_turtle/set_logger_level
/turtle1/set_pen
/turtle1/teleport_absolute
/turtle1/teleport_relative
/turtlesim/get_loggers
/turtlesim/set_logger_level

调用spawn产生一个小海龟:

rosservice call /spawn "x: 2.0
y: 2.0
theta: 0.0
name: 'haha'" 

调用kill杀死一个小海龟:

rosservice call /kill "name: 'haha'" 

向话题发布任务:
海龟的名字叫做haha

rostopic pub -r 10 /haha/cmd_vel geometry_msgs/Twist "linear:
  x: 1.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 1.0"

话题记录:

-a:记录所有操作

-O:压缩文件

cmd_record:文件名称。默认在家目录下

rosbag record -a -O cmd_record

复现记录:

rosbag  play cmd_record.bag

创建工作空间

src: 存放源码的地方

build:编译空间

devel:开发空间

install :安装空间

创建工作空间及编译过程:
lyl@lin:~ $ mkdir
mkdir: 缺少操作数
Try 'mkdir --help' for more information.
lyl@lin:~ $ mkdir --help
用法:mkdir [选项]... 目录...
Create the DIRECTORY(ies), if they do not already exist.

必选参数对长短选项同时适用。
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed
  -v, --verbose     print a message for each created directory
  -Z                   set SELinux security context of each created directory
                         to the default type
      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux
                         or SMACK security context to CTX
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告mkdir 的翻译错误
Full documentation at: <http://www.gnu.org/software/coreutils/mkdir>
or available locally via: info '(coreutils) mkdir invocation'
lyl@lin:~ $ mkdir catkin_ws_1
lyl@lin:~ $ cd catkin_ws
lyl@lin:~/catkin_ws $ mkdir src
mkdir: 无法创建目录"src": 文件已存在
lyl@lin:~/catkin_ws $ cd catkin_ws_1
bash: cd: catkin_ws_1: 没有那个文件或目录
lyl@lin:~/catkin_ws $ cd
lyl@lin:~ $ cd catkin_ws_1
lyl@lin:~/catkin_ws_1 $ mkdir src
lyl@lin:~/catkin_ws_1 $ cd src
lyl@lin:~/catkin_ws_1/src $ catkin_init_workspace
Creating symlink "/home/lyl/catkin_ws_1/src/CMakeLists.txt" pointing to "/opt/ros/melodic/share/catkin/cmake/toplevel.cmake"
lyl@lin:~/catkin_ws_1/src $ cd ..
lyl@lin:~/catkin_ws_1 $ catkin_make
Base path: /home/lyl/catkin_ws_1
Source space: /home/lyl/catkin_ws_1/src
Build space: /home/lyl/catkin_ws_1/build
Devel space: /home/lyl/catkin_ws_1/devel
Install space: /home/lyl/catkin_ws_1/install
####
#### Running command: "cmake /home/lyl/catkin_ws_1/src -DCATKIN_DEVEL_PREFIX=/home/lyl/catkin_ws_1/devel -DCMAKE_INSTALL_PREFIX=/home/lyl/catkin_ws_1/install -G Unix Makefiles" in "/home/lyl/catkin_ws_1/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/lyl/catkin_ws_1/devel
-- Using CMAKE_PREFIX_PATH: /home/lyl/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/lyl/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/lyl/catkin_ws_1/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lyl/catkin_ws_1/build
####
#### Running command: "make -j8 -l8" in "/home/lyl/catkin_ws_1/build"
####
lyl@lin:~/catkin_ws_1 $ catkin_make install
Base path: /home/lyl/catkin_ws_1
Source space: /home/lyl/catkin_ws_1/src
Build space: /home/lyl/catkin_ws_1/build
Devel space: /home/lyl/catkin_ws_1/devel
Install space: /home/lyl/catkin_ws_1/install
####
#### Running command: "make cmake_check_build_system" in "/home/lyl/catkin_ws_1/build"
####
####
#### Running command: "make install -j8 -l8" in "/home/lyl/catkin_ws_1/build"
####
Install the project...
-- Install configuration: ""
-- Installing: /home/lyl/catkin_ws_1/install/_setup_util.py
-- Installing: /home/lyl/catkin_ws_1/install/env.sh
-- Installing: /home/lyl/catkin_ws_1/install/setup.bash
-- Installing: /home/lyl/catkin_ws_1/install/local_setup.bash
-- Installing: /home/lyl/catkin_ws_1/install/setup.sh
-- Installing: /home/lyl/catkin_ws_1/install/local_setup.sh
-- Installing: /home/lyl/catkin_ws_1/install/setup.zsh
-- Installing: /home/lyl/catkin_ws_1/install/local_setup.zsh
-- Installing: /home/lyl/catkin_ws_1/install/.rosinstall
lyl@lin:~/catkin_ws_1 $ 

创建功能包

格式:

catkin_creat_pkg  <package_name> [depend1] [depend2] [depend3]

实例:

catkin_create_pkg test_pkg roscpp rospy std_msgs
#返回到上一级目录,进行编译
catkin_make
#设置一下环境变量
source devel/setup.bash
#检查环境变量
echo $ROS_PACKAGE_PATH

std_msgs:消息的数据类型。

lyl@lin:~/catkin_ws_1 $ rosmsg list
actionlib/TestAction
actionlib/TestActionFeedback
actionlib/TestActionGoal
actionlib/TestActionResult
actionlib/TestFeedback
actionlib/TestGoal
actionlib/TestRequestAction
actionlib/TestRequestActionFeedback
actionlib/TestRequestActionGoal
actionlib/TestRequestActionResult
actionlib/TestRequestFeedback
actionlib/TestRequestGoal
actionlib/TestRequestResult
actionlib/TestResult
actionlib/TwoIntsAction
actionlib/TwoIntsActionFeedback
actionlib/TwoIntsActionGoal
actionlib/TwoIntsActionResult
actionlib/TwoIntsFeedback
actionlib/TwoIntsGoal
actionlib/TwoIntsResult
actionlib_msgs/GoalID
actionlib_msgs/GoalStatus
actionlib_msgs/GoalStatusArray
actionlib_tutorials/AveragingAction
actionlib_tutorials/AveragingActionFeedback
actionlib_tutorials/AveragingActionGoal
actionlib_tutorials/AveragingActionResult
actionlib_tutorials/AveragingFeedback
actionlib_tutorials/AveragingGoal
actionlib_tutorials/AveragingResult
actionlib_tutorials/FibonacciAction
actionlib_tutorials/FibonacciActionFeedback
actionlib_tutorials/FibonacciActionGoal
actionlib_tutorials/FibonacciActionResult
actionlib_tutorials/FibonacciFeedback
actionlib_tutorials/FibonacciGoal
actionlib_tutorials/FibonacciResult
bond/Constants
bond/Status
control_msgs/FollowJointTrajectoryAction
control_msgs/FollowJointTrajectoryActionFeedback
control_msgs/FollowJointTrajectoryActionGoal
control_msgs/FollowJointTrajectoryActionResult
control_msgs/FollowJointTrajectoryFeedback
control_msgs/FollowJointTrajectoryGoal
control_msgs/FollowJointTrajectoryResult
control_msgs/GripperCommand
control_msgs/GripperCommandAction
control_msgs/GripperCommandActionFeedback
control_msgs/GripperCommandActionGoal
control_msgs/GripperCommandActionResult
control_msgs/GripperCommandFeedback
control_msgs/GripperCommandGoal
control_msgs/GripperCommandResult
control_msgs/JointControllerState
control_msgs/JointJog
control_msgs/JointTolerance
control_msgs/JointTrajectoryAction
control_msgs/JointTrajectoryActionFeedback
control_msgs/JointTrajectoryActionGoal
control_msgs/JointTrajectoryActionResult
control_msgs/JointTrajectoryControllerState
control_msgs/JointTrajectoryFeedback
control_msgs/JointTrajectoryGoal
control_msgs/JointTrajectoryResult
control_msgs/PidState
control_msgs/PointHeadAction
control_msgs/PointHeadActionFeedback
control_msgs/PointHeadActionGoal
control_msgs/PointHeadActionResult
control_msgs/PointHeadFeedback
control_msgs/PointHeadGoal
control_msgs/PointHeadResult
control_msgs/SingleJointPositionAction
control_msgs/SingleJointPositionActionFeedback
control_msgs/SingleJointPositionActionGoal
control_msgs/SingleJointPositionActionResult
control_msgs/SingleJointPositionFeedback
control_msgs/SingleJointPositionGoal
control_msgs/SingleJointPositionResult
diagnostic_msgs/DiagnosticArray
diagnostic_msgs/DiagnosticStatus
diagnostic_msgs/KeyValue
dynamic_reconfigure/BoolParameter
dynamic_reconfigure/Config
dynamic_reconfigure/ConfigDescription
dynamic_reconfigure/DoubleParameter
dynamic_reconfigure/Group
dynamic_reconfigure/GroupState
dynamic_reconfigure/IntParameter
dynamic_reconfigure/ParamDescription
dynamic_reconfigure/SensorLevels
dynamic_reconfigure/StrParameter
gazebo_msgs/ContactState
gazebo_msgs/ContactsState
gazebo_msgs/LinkState
gazebo_msgs/LinkStates
gazebo_msgs/ModelState
gazebo_msgs/ModelStates
gazebo_msgs/ODEJointProperties
gazebo_msgs/ODEPhysics
gazebo_msgs/WorldState
geometry_msgs/Accel
geometry_msgs/AccelStamped
geometry_msgs/AccelWithCovariance
geometry_msgs/AccelWithCovarianceStamped
geometry_msgs/Inertia
geometry_msgs/InertiaStamped
geometry_msgs/Point
geometry_msgs/Point32
geometry_msgs/PointStamped
geometry_msgs/Polygon
geometry_msgs/PolygonStamped
geometry_msgs/Pose
geometry_msgs/Pose2D
geometry_msgs/PoseArray
geometry_msgs/PoseStamped
geometry_msgs/PoseWithCovariance
geometry_msgs/PoseWithCovarianceStamped
geometry_msgs/Quaternion
geometry_msgs/QuaternionStamped
geometry_msgs/Transform
geometry_msgs/TransformStamped
geometry_msgs/Twist
geometry_msgs/TwistStamped
geometry_msgs/TwistWithCovariance
geometry_msgs/TwistWithCovarianceStamped
geometry_msgs/Vector3
geometry_msgs/Vector3Stamped
geometry_msgs/Wrench
geometry_msgs/WrenchStamped
map_msgs/OccupancyGridUpdate
map_msgs/PointCloud2Update
map_msgs/ProjectedMap
map_msgs/ProjectedMapInfo
move_base_msgs/MoveBaseAction
move_base_msgs/MoveBaseActionFeedback
move_base_msgs/MoveBaseActionGoal
move_base_msgs/MoveBaseActionResult
move_base_msgs/MoveBaseFeedback
move_base_msgs/MoveBaseGoal
move_base_msgs/MoveBaseResult
move_base_msgs/RecoveryStatus
nav_msgs/GetMapAction
nav_msgs/GetMapActionFeedback
nav_msgs/GetMapActionGoal
nav_msgs/GetMapActionResult
nav_msgs/GetMapFeedback
nav_msgs/GetMapGoal
nav_msgs/GetMapResult
nav_msgs/GridCells
nav_msgs/MapMetaData
nav_msgs/OccupancyGrid
nav_msgs/Odometry
nav_msgs/Path
pcl_msgs/ModelCoefficients
pcl_msgs/PointIndices
pcl_msgs/PolygonMesh
pcl_msgs/Vertices
roscpp/Logger
rosgraph_msgs/Clock
rosgraph_msgs/Log
rosgraph_msgs/TopicStatistics
rospy_tutorials/Floats
rospy_tutorials/HeaderString
rosserial_msgs/Log
rosserial_msgs/TopicInfo
sensor_msgs/BatteryState
sensor_msgs/CameraInfo
sensor_msgs/ChannelFloat32
sensor_msgs/CompressedImage
sensor_msgs/FluidPressure
sensor_msgs/Illuminance
sensor_msgs/Image
sensor_msgs/Imu
sensor_msgs/JointState
sensor_msgs/Joy
sensor_msgs/JoyFeedback
sensor_msgs/JoyFeedbackArray
sensor_msgs/LaserEcho
sensor_msgs/LaserScan
sensor_msgs/MagneticField
sensor_msgs/MultiDOFJointState
sensor_msgs/MultiEchoLaserScan
sensor_msgs/NavSatFix
sensor_msgs/NavSatStatus
sensor_msgs/PointCloud
sensor_msgs/PointCloud2
sensor_msgs/PointField
sensor_msgs/Range
sensor_msgs/RegionOfInterest
sensor_msgs/RelativeHumidity
sensor_msgs/Temperature
sensor_msgs/TimeReference
shape_msgs/Mesh
shape_msgs/MeshTriangle
shape_msgs/Plane
shape_msgs/SolidPrimitive
smach_msgs/SmachContainerInitialStatusCmd
smach_msgs/SmachContainerStatus
smach_msgs/SmachContainerStructure
std_msgs/Bool
std_msgs/Byte
std_msgs/ByteMultiArray
std_msgs/Char
std_msgs/ColorRGBA
std_msgs/Duration
std_msgs/Empty
std_msgs/Float32
std_msgs/Float32MultiArray
std_msgs/Float64
std_msgs/Float64MultiArray
std_msgs/Header
std_msgs/Int16
std_msgs/Int16MultiArray
std_msgs/Int32
std_msgs/Int32MultiArray
std_msgs/Int64
std_msgs/Int64MultiArray
std_msgs/Int8
std_msgs/Int8MultiArray
std_msgs/MultiArrayDimension
std_msgs/MultiArrayLayout
std_msgs/String
std_msgs/Time
std_msgs/UInt16
std_msgs/UInt16MultiArray
std_msgs/UInt32
std_msgs/UInt32MultiArray
std_msgs/UInt64
std_msgs/UInt64MultiArray
std_msgs/UInt8
std_msgs/UInt8MultiArray
stereo_msgs/DisparityImage
tf/tfMessage
tf2_msgs/LookupTransformAction
tf2_msgs/LookupTransformActionFeedback
tf2_msgs/LookupTransformActionGoal
tf2_msgs/LookupTransformActionResult
tf2_msgs/LookupTransformFeedback
tf2_msgs/LookupTransformGoal
tf2_msgs/LookupTransformResult
tf2_msgs/TF2Error
tf2_msgs/TFMessage
trajectory_msgs/JointTrajectory
trajectory_msgs/JointTrajectoryPoint
trajectory_msgs/MultiDOFJointTrajectory
trajectory_msgs/MultiDOFJointTrajectoryPoint
turtle_actionlib/ShapeAction
turtle_actionlib/ShapeActionFeedback
turtle_actionlib/ShapeActionGoal
turtle_actionlib/ShapeActionResult
turtle_actionlib/ShapeFeedback
turtle_actionlib/ShapeGoal
turtle_actionlib/ShapeResult
turtle_actionlib/Velocity
turtlebot3_example/Turtlebot3Action
turtlebot3_example/Turtlebot3ActionFeedback
turtlebot3_example/Turtlebot3ActionGoal
turtlebot3_example/Turtlebot3ActionResult
turtlebot3_example/Turtlebot3Feedback
turtlebot3_example/Turtlebot3Goal
turtlebot3_example/Turtlebot3Result
turtlebot3_msgs/SensorState
turtlebot3_msgs/Sound
turtlebot3_msgs/VersionInfo
turtlesim/Color
turtlesim/Pose
visualization_msgs/ImageMarker
visualization_msgs/InteractiveMarker
visualization_msgs/InteractiveMarkerControl
visualization_msgs/InteractiveMarkerFeedback
visualization_msgs/InteractiveMarkerInit
visualization_msgs/InteractiveMarkerPose
visualization_msgs/InteractiveMarkerUpdate
visualization_msgs/Marker
visualization_msgs/MarkerArray
visualization_msgs/MenuEntry

从上面的内容中可以看到含有布尔型等,详情参见:https://blog.csdn.net/qq_36355662/article/details/62226935

注意:同一个工作空间下不允许存在同名功能包,不同工作空间下允许存在同名功能包。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值