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

Revision history [back]

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not related to turtlebot. I suggest you change the tag to turtlesim.

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not really related to turtlebot. I suggest you change the tag to turtlesim.

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not really related to turtlebot. I suggest you change the tag to turtlesim.

---Edit

You should add self to create your instance attribute so that other methods in TurtleBot class are able to access self.posenew too. The topic you have subscribed to is incorrect. What is turtle/blah? It should be spawn_name/poseso in your case, i.e. blah/pose. The callback – update_posenew where you update your self.posenew is also wrong. Notice that you have two turtles so you have two different poses. Therefore, you need to round the pose of your blah turtle not the turtle1's one. So simply make this change to your code.

self.posenew.x = round(self.posenew.x, 4)
self.posenew.y = round(self.posenew.y, 4)

∆.x and ∆.y are thus the updated self.posenew.x and self.posenew.y respectively.

goal_pose.x = self.posenew.x
goal_pose.y = self.posenew.y

Please also be aware that when you assign Pose() to your new instance attribute self.posenew inside __init__, the contents of self.posenew are initially all set to 0.0 which might cause a problem a bit later. So I advise you to add

rospy.wait_for_message('blah/pose', Pose)

after definition of self.posenew to wait for the message to arrive on the topic blah/pose or simply adding rospy.sleep(0.5) will do the trick.

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not really related to turtlebot. I suggest you change the tag to turtlesim.

---Edit

You should add self to create your instance attribute so that other methods in TurtleBot class are able to access self.posenew too. The topic you have subscribed to is incorrect. What is turtle/blah? It should be spawn_name/poseso in your case, i.e. blah/pose. The callback – update_posenew where you update your self.posenew is also wrong. Notice that you have two turtles so you have two different poses. Therefore, you need to round the pose of your blah turtle not the turtle1's one. So simply make this change to your code.

self.posenew.x = round(self.posenew.x, 4)
self.posenew.y = round(self.posenew.y, 4)

∆.x and ∆.y are thus the updated self.posenew.x and self.posenew.y respectively.

goal_pose.x = self.posenew.x
goal_pose.y = self.posenew.y

Please also be aware that when you assign Pose() to your new instance attribute self.posenew inside __init__, the contents of self.posenew are initially all set to 0.0 which might cause a problem a bit later. affect the calculation of distance/velocity in move2goal(). So I advise you to add

rospy.wait_for_message('blah/pose', Pose)

after definition of self.posenew to wait for the message to arrive on the topic blah/pose or simply adding rospy.sleep(0.5) will do the trick.

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not really related to turtlebot. I suggest you change the tag to turtlesim.

---Edit---Edit:

You should add self to create your instance attribute so that other methods in TurtleBot class are able to access self.posenew too. The topic you have subscribed to is incorrect. What is turtle/blah? It should be spawn_name/poseso in your case, i.e. blah/pose. The callback – update_posenew where you update your self.posenew is also wrong. Notice that you have two turtles so you have two different poses. Therefore, you need to round the pose of your blah turtle not the turtle1's one. So simply make this change to your code.

self.posenew.x = round(self.posenew.x, 4)
self.posenew.y = round(self.posenew.y, 4)

∆.x and ∆.y are thus the updated self.posenew.x and self.posenew.y respectively.

goal_pose.x = self.posenew.x
goal_pose.y = self.posenew.y

Please also be aware that when you assign Pose() to your new instance attribute self.posenew inside __init__, the contents of self.posenew are initially all set to 0.0 which might affect the calculation of distance/velocity in move2goal(). So I advise you to add

rospy.wait_for_message('blah/pose', Pose)

after definition of self.posenew to wait for the message to arrive on the topic blah/pose or simply adding rospy.sleep(0.5) will do the trick.

click to hide/show revision 6
No.6 Revision

I think this is exactly what you are looking for. You just need to subscribe your /blah/pose to get the goal pose rather than get it from the user.

As for

stops at a 'D' unit distance from 'blah'

simply set distance_tolerance to your D unit.

I hope this helps!

P.S. This question is not really related to turtlebot. I suggest you change the tag to turtlesim.

---Edit:


Edit:

You should add self to create your instance attribute so that other methods in TurtleBot class are able to access self.posenew too. The topic you have subscribed to is incorrect. What is turtle/blah? It should be spawn_name/poseso in your case, i.e. blah/pose. The callback – update_posenew where you update your self.posenew is also wrong. Notice that you have two turtles so you have two different poses. Therefore, you need to round the pose of your blah turtle not the turtle1's one. So simply make this change to your code.

self.posenew.x = round(self.posenew.x, 4)
self.posenew.y = round(self.posenew.y, 4)

∆.x and ∆.y are thus the updated self.posenew.x and self.posenew.y respectively.

goal_pose.x = self.posenew.x
goal_pose.y = self.posenew.y

Please also be aware that when you assign Pose() to your new instance attribute self.posenew inside __init__, the contents of self.posenew are initially all set to 0.0 which might affect the calculation of distance/velocity in move2goal(). So I advise you to add

rospy.wait_for_message('blah/pose', Pose)

after definition of self.posenew to wait for the message to arrive on the topic blah/pose or simply adding rospy.sleep(0.5) will do the trick.