how to publish sensor_msgs/Joy in C++ ?
I already did check that using command in terminal using 'rostopic echo /teleop/joy'. But, I 'd like to check in my source code based on C++.
Here is my current test source code,
ros::Publisher pub_joy;
pub_joy = nh.advertise<sensor_msgs::Joy>("/teleop/joy", 1000);
void push_joyBtnStart() {
sensor_msgs::Joy joy;
joy.buttons.clear();
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(1); // means 'start' button
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0);
joy.buttons.push_back(0); // 11
pub_joy.publish(joy);
ROS_INFO("pushed start button");
}
This running node while doing echo rostopic('teleop/joy') in terminal. But, result is no response.
Any idea about this issue ? or Did you find my problem of this situation ?
Thanks.
Asked by Jeesang on 2016-03-30 01:43:04 UTC
Comments
what do you mean by no response? rostopic echo teleop/joy does not show anything or your robot is not moving? and are you making sure your function is being called?
Asked by Mehdi. on 2016-03-30 02:58:54 UTC
Sorry, it means that rostopic echo does not show anything. also I make sure my function is being called in main loop.
Asked by Jeesang on 2016-03-30 03:23:40 UTC
As @mehdi said please confirm that this function is being called. Second do you spin your node?
Asked by BennyRe on 2016-03-30 04:56:05 UTC