Ask Your Question
0

move forward turtlebot2 in the real world

asked 2014-11-04 03:27:54 -0500

ros_master gravatar image

updated 2014-11-04 03:33:35 -0500

Hi guys. I want to move the turtlebot. I am using Hydro and KobukiBase. Firstly i created package inside my catkin_ws:

$ catkin_create_pkg forward std_msgs rospy roscpp actionlib tf geometry_msgs move_base_msgs .

Then i edit CMakeList:

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

Thirdly, i run these commads:

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);

}

errors:

[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

I think this code is correct and executable but rosrun command is wrong. I don't fix this. What do you think about these errors?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-11-04 03:52:52 -0500

lebowski gravatar image

you try to compile your node before ros knows about your workspace.

so

  1. "source ./devel/setup.bash" or even better, source the setup.bash in your .bashrc
  2. do catkin_make in your workspace
  3. if you got no errors, rosrun your node with

    rosrun forward gg

IMPORTANT: you CANT rosrun a cpp file and never change ROS_PACKAGE_PATH by hand! always source the setup.bash

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-04 03:27:54 -0500

Seen: 98 times

Last updated: Nov 04 '14