Hi,
I've written a small program which subscribes the topic "joy" from the joy_node (joystick) then it should process the date and publish it on a new topic "sub_dynamixel". Well but it doesn't, the code compiles but no published data available.
#include <sensor_msgs/Joy.h>
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "message/message_back.h"
#include <sstream>
#include <stdio.h>
#include <iostream>
void chatterCallback(const sensor_msgs::Joy::ConstPtr &joy)
{
float position;
int position_move;
ros::NodeHandle r;
ros::Publisher chatter_pub = r.advertise<message::message_back>("sub_dynamixel", 1000);
message::message_back msg;
position = joy->axes[0];
if(position>0)
{
position_move=position*512;
position_move+=512;
}
else if(position<0)
position_move=512-(position*(-1)*512);
else if(position==0)
position_move=512;
msg.position_move = position_move;
chatter_pub.publish(msg);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "dynamixel_teleoperation");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("joy", 1000, chatterCallback);
ros::spin();
return 0;
}
Originally posted by Ros451 on ROS Answers with karma: 18 on 2013-09-10
Post score: 0