Ask Your Question
0

Mimic for turtlebots

asked 2016-07-06 00:50:09 -0500

David_Zizu gravatar image

I am trying to mimic the movement of the turtlebot. In order to test mimic, I am using turtlebot_gazebo. I am not able to compile my mimic.cpp file. I have the following error:

... /usr/include/boost/bind/mem_fn_template.hpp:184:7: note: candidate expects 2 arguments, 1 provided make[2]: * [turtlebot_move/CMakeFiles/mimic.dir/src/mimic.cpp.o] Error 1 make[1]: [turtlebot_move/CMakeFiles/mimic.dir/all] Error 2 make: ** [all] Error 2 Invoking "make -j8 -l8" failed

Here is the source code for my mimic file:

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include <iostream>

class Mimic {
public:
  Mimic();
private:
  void poseCallback(const nav_msgs::Odometry & odom);

  ros::Publisher vel_pub;
  ros::Subscriber pose_sub;
};

Mimic::Mimic() {
   ros::NodeHandle input_nh("input");
   ros::NodeHandle output_nh("output");
   vel_pub = output_nh.advertise<geometry_msgs::Twist>("turtlebot_2/cmd_vel_mux/input/teleop", 1);
   pose_sub = input_nh.subscribe<nav_msgs::Odometry>("turtlebot_1/odom", 1, &Mimic::poseCallback);
}

void Mimic::poseCallback(const nav_msgs::Odometry & odom) {
   geometry_msgs::Twist vel;
   vel.linear = odom.twist.twist.linear; 
   vel.angular = odom.twist.twist.angular;

   vel_pub.publish(vel);
 }

int main(int argc, char **argv) {

   ros::init(argc, argv, "mimic");
   Mimic mimic;

   ros::spin();
}

I am pretty sure that the problem is related to "nav_msgs::Odometry." I included all the necessary info to my CMakeLists.txt and package.xml files. Basically, I tried to subscribe to turtlebot_1/odom topic and then publish it on turtlebot_2/cmd_vel_mux/input/teleop topic. Could someone please tell me what am I doing wrong? Thanks in advance! :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-01-23 13:14:35 -0500

jtim gravatar image

Seems like your subscribers are missing an argument probably put this at the end.

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

Stats

Asked: 2016-07-06 00:50:09 -0500

Seen: 166 times

Last updated: Jan 23 '17