簡體   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