高脚猫2号kobuki基地向前移动

turtlebot 2 kobuki base move forward

本文关键字:移动 2号 kobuki 高脚猫      更新时间:2023-10-16

我想移动turtlebot.包名为"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