调用“make --pkg chapter2_tutorials -j1 -l1”失败

时间:2017-02-19 16:23:06

标签: ros catkin

example1_a.cpp

include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
int main(int argc, char **argv)
{
  ros::init(argc, argv, "example1_a");
  ros::NodeHandle n;
  ros::Publisher pub = n.advertise<std_msgs::String>("message", 1000);
  ros::Rate loop_rate(10);
  while (ros::ok())
  {
    std_msgs::String msg;
    std::stringstream ss;
    ss << " I am the example1_a node ";
    msg.data = ss.str();
    //ROS_INFO("%s", msg.data.c_str());
    pub.publish(msg);
    ros::spinOnce();
    loop_rate.sleep();
  }
  return 0;
}

example1_b.cpp

#include "ros/ros.h"
#include "std_msgs/String.h"

void messageCallback(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO("I heard: [%s]", msg->data.c_str());
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "example1_b");
  ros::NodeHandle n;
  ros::Subscriber sub = n.subscribe("message", 1000, messageCallback);
  ros::spin();
  return 0;
}

catkin_make –-pkg chapter2_tutorials

时出错
#### Running command: "make cmake_check_build_system" in "/home/ros/catkin_ws/build"
####
####
#### Running command: "make –-pkg chapter2_tutorials -j1 -l1" in "/home/ros/catkin_ws/build"
####
make: *** No rule to make target '–-pkg'.  Stop.
Invoking "make –-pkg chapter2_tutorials -j1 -l1" failed

$ export | grep ROS

ros@ubuntu:~/catkin_ws$ export | grep ROS
declare -x ROSLISP_PACKAGE_DIRECTORIES="/home/ros/catkin_ws/devel/share/common-lisp"
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="/home/ros/catkin_ws/src:/opt/ros/kinetic/share"
declare -x ROS_ROOT="/opt/ros/kinetic/share/ros"

谢谢!

2 个答案:

答案 0 :(得分:0)

你看过ROS.org教程了吗?他们是一个很好的资源。 http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment

您应该通过删除--pkg标记来获得所需的结果。尝试运行catkin_make chapter2_tutorials

答案 1 :(得分:0)

只需运行catkin_make而不是make

$ catkin_make –-pkg chapter2_tutorials -j1 -l1