Rosserial Error: No matching function for call to

asked 2018-07-24 18:04:08 -0600

huang27c gravatar image

updated 2018-07-24 19:09:40 -0600

I'm trying to load Odom example from ros_lib on my robot.

I Replaced

ros::NodeHandle  nh;

to

ros::NodeHandle_<ArduinoHardware, 6, 6, 150, 150>  nh;

But then it shows the error: No matching function for call to on

broadcaster.init(nh);

in setup().

Can anyone please give me some suggestions?

Update:

This is the complete code:

#include <ros.h>
#include <ros/time.h>
#include <tf/tf.h>
#include <tf/transform_broadcaster.h>

ros::NodeHandle_<ArduinoHardware, 6, 6, 150, 150>  nh;

geometry_msgs::TransformStamped t; tf::TransformBroadcaster broadcaster;

double x = 1.0; double y = 0.0; double theta = 1.57;

char base_link[] = "/base_link"; 
char odom[] = "/odom";

void setup()
{
  nh.initNode();
  broadcaster.init(nh);
}

void loop()
{  
  // drive in a circle
  double dx = 0.2;
  double dtheta = 0.18;
  x += cos(theta)*dx*0.1;
  y += sin(theta)*dx*0.1;
  theta += dtheta*0.1;
  if(theta > 3.14)
    theta=-3.14;

  // tf odom->base_link
  t.header.frame_id = odom;
  t.child_frame_id = base_link;

  t.transform.translation.x = x;
  t.transform.translation.y = y;

  t.transform.rotation = tf::createQuaternionFromYaw(theta);
  t.header.stamp = nh.now();

  broadcaster.sendTransform(t);
  nh.spinOnce();

  delay(10);
}

The error message I received:

/tmp/arduino_modified_sketch_779304/Odom.ino: In function 'void setup()':
Odom:25: error: no matching function for call to 'tf::TransformBroadcaster::init(ros::NodeHandle_<ArduinoHardware, 6, 6, 150, 150>&)'
   broadcaster.init(nh);
                  ^
edit retag flag offensive close merge delete

Comments

Can you please update your question with a link to the tutorial/example that you're referring to and a copy/paste of the complete error?

jayess gravatar image jayess  ( 2018-07-24 18:53:31 -0600 )edit

Is there a reason why you're using

ros::NodeHandle_<ArduinoHardware, 6, 6, 150, 150>  nh

vs

ros::NodeHandle  nh

? I've rosserial a few times and never had to do that.

jayess gravatar image jayess  ( 2018-07-24 19:35:34 -0600 )edit

I need ros::NodeHandle_<ArduinoHardware, 6, 6, 150, 150> nh because I'm using Pololu Romi32U4.

huang27c gravatar image huang27c  ( 2018-07-25 08:29:37 -0600 )edit