# Revision history [back]

You have a publisher with the queue size of 1 and you try to publish 3 messages one after another. What happens if you increase the queue size, or add some delay between the obstacle pose publishing?

General recommendation: always start with the minimal working prototype of what you want to do and after you are sure the prototype work, build up onto it. In your case first move the obstacles always the same, just to see you can move them. Then just two random direction to make sure you can change the movement during runtime. And work on every obstacle independently. First make the obstacle 1 move, then add obstacle 2 etc.

When I go through your code, I can see, that the obstacle 1 will always start at [2.5, 2.5] and move either backward (if a==2) or right (if a==1). Rest of the obstacle 1 code branch will never be executed.

As for obstacle 2, I cannot see where it is placed for the first time, but after the first loop, it will be placed at x coordinate 2.5 and there is no if branch for this condition. If the obstacle 2 starts at x coordinate 2.5 the object obstacle_2 will remain the same as it is at every loop.

When you get c==2, the obstacle 3 is set to x = -2.5 but again, there is no if statement that would satisfy this condition, so the obstacle_3 object stays the same. If c==1, you set the y coordinate to 2.5 so only the if obstacle_3.pose.position.y > 2.2: branch can ever be executed.

The idea is interesting, but the code is very ugly. It will be easier for us to help you, if you write clean code.