Exercise 12 making a robot, stuck on the idea

I am trying to solve the exercise 12, i am getting a bit stuck on the idea why the solution is like it is?

  • first the service of client server for determining if the obstacle is in front and figuring out wich way to turn, would it not be a better solution to do that inside a class? as from what i understand sending a request to the server and having the whole program wait for a response while the robot is driving, and it also adds another layer of communication, is this the best way, i mean is this what services would be best suited for? or am i just thinking of ros from an old arduino way where everything was done in one big program?
    Would it not be better to use an action server if anything for this particular task and just use a normal while loop

     while robot.has_no_obstacle_in_front:
         robot_contorller.cmd.liner.x = 0.5
  • also would it not be better to check the 3 laser reading at [0, 360, 719] to check if there is anything in front, and then determine if the robot is out of the maze?

reason why i am asking is because i am trying to get my head in to the “right way” of thinking when it comes to ros (from what i peace together from online it is not the same way of thinking as building a whole robot on Arduino) so i don’t want to be stuck in my old ways sort of say



There are many ways to tackle the project, and like you propose, a good solution would be to use an action server in a while loop, or checking the laser readings through a subscriber/callback.

Services are used for procedure calls that finish quickly, like checking the crash direction service that is used in the solution, so that’s why it’s a good idea to add a service in this case, and it’s also an effort to consolidate all of the learned topics throughout the course in the final project.

Action servers are basically service servers, with the addition that it can be done asynchronously which might help your overall program in certain situations. I like to think of service/action servers as implementations on top of the publisher/subscriber level, which would mean that adding this layer of communication would not affect the performance of the program, but rather improve it.