Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OK, thank you for you advice. I used a geometry_msg

here the new code and that work perfectly:

#include <Servo.h>
#include <math.h> 
#include <ros.h>
#include <geometry_msgs/Point.h>

......  
......

ros::NodeHandle  nh;

void Moves_cb( const geometry_msgs::Point& cmd_msg){
Moves(cmd_msg.x,cmd_msg.y,cmd_msg.z); // Moves(x,y,z) it's a function witch move to the arm   to  the coordinates (x,y,z) using a linear trajectory
}
ros::Subscriber<geometry_msgs::Point> sub("Moves", Moves_cb);

void setup(){
 nh.initNode();
 nh.subscribe(sub);

 servo0.attach(8); 
 servo1.attach(9);
 servo2.attach(10);
 servo3.attach(11);
 Init();            // initialize the position of the robot 
 delay(2000); 
 }

 .......
 .......