rosrun 使用
rosrun [功能包名称] [节点名称]
eg.
rosrun turtlesim turtlesim_node
我的一个错误行为:
rosrun cpoint filter_test.cpp
我让rosrun运行了cpp文件
于是奇怪的事情发生了
我如此运行,catkin_make编译成功了,但是再执行以上命令,会检查到注释错误,莫名的语法错误,会很奇怪,最后发现是rosrun应该运行的是节点,而不是cpp文件。
报错如下:
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 1: /bin: Is a directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 2: 关于使用sensor_msgs/PointCloud2,: No such file or directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 3: build/: Is a directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 6: //: Is a directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 11: //滤波的头文件: No such file or directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 13: //申明发布器: No such file or directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 14: ros::Publisher: command not found
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 15: //回调函数: No such file or directory
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 16: void: command not found
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 17: syntax error near unexpected token `const'
/home/twilight/project/catkin_ws/src/cpoint/src/filter_test.cpp: line 17: `cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) //特别注意的是这里面形参的数据格式'
我的cmakelist
cmake_minimum_required(VERSION 3.0.2)
project(cpoint)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
sensor_msgs
std_msgs
cv_bridge
image_transport
pcl_conversions
pcl_ros
)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
################################################
## Declare ROS messages, services and actions ##
################################################
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
###################################
## catkin specific configuration ##
###################################
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES test_pkg
# CATKIN_DEPENDS roscpp rospy sensor_msgs std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
include_directories(
${PCL_INCLUDE_DIRS}
)
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
## add_executable(cpoint src/PointCloud2_to_pcl_node.cpp src/filter_test.cpp)
add_executable(cpoint src/filter_test.cpp)
target_link_libraries(cpoint ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
target_link_libraries(cpoint ${catkin_LIBRARIES})
给自己气笑了