繁体   English   中英

turtlebot 2 kobuki基地前进

[英]turtlebot 2 kobuki base move forward

我想移动turtlebot.package的名称为“ forward”首先,我在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

您如何看待这些错误?

您将可执行文件命名为gg

add_executable(gg src/g.cpp) and target_link_libraries(gg, ${catkin_LIBRARIES})

但是尝试运行目标gg.cpp

rosrun forward gg.cpp

尝试

rosrun forward gg

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM