How to run an action server simultaneously

My assignment is to make a robot move in a square, stop when an obstacle is detected, and send distance covered as feedback using a service server and an action server respectively. At the moment both servers run sequentially. Please how can I make both servers run simultaneously?

Since this is an assignment, we can’t give you the full answer. Here are some hints (there are other ways, but this is the simplest I can think of).

  1. Write separate scripts for your action and service servers.
  2. Write a different script for the client, which will contain the main logic for moving the robot and will call the action or service when necessary.
  3. Have your package launch file start the action and service scripts, then your client script.

Voila!

The above example uses three scripts and one launch file. You may be able to do one/two scripts (especially with Python classes), but that will depend on how much you are familiar with programming.

PS:
I believe you have taken into account what you need to do to implement:
a. Obstacle avoidance
b. Calculating the distance covered