PID following line

asked 2021-06-22 08:19:12 -0500

maxrobot gravatar image

Hello.

I have a car that should follow a line. The line is based on a point cloud from when the car has driven a track before. Lets say it drives down the alley and back. I want the car to follow the path as if the point cloud created a line and it followed it that way. I am planning on using the ROS PID system and dont know how to calculate the distances between the car and the "line" One way would be to extract all points in the cloud, assuming a 2d-world(discarding z-axis) and look at all coordinates and see which one is closest and then get the distance between me and that coordinate. That would be the offset. But I'm unsure how to make that happen. Do you have any suggestions?

The only thing I can think of is to do this:

  1. Drive a path to create a point cloud e.g (rosbag record -a)
  2. Stop recording and loop through all timestamps and store the coordinates in an array.
  3. Set the speed to a given number
    1. Then calculate the one closest to the car
    2. When the closest point is found, take the offset and publish to the corresponding topic following the ROS PID guide
    3. Loop to step 3 again.
edit retag flag offensive close merge delete