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

Revision history [back]

click to hide/show revision 1
initial version

Thanks Mike. I followed these steps: 1) create a package containing the two msg: diag.msg and motore.msg 2) catkin_make of the package 3) generate ros_lib libraries for the Arduino messages 4) copied the diagnostics.h and motore.h to Arduino libraries 5) created a test sketch:

include <ros.h> include <ros node_handle.h=""> include <diag motore.h=""> include <diag diag.h="">

diag::diag diag_msg; diag::motore motor_msg; ros::NodeHandle nh; ros::Publisher diag_pub("diagnostic", &diag_msg); void setup() { // put your setup code here, to run once:

// ROS Setup nh.initNode(); nh.advertise(diag_pub); while(!nh.connected()) nh.spinOnce(); }

void loop() { // put your main code here, to run repeatedly: motor_msg.heartbeat= false; motor_msg.speedRPM= 10; motor_msg.wheel_speed=2.45; motor_msg.voltage= 26.0; motor_msg.current= 2.0; motor_msg.torque=30; motor_msg.temperature= 27; motor_msg.HSinkTemp= 28; diag_msg.FrontLeft = motor_msg; //diag_msg.fl.statoCtl= 8;

diag_pub.publish(&diag_msg); delay (5000); nh.spinOnce(); }

As I told, if I try to compile the sketch I get the error:

Users/mdore/Dropbox/Il mio Mac (MacBook-Pro-di-Massimo.local)/Documents/Arduino/libraries/Rosserial_Arduino_Library/src/diag/diag.h:16:21: error: invalid use of incomplete type 'class diag::diag' typedef diag::motore _FrontLeft_type; ^~~~~~ /Users/mdore/Dropbox/Il mio Mac (MacBook-Pro-di-Massimo.local)/Documents/Arduino/libraries/Rosserial_Arduino_Library/src/diag/diag.h:13:9: note: definition of 'class diag::diag' is not complete until the closing brace class diag : public ros::Msg ^~~~ /Users/mdore/Dropbox/Il mio Mac (MacBook-Pro-di-Massimo.local)/Documents/Arduino/libraries/Rosserial_Arduino_Library/src/diag/diag.h:17:7: error: '_FrontLeft_type' does not name a type _FrontLeft_type FrontLeft; ^~~~~~~~~~~~~~~

-------------------------- Second try:

1) I created two packages diag and motore on Ros: diagnostica_ws/src/diag and diagnostica_ws/src/motor 2) catkin_make 3) generate ros_lib libraries 4) copied diag.h on diag/diag.h and motore.h in motore/motore.h 5) compile the sketch changing the class name:

diag::diag diag_msg; motore::motore motor_msg; ros::NodeHandle nh; ros::Publisher diag_pub("diagnostic", &diag_msg); void setup() { // put your setup code here, to run once:

// ROS Setup nh.initNode(); nh.advertise(diag_pub); while(!nh.connected()) nh.spinOnce(); }

void loop() { // put your main code here, to run repeatedly: motor_msg.heartbeat= false; motor_msg.speedRPM= 10; motor_msg.wheel_speed=2.45; motor_msg.voltage= 26.0; motor_msg.current= 2.0; motor_msg.torque=30; motor_msg.temperature= 27; motor_msg.HSinkTemp= 28; diag_msg.FrontLeft = motor_msg; //diag_msg.fl.statoCtl= 8;

diag_pub.publish(&diag_msg); delay (5000); nh.spinOnce(); } now the compilation is fine, but the problem is on ros side, as I told you. ROS melodic runs on a x64 cpu with ubuntu 18.04lts

Probably I have to solve the compilation error on Arduino (Arduino due processor). it should be the same relationship as , fo example, Pose and Point but in my case I do not understand the problem. Thanks Massimo