Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Subscribe a array in the terminal / arduino

Hello,

I am trying to send a message to the Arduino using the terminal. The goal, is to control a little robot arm i have created, entering the coordinates in the terminal. I have no problem with the arduino part, but with the ROS part, it's a quite different...

I don't know how to do it.

Here is a part of my code:

#include <Servo.h>
#include <math.h> 
#include <ros.h>
#include <std_msgs/UInt16.h>

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

ros::NodeHandle  nh;void Moves_cb( const std_msgs::UInt16& cmd_msg){
Moves(cmd_msg.data,0,0); // Move the arm to the coordinates (x,y,z). Here i was verificating the code with only one element. Now i want to do the same with all the coordinates
}
ros::Subscriber<std_msgs::UInt16> 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); 
  }

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

Thanks

--Pierre

Subscribe a array in the terminal / arduino

Hello,

I am trying to send a message to the Arduino using the terminal. The goal, is to control a little robot arm i have created, entering the coordinates in the terminal. I have no problem with the arduino part, but with the ROS part, it's a quite different...

I don't know how to do it.

Here is a part of my code:

#include <Servo.h>
#include <math.h> 
#include <ros.h>
#include <std_msgs/UInt16.h>

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

ros::NodeHandle  nh;void Moves_cb( const std_msgs::UInt16& cmd_msg){
Moves(cmd_msg.data,0,0); // Move the arm to the coordinates (x,y,z). Here i was verificating the code with only one element. Now i want to do the same with all the coordinates
}
ros::Subscriber<std_msgs::UInt16> 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); 
  }

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

Thanks

--Pierre

Subscribe a an array in the terminal / arduino

Hello,

I am trying to send a message to the Arduino using the terminal. The goal, is to control a little robot arm i have created, entering the coordinates in the terminal. I have no problem with the arduino part, but with the ROS part, it's a quite different...

I don't know how to do it.

Here is a part of my code:

#include <Servo.h>
#include <math.h> 
#include <ros.h>
#include <std_msgs/UInt16.h>

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

ros::NodeHandle  nh;void Moves_cb( const std_msgs::UInt16& cmd_msg){
Moves(cmd_msg.data,0,0); // Move the arm to the coordinates (x,y,z). Here i was verificating the code with only one element. Now i want to do the same with all the coordinates
}
ros::Subscriber<std_msgs::UInt16> 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); 
  }

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

Thanks

--Pierre

Subscribe an array How to subscribe coordinates in the terminal / arduinoarduino?

Hello,

I am trying to send subscribe a message to the Arduino using the terminal. The goal, is to control a little robot arm i have created, entering the coordinates in the terminal. I have no problem with the arduino part, but with the ROS part, it's a quite different...

I don't know how to do it.

Here is a part of my code:

#include <Servo.h>
#include <math.h> 
#include <ros.h>
#include <std_msgs/UInt16.h>

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

ros::NodeHandle  nh;void nh;

void Moves_cb( const std_msgs::UInt16& cmd_msg){
Moves(cmd_msg.data,0,0); // Move Moves(x,y,z) it's a function witch move to the arm to the coordinates (x,y,z). Here i was verificating the code with only one element. Now i want to do the same with all the coordinates
(x,y,z) using a linear trajectory
}
ros::Subscriber<std_msgs::UInt16> 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); 
  }

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

In this code i have just subscribe a std_msgs::UInt16 to check if everything was working well (so i put y=0 and z=0 in the Moves function).

Now, i want to do subscribe the 3 coordinates (and not only one), but i have no idea to do this.

If some one have any idea.

Thanks

--Pierre