Commit b3290c6a authored by Helge's avatar Helge

Minor bug fixes and changed directory structure

parent 67ee34bc
Pipeline #187180 failed with stage
in 57 seconds
{
"modelsDir": "Bumpbot/models/",
"outputDir": "Bumpbot/target/",
"rootModel": "test.bumpBot",
"modelsDir": "models/",
"outputDir": "target/",
"rootModel": "bumper.bumpBot",
"generators": ["cpp", "roscpp"]
}
/* (c) https://github.com/MontiCore/monticore */
package test;
package bumper;
conforms to de.monticore.lang.monticar.generator.roscpp.RosToEmamTagSchema;
tags Bumb{
tag bumpBot.test with RosConnection = {topic = (/carla/ego_vehicle/vehicle_control_cmd, carla_msgs/CarlaEgoVehicleControl)};
tag bumpBot.vehicle_control with RosConnection = {topic = (/carla/ego_vehicle/vehicle_control_cmd, carla_msgs/CarlaEgoVehicleControl)};
tag bumpBot.orientation with RosConnection = {topic = (/carla/ego_vehicle/vehicle_status, carla_msgs/CarlaEgoVehicleStatus), msgField = orientation};
tag bumpBot.collision_normale with RosConnection = {topic = (/carla/ego_vehicle/collision, carla_msgs/CarlaCollisionEvent), msgField = normal_impulse};
tag bumpBot.collision_normale_out with RosConnection = {topic = (/carla/ego_vehicle/collision, carla_msgs/CarlaCollisionEvent), msgField = normal_impulse};
......
/* (c) https://github.com/MontiCore/monticore */
package test;
import test.structures.*;
package bumper;
import bumper.structures.*;
component BumpBot{
ports out Ego_Vehicle test,
ports out Ego_Vehicle vehicle_control,
in Quaternion orientation,
in Vector3 collision_normale,
out Vector3 collision_normale_out;
out Vector3 collision_normale_out;
implementation Math{
static B inited = false;
static B skip = false;
......@@ -20,39 +21,45 @@ component BumpBot{
collision_normale_out.z = collision_normale.z;
else
inited = true;
collision_normale_out.z = -1;
end
test.throttle = 1.0;
test.brake = 0.0;
test.hand_brake = false;
collision_normale_out.z = -1;
end
vehicle_control.throttle = 1.0;
vehicle_control.brake = 0.0;
vehicle_control.hand_brake = false;
test.gear = 1;
test.manual_gear_shift = false;
vehicle_control.gear = 1;
vehicle_control.manual_gear_shift = false;
Q tmp = asin(orientation.z);
B noCollisionHappened = abs(collision_normale.z+1) < 0.000001;
if noCollisionHappened
test.reverse = false;
test.steer= 0;
else
Q drivingDirX = (1-(abs(tmp)/(M_PI/4)));
vehicle_control.reverse = false;
vehicle_control.steer= 0;
else
Q drivingDirX = (1-(abs(tmp)/(M_PI/4)));
Q drivingDirY = 2*tmp/(M_PI/4);
Q collisionOrtogonalDirection = -drivingDirX * collision_normale.y + drivingDirY * -collision_normale.x;
Q collisionDirection = drivingDirX * -collision_normale.x + drivingDirY * collision_normale.y;
Q projectionFactor = collisionDirection / sqrt(drivingDirX * drivingDirX + drivingDirY * drivingDirY);
B turnCompleted = (projectionFactor * drivingDirX * -collision_normale.x) + (projectionFactor * drivingDirY * collision_normale.y) < 0;
if collisionDirection < 0.0 || turnCompleted
test.reverse = false;
test.steer= 0;
if collisionDirection < 0.0 || turnCompleted
vehicle_control.reverse = false;
vehicle_control.steer= 0;
skip = true;
else
test.reverse = true;
if collisionOrtogonalDirection > 0.0
test.steer = 0.5;
vehicle_control.reverse = true;
if collisionOrtogonalDirection > 0.0
vehicle_control.steer = 0.5;
else
test.steer = -0.5;
vehicle_control.steer = -0.5;
end
end
end
end
end
end
}
}
package test.structures;
import test.structures.*;
package bumper.structures;
import bumper.structures.*;
struct Collision{
Z other_actor_id;
......
/* (c) https://github.com/MontiCore/monticore */
package test.structures;
package bumper.structures;
struct Ego_Vehicle{
Q throttle;
......
package test.structures;
package bumper.structures;
struct Vector3{
Q x;
......
package test.structures;
import test.structures.*;
package bumper.structures;
import bumper.structures.*;
struct Vehicle_Status{
Q velocity;
......
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