ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

can't use push_back for a array ros message in arduino

asked 2016-05-22 23:05:12 -0500

crazymumu gravatar image

Arduino code:

#include <ros.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/PoseArray.h>

ros::NodeHandle nh;

geometry_msgs::PoseArray array;
ros::Publisher p("array", &array);

void setup()
{ 
  pinMode(13, OUTPUT);
  nh.initNode();
  nh.advertise(p);
}

void loop()
{  
  geometry_msgs::Pose pose;

  pose.position.x=1;
  pose.position.y=1;
  pose.position.z=1;

  array.poses.push_back(pose);

  p.publish(&array);
  nh.spinOnce();
  delay(10);
}

Here is simple test to publish a PoseArray. When I compile it, I got the errors like:

/Users/Crazymumu/Desktop/array_test_1/array_test_1.ino: In function 'void loop()': array_test_1:37: error: request for member 'push_back' in 'array.geometry_msgs::PoseArray::poses', which is of pointer type 'geometry_msgs::Pose' (maybe you meant to use '->' ?)
array.poses.push_back(pose); ^ exit status 1 request for member 'push_back' in 'array.geometry_msgs::PoseArray::poses', which is of pointer type 'geometry_msgs::Pose
' (maybe you meant to use '->' ?)

I am not sure. This should be all right in original ROS environment. Any suggestions? Thanks

edit retag flag offensive close merge delete

Comments

Have you tried what the error suggest? I am not familiar with ROS Arduino, but it says that you must use array.poses->push_back

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-05-23 10:19:11 -0500 )edit

yes, I tried.

crazymumu gravatar image crazymumu  ( 2016-05-23 20:59:06 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-05-23 21:08:54 -0500

crazymumu gravatar image

updated 2016-05-23 21:10:08 -0500

use array.poses[i]=pose; No vector available in arudino. Also be aware that the arrays in the messages are not defined as vector objects.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-22 23:05:12 -0500

Seen: 1,024 times

Last updated: May 23 '16