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

Use a Joystick in qnode.cpp

asked 2013-12-12 23:15:56 -0500

Cookie gravatar image

updated 2014-01-28 17:18:49 -0500

ngrennan gravatar image

Hi there,

i am quite new to ROS and c++, so excuse if if this question is an easy one, plz :)

i created a package with catkin_create_qt_package and now i want to use a JoyListener.

The problem is, that i really don't know how to integrate the code? I found some examples for using the joy.h node, but nothing for using it in the catkin created qt package :( Do i have to add the code in qnode.cpp ?

Sorry for my english XD i don't know how to explain my problem :3

[Edit] Sorry, i don't get it :( I used this code for subscribing the joy-node:

ros::Subscriber sub = n.subscribe<sensor_msgs::Joy>("joy", 10, &QNode::joyCallback);

And this is my prototype of the joyCallback-function:

void QNode::joyCallback(const sensor_msgs::Joy::ConstPtr& joy_msg)
{
 ros::Publisher chatter_publisher.publish(joy_msg); 
}

but i get this strange error and don't know what it means...

/usr/include/boost/function/function_template.hpp:225: error: no match for call to ‘(boost::_mfi::mf1<void, test_joy::QNode, const boost::shared_ptr<const sensor_msgs::Joy_<std::allocator<void> > >&>) (const boost::shared_ptr<const sensor_msgs::Joy_<std::allocator<void> > >&)’

do you have any idea of what i'm doing wrong?

edit retag flag offensive close merge delete

Comments

Do you want to receive joystick messages? In that case check out the standard subscriber tutorial.

dornhege gravatar image dornhege  ( 2013-12-13 00:03:29 -0500 )edit

i want to use the joystick for controlling an AR Drone. I thought it would be fine to display the pressed buttons in an QT gui, but i dont know how to check, which button is pressed from the gui package :/

Cookie gravatar image Cookie  ( 2013-12-13 04:54:22 -0500 )edit
1

If you want to know which buttons are pressed on a running joystick node then subscribe to a sensor_msgs/Joy message. It's usually on the /joy topic.

dornhege gravatar image dornhege  ( 2013-12-13 05:05:33 -0500 )edit

Ok thanks, i'll try it out :)

Cookie gravatar image Cookie  ( 2013-12-13 05:39:06 -0500 )edit

I don't get it >___< i updated the question to what i have done to subscribe the joy-messages.. help plz :(

Cookie gravatar image Cookie  ( 2013-12-13 07:46:53 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2013-12-13 10:11:46 -0500

joq gravatar image

The compiler is complaining because the pointer to a JoyStick message passed to your callback is not a valid parameter to the chatter_publisher.publish() method.

What in the world was that statement supposed to do?

ros::Publisher chatter_publisher.publish(joy_msg);

This is not a forum for basic C++ language questions.

edit flag offensive delete link more

Comments

sorry to ask stupid questions, i am new to c++... but i found out that this is not the real problem at all... i deletet this line and replaced it...but it seems as if my subscriber is not even entering my joyCallback(...)... whatever.... :(

Cookie gravatar image Cookie  ( 2013-12-14 01:26:51 -0500 )edit

Aaargh ok i found the mistake, it was the joystick itself..... thanks for helping me! :D

Cookie gravatar image Cookie  ( 2013-12-14 01:33:06 -0500 )edit

Question Tools

Stats

Asked: 2013-12-12 23:15:56 -0500

Seen: 582 times

Last updated: Dec 13 '13