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

Compare with Current View Page History

« Previous Version 18 Next »

General procedure to run let your vehicles drive

Here is basically what you always do, if you want one or more vehicles drive according to your trajectory:

  1.  Write your code in C++ or Matlab
  2.  Compile it, if you use C++
  3. Upload it to the Lab Control Center (LCC) (see here)
  4. Press "deploy" in the LCC


If you only want to drive a vehicle to a specific point follow the instructions here.

Code example

C++

Circular trajectory generation for one vehicle

MATLAB

Circular trajectory generation for one vehicle

How the code works

In this first example we show you how to write your code in C++ or MATLAB.  In this example one vehicle drives in a circle which is not attached to the map.

Initialisation

Therefore you first initiate a Writer for the RTI DDS Service to ensure the position and speed will be sent to the simulation and the vehicle.

Giving direction and speed

In the next step you define the points and the speed of your vehicle at each point for your entire trajectory. When you use 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:




When you define 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.

Segment duration

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

Sending the trajectory information to the vehicle

At last you sent all data to your vehicle using the writer-function from the beginning.


Matlab specific information

First steps - what the HLC scripts need to include

  • Send a ReadySignal message after initialization - only the ID string matters, which must be of the form "hlc_" + vehicle_id, where the latter is the ID of the vehicle the HLC is responsible for
  • Receive VehicleStateList messages, which include the current states and observations of the vehicle as well as the current time - this signal is supposed to be the start signal for the HLC, so computation should start using this data after the message was received. Make sure to ignore signals received during computation, if that takes longer than a single period
  • Send vehicle command messages as a result of the communication including the vehicle ID to the Middleware, which propagates these to the vehicle
  • React to stop signals sent by the LCC and propagated to the HLC by the Middleware
  • Your function head may differ, but you must use varargin as your last parameter to pass vehicle IDs to your script. This allows you to define, for your script, which vehicle(s) it should be responsible for. Any previous parameters you define are your own 'custom' parameters and need to be specified as additional parameters in the Lab Control Centers' UI before starting your script (if you wish to start it using the UI).














  • No labels