2013-11-21 46 views
0

我是一名ROS.My的初学者,我的操作系统是Ubuntu 12.04,我的ROS是hydro.After我读了一些关于ROS.wiki中的初学者教程的“讲者和听者”的章节,我尝试写一个发布者发布消息主题“turtle1/com_vel”这样我可以控制乌龟跑round.But时,我尽量让我的代码,它fails.The终端提醒我,在ROS中如何发布我自己的话题?

CMake Error at /opt/ros/hydro/share/catkin/cmake/catkinConfig.cmake:72 (find_package): 
    Could not find a configuration file for package ros. 

    Set ros_DIR to the directory containing a CMake configuration file for ros. 
    The file will have one of the following names: 

    rosConfig.cmake 
    ros-config.cmake 

我想这有什么不对与我的CMakeLists.txt.But比较它与ROS.wiki中的演示后,我仍然无法找到错误。 这是我在cpp文件中的代码。在这个文件中,我定义了一个名为move_turtle的发布者。

#include "ros/ros.h" 
#include "geometry_msgs/Twist.h" 

int main(int argc, char** argv) 
{ 
    // initialization 
    ros::init(argc, argv, "move_turtle"); 
    ros::NodeHandle n; 
    ros::Publisher move_pub = n.advertise<geometry_msgs::Twist>("turtle1/com_vel",100); 
    ros::Rate loop_rate(10); 
    //define the moving rule that I want.It is a circle. 
    geometry_msgs::Twist com_cicle; 
    com_cicle.linear.x=3.0; 
    com_cicle.linear.y=com_cicle.linear.z=0.0; 
    com_cicle.angular.x=com_cicle.angular.y=0.0; 
    com_cicle.angular.z=2.0; 
    while(ros::ok()) 
    { 
    //publish the msg to topic /tuttle1/com_vel 
    move_pub.pulish(com_cicle); 
    ros::spinOnce(); 
    loop_rate.sleep(); 
    } 
    return 0; 
} 

而我的CMakeLists.txt如下:

cmake_minimum_required(VERSION 2.8.3) 
project(move_turtle) 

find_package(catkin REQUIRED COMPONENTS 
    ros 
    geometry_msgs 
    turtlesim 
) 

catkin_package() 
include_directories(
    ${catkin_INCLUDE_DIRS} 
) 

## Declare a cpp executable 
    add_executable(move_turtle src/move_turtle.cpp) 

## Specify libraries to link a library or executable target against 
    target_link_libraries(move_turtle ${catkin_LIBRARIES}) 

回答

0

哦......我在第5行中使用的 '活性氧' 代替“roscpp“CMakeLists.txt'.That就是为什么它提醒我,我的道路上没有'ros'套餐。

相关问题