Arduino Twist subscriber won't work
This small program on Arduino sure gives lengthy errors! What am I doing wrong? This is Auduino UNO attached to Jetson TX1, with Rosserial.
ERROR
simple_subscriber_cmd_vel4.ino:17:74: error: invalid conversion from 'int' to 'ros::Subscriber<geometry_msgs::Twist>::CallbackT {aka void (*)(const geometry_msgs::Twist&)}' [-fpermissive]
In file included from /home/ubuntu/sketchbook/libraries/ros_lib/ros/node_handle.h:84:0,
from /home/ubuntu/sketchbook/libraries/ros_lib/ros.h:38,
from simple_subscriber_cmd_vel4.ino:2:
/home/ubuntu/sketchbook/libraries/ros_lib/ros/subscriber.h:65:7: error: initializing argument 2 of 'ros::Subscriber<MsgT>::Subscriber(const char*, ros::Subscriber<MsgT>::CallbackT, int) [with MsgT = geometry_msgs::Twist; ros::Subscriber<MsgT>::CallbackT = void (*)(const geometry_msgs::Twist&)]' [-fpermissive]
Subscriber(const char * topic_name, CallbackT cb, int endpoint=rosserial_msgs::TopicInfo::ID_SUBSCRIBER) :
^
simple_subscriber_cmd_vel4.ino:17:74: error: invalid conversion from 'void (*)(const geometry_msgs::Twist&)' to 'int' [-fpermissive]
In file included from /home/ubuntu/sketchbook/libraries/ros_lib/ros/node_handle.h:84:0,
from /home/ubuntu/sketchbook/libraries/ros_lib/ros.h:38,
from simple_subscriber_cmd_vel4.ino:2:
/home/ubuntu/sketchbook/libraries/ros_lib/ros/subscriber.h:65:7: error: initializing argument 3 of 'ros::Subscriber<MsgT>::Subscriber(const char*, ros::Subscriber<MsgT>::CallbackT, int) [with MsgT = geometry_msgs::Twist; ros::Subscriber<MsgT>::CallbackT = void (*)(const geometry_msgs::Twist&)]' [-fpermissive]
Subscriber(const char * topic_name, CallbackT cb, int endpoint=rosserial_msgs::TopicInfo::ID_SUBSCRIBER) :
^
SKETCH
#include <ArduinoHardware.h>
#include <ros.h>
#include <geometry_msgs/Twist.h>
ros::NodeHandle nh;
geometry_msgs::Twist msg;
float move1;
float move2;
void roverCallBack(const geometry_msgs::Twist& cmd_vel)
{
move1 = cmd_vel.linear.x * 127 ;
move2 = cmd_vel.angular.z * 127 ;
}
ros::Subscriber <geometry_msgs::Twist> sub("/cmd_vel", 100, roverCallBack);
void setup()
{
nh.initNode();
nh.subscribe(sub);
}
void loop()
{
nh.spinOnce();
delay(1);
}