Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

cd ~\dev\software\hlc\matlab\basic_circle_example

How the code works

In this example one vehicle drives in a circle which is not attached to the map. See the sourcecode for explicit documentation. This chapter only provides the theoretical background.

Initialisation

...

Goal

The vehicle will drive in a basic circle with a radius of 1m. The center of the circle will be in the center of the map, but the circle will not be connected to the map.

Initialisation

Initialize a DDS Writer for the RTI DDS Service is intialtized to ensure that position and speed will be sent to the simulation and the vehicle.

Giving direction and speed

Next points and speed Define four points of your circle on a coordinate system.

BILD 

Define the speed vector of the vehicle are defined at for each point for the entire trajectory. When you use define v_x and v_y keep in mind that this is not the actual speed but the speed vector at your current location ( remember that vges = sqrt(vx^2 +vy^2) (as it is a vector). You use this vector to define the direction for your vehicle, so where it has to steer next:

...

While defining the speed vector also be aware that the tangent will fit with the vector/tangent from the previous point and that the shape of the curve is not only affected by the vector of the starting point but also of the vector at the end point/next starting point. It turns out that it is the easiest way to define your speed vector by drawing our shape first and define the signs of your vectors to ensure the right orientations. It is recommanded to always define a speed for both v_x and v_y, even if it is a small value, to ensure the right orientation of your vehicle. Last but not least remember that your are giving a trajectory to a physical system so sharp edges won't be possible.
. Always assign at least a small value to both vectors to ensure the correct direction. Remember that your are defining a physical system, so avoid sharp edges.

Draw the vecotrs on each point of your trajectory:


Image Added


Image Added



Now implement your points and speed values using the predefined vetors trajectory_px and trajectory_py for your points of the trajectory and trajectory_vx and trajectory_vy for the speed at each point. The speed is given in m/s. Set the center of the circle to the center of the map at x =2,25m and y= 2m.

Segment duration

For the segment duration keep in mind that speed, time and waylength have to fit. Verify your speed/way/duration with vges =ssegment/tsegmentduration.

...