Aufgrund einer Wartung wird GitLab am 26.10. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 26.10. between 8:00 and 9:00 am.

Commit fff4f399 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Model: added Rectangle struct

parent 4c88328a
......@@ -4,6 +4,7 @@ import ba.util.RelToAbsTrajectory;
import ba.util.CommQuality;
import ba.vehicle.VelocityController;
import ba.collisionDetection.CollisionDetectionGeneric;
import ba.struct.Rectangle;
//component System<N1 n = 2,N1 x = 1,N1 m = 5,N1 m1 = 4,N1 m2 = 10>{
component System{
//Intersection ports
......@@ -12,7 +13,7 @@ component System{
in Q^{3,5} absTrajectory[2];
//Collision detection ports
ports in Q(0m : 10000000m)^{2,4} hullsIn[2],
ports in Rectangle hullsIn[2],
out B collisionOut;
//Vehicle ports
package ba.collisionDetection;
import ba.util.RectIntersection;
import ba.util.SingleSetCompareMatrix;
import ba.util.SingleSetCompareRectangle;
import ba.util.MultiOr;
import ba.struct.Rectangle;
component CollisionDetectionGeneric<N1 n = 2,N1 x = 1>{
//component CollisionDetection{
ports in Q^{2,4} hulls[n],
ports in Rectangle hulls[n],
out B collision;
instance SingleSetCompareMatrix<2,4,2,1> singleSetCompare;
instance SingleSetCompareRectangle<2,1> singleSetCompare;
instance RectIntersection rectIntersection[x];
instance MultiOr<1> multiOr;
package ba.struct;
struct Point{
Q posX;
Q posY;
\ No newline at end of file
package ba.struct;
component RectToPoints{
ports in Rectangle rect,
out Point points[4];
implementation Math{
points(1) = rect.pointA;
points(2) = rect.pointB;
points(3) = rect.pointC;
points(4) = rect.pointD;
\ No newline at end of file
package ba.struct;
struct Rectangle{
Point pointA;
Point pointB;
Point pointC;
Point pointD;
\ No newline at end of file
package ba.util;
import ba.struct.Point;
component PointsToLine{
ports in Point pointA,
in Point pointB,
out Q^{4,1} line;
implementation Math{
line(1,1) = pointA.posX;
line(2,1) = pointA.posY;
line(3,1) = pointB.posX;
line(4,1) = pointB.posY;
\ No newline at end of file
package ba.util;
import ba.struct.Rectangle;
component RectIntersection{
//TODO: make rect type clearer. Current: 4 points going clockwise around the rect
ports in Q^{2,4} rect1,
in Q^{2,4} rect2,
ports in Rectangle rect1,
in Rectangle rect2,
out B collision;
//check intersection of 4*4 lines w/o permutations
package ba.util;
import ba.struct.Rectangle;
import ba.struct.RectToPoints;
component RectToLines{
ports in Q^{2,4} rect,
ports in Rectangle rect,
out Q^{4,1} lines[4];
implementation Math{
Q^{4,1} tmpLine;
for i = 1:4
Z j;
if i == 4
j = 1;
j = i + 1;
tmpLine(1,1) = rect(1,i);
tmpLine(2,1) = rect(2,i);
tmpLine(3,1) = rect(1,j);
tmpLine(4,1) = rect(2,j);
lines(i) = tmpLine;
//TODO: as array once issue is resolved
//if i == 1
// lineA = tmpLine;
// elseif i == 2
// lineB = tmpLine;
// elseif i == 3
// lineC = tmpLine;
// elseif i == 4
// lineD = tmpLine;
// end
instance RectToPoints rectToPoints;
instance PointsToLine pointsToLine[4];
connect rect -> rectToPoints.rect;
connect rectToPoints.points[1] -> pointsToLine[1].pointA;
connect rectToPoints.points[2] -> pointsToLine[1].pointB;
connect rectToPoints.points[2] -> pointsToLine[2].pointA;
connect rectToPoints.points[3] -> pointsToLine[2].pointB;
connect rectToPoints.points[3] -> pointsToLine[3].pointA;
connect rectToPoints.points[4] -> pointsToLine[3].pointB;
connect rectToPoints.points[4] -> pointsToLine[4].pointA;
connect rectToPoints.points[1] -> pointsToLine[4].pointB;
connect pointsToLine[:].line -> lines[:];
\ No newline at end of file
package ba.util;
import ba.struct.Rectangle;
//TODO: x has to be (n-1)n/2
//TODO: EMAM2Cpp does not work with struct generics
component SingleSetCompareRectangle<N1 n = 2,N1 x = 1>{
ports in Rectangle setIn[n],
out Rectangle outA[x],
out Rectangle outB[x];
implementation Math{
Z counter = 1;
for i = 1:n
for j = (i+1):n
outA(counter) = setIn(i);
outB(counter) = setIn(j);
counter = counter + 1;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment