0
$\begingroup$

Rosanswers logo

I'm totally a beginner in ROS & Robotics .. I have installed ROS Hydro and set up my workspace + sandbox.

then i started to create enclosure_escape package with 3 dependencies

$ roscd
$ cd sandbox 
$ roscreate-pkg enclosure_escape roscpp kobuki_msgs geometry_msgs

now I have to create my c++ code in src folder .. lets say enclosure_escape.cpp which contains the following code ..

//include libraries
#include <kobuki_msgs/BumperEvent.h>
#include <geometry_msgs/Twist.h>
#include <ros/ros.h>

//define the bumperCallback function
void bumperCallback(const kobuki_msgs::BumperEvent bumperMessage)
{
  ROS_INFO("bumper hit. value = [%d]", bumperMessage.bumper);
}

//ROS node entry point
int main(int argc, char **argv)
{

  ros::init(argc, argv, "turtlebot_test_node");
  ros::NodeHandle n;

  ros::Subscriber bumperSubscriber = n.subscribe("/mobile_base/events/bumper", 100, bumperCallback);

  ros::Publisher velocityPublisher = n.advertise<geometry_msgs::Twist>("cmd_vel_mux/input/teleop", 1);

  //create a Twist message to publish the velocity
     geometry_msgs::Twist velMessage;
     velMessage.linear.x = 1.0;
     velMessage.angular.z = 0.0;

  //publish the message
  velocityPublisher.publish(velMessage);

  ros::spin();

  return 0;
}

now the Question comes .. how to run this on turtlebot simulator?


Originally posted by adelali on ROS Answers with karma: 1 on 2013-10-25

Post score: 0


Original comments

Comment by choog on 2014-06-06:
on your ros::Publisher velocityPublisher = n.advertise<geometry_msgs::Twist>("cmd_vel_mux/input/teleop", 1); line why do you specify ("cmd_vel_mux/input/teleop", 1) in your code? what is this doing?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

To run this with a TurtleBot in simulation you just have to run it on the same network with the same ROS Master and it will communicate over ROS.


Originally posted by tfoote with karma: 58457 on 2014-03-26

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.