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

Trouble subscribing to turtlesim color sensor in a rostest

asked 2011-06-14 19:56:15 -0600

gainerems gravatar image

updated 2011-06-16 19:40:57 -0600

def callback(data):
x = rospy.Subscriber("/turtlesim/turtle1/color_sensor",Color, callback)

Hi, The topic is subscribe and published but i can manage to display the content, if you have any idea thanks.I am using rostest and the master server is different than with roslaunch. (conflit or setup to do?). it's never leave the rospy.spin()

thanks for your answer, the topic is good. When it subscribe I get this so it should be okay. But the callback is never call. I think rostest is doing something i don't get. I run the same in tutorial) and it's work.

rostopic info /turtlesim/turtle1/color_sensor 

Type: turtlesim/Color

Publishers:   * /turtlesim/turtlesim_node (http://jsf-p-desktop:55631/)

Subscribers:   * /turtlesim_move_test (http://jsf-p-desktop:34016/)

okey , i checked the and they use:

 sub = rospy.Subscriber(topic, rospy.AnyMsg, self.callback)

should I look for the use of self?


edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2011-06-16 05:49:32 -0600

jbohren gravatar image

You'll be unable to connect with nodes that were launched under rostest since rostest uses port 22422 instead of 11311. You will need to change the ROS_MASTER_URI to accommodate this, i.e.:

$> export ROS_MASTER_URI=http://your-hostname:22422

This is described in more detail here.

edit flag offensive delete link more


Thx, actually I run the test and in another terminal (with changing the host) with the listener it works. The problem is in the test script, I can't get topic data from their. It's look like I can subscribe but i can't "listen" in test script.
gainerems gravatar image gainerems  ( 2011-06-16 19:33:10 -0600 )edit

answered 2011-06-14 21:27:00 -0600

dornhege gravatar image

Do you have a typo? You are subscribing to /tulesim..., but might want /turtlesim...

It is ok to have a separate roscore running.

edit flag offensive delete link more

answered 2011-06-16 04:11:33 -0600

kwc gravatar image

updated 2011-06-16 04:11:45 -0600

rostest does not run against the existing roscore. Instead, it sets up its own ROS system. Does your rostest start all of the nodes that you intend to test with?

edit flag offensive delete link more


thx, i stoped roscore but it's still the same.
gainerems gravatar image gainerems  ( 2011-06-16 19:34:20 -0600 )edit

answered 2011-06-16 23:39:09 -0600

gainerems gravatar image

updated 2011-06-17 00:08:11 -0600


I should put the rostest in text mode earlier, the log info is working.

rospy.loginfo(rospy.get_name()+"I heard %s",data.r)

but i don't why the fail is not working in the callback, how can I stop the callback loop?

edit flag offensive delete link more

Question Tools


Asked: 2011-06-14 19:56:15 -0600

Seen: 1,135 times

Last updated: Jun 17 '11