Mimic for turtlebots
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! :)