Ask Your Question
0

Extract data from topic (ar_pose)

asked 2017-03-24 11:09:20 -0500

jsoley gravatar image

Hi, I am trying to get data from ar_pose_markers. I am running the package and I see the topic is refreshing with new data. I am using ar_tools and usb_cam.

I have to make a node that subscribe to this topic and it able to extract the information. I am subscribing to the topic but I can extract the position. This code give me a number but is the same number all the time.

The node code is the following one

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <ar_pose/ARMarkers.h>



int yo=10;
int zo;
int i=0;
void ar_pose_markerCallback(const ar_pose::ARMarkers::ConstPtr& msg)
{
float xo=0;
ROS_INFO("hello world");
ar_pose::ARMarker ar_pose_marker;
xo=ar_pose_marker.pose.pose.orientation.x;
ROS_INFO("%d", xo);


}

int main(int argc, char **argv)
{
ROS_INFO("hello world");
ros::init(argc, argv, "node_sub");
ros::NodeHandle n;
ros::Rate loop_rate(1);
ros::Subscriber sub = n.subscribe("ar_pose_marker", 1, ar_pose_markerCallback);
while (ros::ok())

{

ros::spinOnce();
loop_rate.sleep();

} return 0; }

edit retag flag offensive close merge delete

Comments

Try the following:

xo=ar_pose_marker.pose.pose.orientation.x;

xo=msg->pose.pose.orientation.x;

You do not use the received data in your code, instead you use the initial value from the constructor of the marker.

angeltop gravatar image angeltop  ( 2017-03-27 07:01:17 -0500 )edit

Can you write this in Python. Thanks. I wanted to know the current position of my markers and then I have to move my drone to the next way point which is a 3D position.

Mikku gravatar image Mikku  ( 2017-11-23 00:37:26 -0500 )edit

@Mikku You can follow the tutorial : http://wiki.ros.org/ROS/Tutorials/Wri...

angeltop gravatar image angeltop  ( 2017-11-23 01:55:32 -0500 )edit

Sir I have done that and made my Python file. But I don't want to use callback function. Because when I have to move the drone to the different point . The changes I am doing in the callback function is not being reflected on the main program. I am therefore looking for an another way to find poses.

Mikku gravatar image Mikku  ( 2017-11-23 03:21:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-29 07:27:20 -0500

saikishor gravatar image

updated 2017-03-29 07:28:10 -0500

if you have only using one marker, with your camera try using the below command to fetch x;

msg->markers[0].pose.pose.position.x

if you want orientation, replace "position" with "orientation"

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-03-24 11:09:20 -0500

Seen: 774 times

Last updated: Mar 29 '17