0
$\begingroup$

Rosanswers logo

Hi everyone,

I have a robot equipped with different sensors. one of them is 3d lidar. i have used the pointcloud and converted them into lasersacn. now i have written a simple python code which do object detction and specify the distance from the nearest object to the lidar based on the lasersan ranges. this is the first code, now i have written another code which should use this value and start moving and stop when it reach near the object. now my problem is that i want the distance value specified in the first code(output of the first code, for instance it would say 10 m to the object), automatically be called in the second code. what should i do?

thanks


Originally posted by Delbina on ROS Answers with karma: 109 on 2022-08-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

There are many choices/design decisions to take at this point.

  1. The simplest idea is to publish the distance value as a latched topic. Then, in your second program, please make a subscriber, listening to the published topic. This way, you can easily get the distance value in your second program.
  2. Another approach could be making use of ROS Service. On the first program (node), please make a service server that returns the distance from the object. Then, please create a service client on the second program (node) to get the distance value.

Once you have the distance value, you can execute the move command.


Originally posted by ravijoshi with karma: 1744 on 2022-08-17

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Delbina on 2022-08-17:
thanks a lot

Comment by Delbina on 2022-08-17:
@Ravi Joshi i want to use the first suggestion, I have defined publisher in the first code and subscriber in the second code. now just running the first code and then the second code would be ok?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.