invalid conversion from void(*) to ros
Hi , i am new to ROS and arduino . i had some problems with my codes . Do you guys mind helping me take a look at my codes ?
#include <ros.h>#include <stdmsgs/Int32.h> #include <stdmsgs/Int16.h> #include <stdmsgs/Float32.h> #include <stdmsgs/String.h>
/*******************/ / Variables setup */ /********************/
int interruptPin = 2; char bufferX[9]; char bufferY[9];
String str = ""; String str_ = ""; bool go = false;
int R; int L;
stdmsgs::Int32 lwheelmsg; stdmsgs::Int32 rwheelmsg;
stdmsgs::Float32 lmotormsg; stdmsgs::Float32 rmotormsg;
/********************/ / Subscribed Nodes */ /*********************/
ros::NodeHandle nh;
ros::Publisher lwheel("lwheel", &lwheelmsg); ros::Publisher rwheel("rwheel", &rwheelmsg);
void lmotorCb(){ Serial1.print("V21="); Serial1.println(L); Serial1.println("V31=1"); }
void rmotorCb(){ Serial1.print("V22="); Serial1.println(R); Serial1.println("V31=1");
} ros::Subscriber<stdmsgs::Float32> lwheelvtarget("lwheelvtarget", lmotorCb); ros::Subscriber<stdmsgs::Float32> rwheelvtarget("rwheelvtarget", rmotorCb);
void setup() { Serial.begin(115200); Serial1.begin(38400); pinMode(interruptPin, INPUT); UCSR1C = (UCSR1C & 0xCF) | (0b11 << 4); // Enable odd parity
/*******************/ / ROS Node setup */ /********************/ nh.getHardware()->setBaud(115200); nh.initNode(); nh.subscribe(lwheelvtarget); nh.subscribe(rwheelvtarget); nh.advertise(lwheel); nh.advertise(rwheel); }
void loop() { //Fetching encoder line Serial1.find('=');
str = Serial1.readStringUntil(','); str = Serial1.readStringUntil('\n'); strncpy(bufferX, str.cstr(), 9); //String to char rwheel_msg.data = (unsigned int)strtol(&bufferX[1], NULL, 16);
strncpy(bufferY, str.cstr(), 9); //String to char lwheelmsg.data = (unsigned int)strtol(&bufferY[1], NULL, 16); lwheel.publish(&lwheelmsg); nh.spinOnce(); rwheel.publish(&rwheelmsg); nh.spinOnce(); /***********************************/ / Tesiting routine (use when needed) */ /***********************************/ / Serial.print("Left wheel: "); Serial.print(lwheelmsg.data); Serial.print(" - Right wheel: "); Serial.print(rwheel_msg.data); Serial.print("\n"); */ }
And this is the error shown
/tmp/arduinomodifiedsketch623299/AMC-8004.ino:52:77: warning: invalid conversion from 'void (*)()' to 'ros::Subscriber<stdmsgs::Float32>::CallbackT {aka void (*)(const stdmsgs::Float32&)}' [-fpermissive] ros::Subscriber<stdmsgs::Float32> lwheelvtarget("lwheelvtarget", lmotorCb); ^
Asked by AyeSir on 2016-09-07 23:07:58 UTC
Comments