Programming Hint - Ex 4.4

Friends could you please provide some hint to make my action client work properly? I am stuck in making my loop works to allow the husky robot goes continuously to 3 different goals spots forever…

The snippet of the code which is not working is below:

The robot does not move…just accept with one position loop (like the solution).

Thanks!

Hey @marcusvini178,
It looks like you are only defining the goal message, but never sending it. Also your while loops are stuck forever. You set i = 0 and then loop forever. The i = i + 1 has to be inside the while loop. Same with the count loop

1 Like

Thanks very much @simon.steinmann91 I did not realize that the i+1 and cout+1 were wrongly idented. And I was using the action client sender goal after the loop…enormous mistake! Now I put the communication sender goal inside the inner if loop and it worked properly.

However I am still with a doubt: I was simulating 3 different positions individually for the husky robot reach, before put all them together to work subsequently. And I noted that this move does not work if you just send values for X and Y coordinates. It is required to use the quarternions too, if not use the robot will stay stuck. Why?

The other aspect is confuse to me is that. These targets goals are:
From the robot, I mean from its position until reach the vector sent (X,Y, angles) ?? and then it starts moving X value and Y value until achieve these values??
OR
The target is regarding the map: I mean, I have a map, like a GPS, have latitude and longitute of the Earth and then the target is position X = 3 and y = 5 will always be the same place in this map? In other words the robot will move to this pose not from him but to achieve this “latitude/longitude” value in the map?

The confusion happens becuase the robot move is very randomly, so I could not get the idea visualizing it working…

And to finish this question. I used an enormous value for the counter in my while loop, for example while count < 1000. But lets say I really want an infinite loop. Which command or structure could I use to do that?

Thanks Simon!!!

I have not done this module, so I dont know how exactly the code works. With ROS navigation and tf you always work in frames. A frame is basically a coordinate system. You usually have a world or map frame that is static. This frame is a good reference and you can define your robot’s position relative to the static map frame. Then the goal position is also in the map frame, NOT relative to the robot. So yes, more like GPS.

But again, I do not know how the code works and whether it uses the orientation. Perhaps the orientation just has to be a valid format, but is not used. I do not know.

To answer your second question, to run an infinite loop do this:

while not rospy.is_shutdown():
   #do some work
   if something == True:  # optional, you can use this to run the loop forever until something happens
        break   #stops the loop if something == True
1 Like

Thanks @simon.steinmann91

Simon, I will add other doubt here from next exercise, the 4.7. It tells me that is posible create a path and visualize it without execute, sending a message to service move_base/make_plan.
Then I have created this service and worked properly, displaying in webshell the goal which I passed as input. However I could not visualize the path with markers in Rviz.


I expected I would see the path, even that the robot would not execute it. The head from tutorial says:
“In some cases, you might be interested in just visualizing the global plan, but not in executing that plan. For this case, the move_base node provides a service named /make_plan . This service allows you to calculate a global plan without causing the robot to execute the path. Let’s check how it works with the next exercise.”
I tried to subscribe to all the topics from the path plugin. Am I subscribing the wrong plugin?
More information below:

Thanks

I also could not understand wich result was expected executing the exercise 4.9:

“Change the use_dijkstra parameter to false, and repeat Exercise 4.8. Check if something changes now.”

I did not find this parameter in the .yam file I have created (copied from source) in the exercise. There was just the parameter:

NavfnROS:
  visualize_potential: true

which was set to true and then I change to false. However this parameter is regarding the unknow environment and the result of simulation did not change. What the professor who wrote this tutorial means with use_djikstra parameter?

In order to visualize something in Rviz, you have to publish the corresponding topic. In case of ‘Path’ that is a nav_msgs/Path msg http://docs.ros.org/api/nav_msgs/html/msg/Path.htmlhttp://docs.ros.org/api/nav_msgs/html/msg/Path.html

Make sure you are publishing a topic of that type correctly and that you are selecting it in Rviz as the Path topic. From the screenshots provided it is not 100% clear what you are doing.

I executed the exercise 4.7 properly. I compared with the solution later and it is much similar…just the words to represent an object and instance changes…
In this exercise, it was necessary just to pass goals as arguments through a service with a specific kind of srv message: GetPlan.
This message just simulates the plan goal (as the tutorial is telling) in order to provide the user visualizes the path, without the robot executing this path. The purpose is just visualization. The node which I launched is the same and worked well to display the path for the robot when the idea is calculating the path and executing. In this way, I imagine the topic is the same and was already published in Rviz, because I used it in this viewer. Maybe the problem can be that I did give all the positions/orientations arguments in the service script, such as the solution used. I assumed the position.z and the orientation.x and orientation.y would be set to 0 if I did not pass arguments. And maybe this is why the path is not displayed in Rviz…I will check…

the service GetPlan should return a nav_msgs/Path message, which you then have to publish, in order for Rviz to visualize it. I don’t have access to the course right now, so I can’t check.

Thanks Simon. No problem. I will reload my ws. Sometimes the issue is that I simulate one thing successive to other…and the system does not deal with…this also is not too important for me.
I am happy that I finished the class I of path planning 99%…
I still did not visit the path planning II, so maybe I will make a question that is in the next chapter…
So here go: I have read that the global planner can be swiched ( in tutorial just switched between navfn/NavfnROS and carrot_planner/CarrotPlanner.
But I need in my project use the Rapidly exploring Random Tree (RRT) path planner algorithm.
So is posible to change there for this specific path planner or need I use MoveIt to do that?
Because my professor used MoveIt to work with G500 but I think because he used also for plan the trajectory of the robot arm. So I am in doubt if the Navigation Stack will be enough to use my path planner algorithm (in case RRT) or if I will need to use MoveIt and make some integration, considering that Moveit- OMPL has a lot of path planner libraries ready for using…

I’m not very well versed in the whole navigation area. However I worked enough with moveit to know that it is very powerful. So I’d suggest going that route. But you should probably ask your Professor what he thinks.

1 Like