1
$\begingroup$

I'm studying robotics at the university and as a practice, I have to implement potential field in the simulator (I'm going to use ROS and Gazebo).

I'm having troubles about how to implement it, especially in the data structures that I'm going to need. By the way, I'm going to do it with C++.

If I have understand it well, goal attracts the robot and obstacles repel it. So, the first thing I need is:

  1. A map with the obstacles, and goal location.

I will also need a function that computes the force between the robot's current location and goal, taking repelling force into consideration.

With the map and the previous function, I will move the robot to goal location.

Do you think I need something else?

$\endgroup$
2
$\begingroup$

I am assuming you need a force field mapping of a two-dimensional space.

You will need an array to hold the goals, unless there is only one. You will need an array to hold the obstacles. Both of these arrays must be two-dimensional to contain the coordinates of the locations.

You will need an algorithm that, for a given point in your space, sums the attractors and repulsors to come up with a vector force at that location in your field. You can do a vector summation - add all of the $F \cos \theta$ terms and all of the $F \sin \theta$ terms. This algorithm likely contains some factor based on the distance between locations. You might start by using a negative coefficient times the gravity equation for obstacles, and a positive coefficient for goals. This becomes more difficult to do when the obstacles are larger than point masses. You can play with the value of the coefficients to change the magnitude of the force field.

You will (probably, depending on the assignment) need a method to loop through the x and y coordinates of your space, computing the vector force for each location. If this is required, you will need to store this data.

Finally, you may need a way to display the force vectors. You can do this by displaying scaled lines in the direction of each vector, although your instructor may want some other representation.

Hopefully this will get you past your stuck point.

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. I think I will get a vector (with a magnitude and direction), because they are forces. How can I get this vector? In other words, what is the formula to compute that vector? $\endgroup$
    – VansFannel
    Aug 4 '19 at 7:28
  • $\begingroup$ Edited answer to address your comment. $\endgroup$
    – SteveO
    Aug 4 '19 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.