我想移动turtlebot.package名称是“转发”首先我在我的catkin_ws中创建了包
$ catkin_create_pkg forward std_msgs rospy roscpp actionlib tf geometry_msgs move_base_msgs
然后我编辑CMakeList
add_executable(gg src/g.cpp) and target_link_libraries(gg, ${catkin_LIBRARIES})
第三,我运行这些命令:
catkin_make
roscore
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:'pwd'
source ./devel/setup.bash
rosrun forward gg.cpp
gg.cpp:
#include <ros/ros.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <geometry_msgs/Twist.h>
#include <tf/transform_datatypes.h>
#include <stdio.h>
#include <math.h>
#include <tf/transform_listener.h>
#include <algorithm>
#include <geometry_msgs/PointStamped.h>
#include <std_msgs/Header.h>
#include <iostream>
int main(){
geometry_msgs::PointStamped p;
geometry_msgs::PointStamped p1;
p.header.stamp = ros::Time();
std::string frame1 = "/camera_depth_optical_frame";
p.header.frame_id = frame1.c_str();
p.point.x = 0;
p.point.y = 0;
p.point.z = 1; // 1 meter
// std::string frame = "map";
/*try
{
listener.transformPoint(frame,p,p1);
}catch(tf::TransformException& ex) { ROS_ERROR("exception while transforming..."); }
*/
// create message for move_base_simple/goal
geometry_msgs::PoseStamped msg;
msg.header.stamp = ros::Time();
std::string frame = "/map";
msg.header.frame_id = frame.c_str();
msg.pose.position = p1.point;
msg.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
//publisher.publish(msg);
}
错误:
[rosrun] Couldn't find executable named gg.cpp below /home/turtlebot/catkin_ws/src/forward
[rosrun] Found the following, but they're either not files,
[rosrun] or not executable:
[rosrun] /home/turtlebot/catkin_ws/src/forward/src/gg.cpp
您如何看待这些错误?
答案 0 :(得分:0)
您可执行文件gg
:
add_executable(gg src/g.cpp) and target_link_libraries(gg, ${catkin_LIBRARIES})
但尝试运行目标gg.cpp
rosrun forward gg.cpp
尝试
rosrun forward gg