You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

In this first example we show you how to write your code in C++ how to geht your code to work in the Lab Control Center. Using this example code your vehicles will drive in a circle (not attached to the map). The code also includes a possible solution to drive a figure eight (see code comments).

General Procedure to run let your vehicles drive
  1.  Write your code in C++ or Matlab
  2.  Compile it, if you use C++
  3. Upload it to the LCC (see here)
  4. Press "deploy"
Code description

You define the position of the target points, the speed of your vehicle for each section and the time the vehicle needs to pass a segment. In this example the target points are not connected to the map.

This vector defines the x position of a target point (m):

vector<double> trajectory_px = vector<double>{ 1, 0, -1, 0}

This vector defines the y position of a target point (m):

vector<double> trajectory_py = vector<double>{ 0, 1, 0, -1}

This vector defines the x speed to the target point. The sign gives the orientation in the cartesian coordinate system (unit (m/s)):

vector<double> trajectory_vx = vector<double>{ 0, -1, 0, 1}

This vector defines the y speed to the target point. The sign gives the orientation in the cartesian coordinate system (unit (m/s)):

vector<double> trajectory_vy = vector<double>{ 1, 0, -1, 0}

This vector defines the time the vehicle takes between two target points (unit ns):

vector<uint64_t> segment_duration = vector<uint64_t>{1550000000ull, 1550000000ull, 1550000000ull, 1550000000ull}

In this vector we see the time for 1 m/s and a way length of pi/2 (a quater circle ;))


Advice for use:

  • Speed, time and waylength have to fit. Verify your speed/way/duration with vges =s/t
  • Remember that vges = sqrt(vx^2 +vy^2) as it is a vector ((here vges,1 = vx,1,-vy,1))








  • Define the vector of your current point so that the tangent will fit with the vector/tangent from the previous point
  • Be aware 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
  • use always a speed for both dimensions (even it is only a very small value) to ensure the right tilt of your curve. → Draw your shape first and define the signs of your vectors. It turned out to be the easiest way to ensure the right orientations.
  • Remember that your are giving a trajectory to a physical system so sharp edges won't be possible




C++

Circular trajectory generation for one vehicle

MATLAB

Circular trajectory generation for one vehicle












  • No labels