Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.pyc
*.swp
mep3_simulation/webots_data/worlds/.eurobot.jpg
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""ObjectDetectionSupervisorController controller."""

# You may need to import some classes of the controller module. Ex:
# from controller import Robot, Motor, DistanceSensor
from controller import Robot

# create the Robot instance.
robot = Robot()

# get the time step of the current world.
timestep = int(robot.getBasicTimeStep())
OBJECT_DETECTION_CAMERA_NAME = "ODCamera"
camera = robot.getDevice(OBJECT_DETECTION_CAMERA_NAME)
camera.enable(timestep)

# You should insert a getDevice-like function in order to get the
# instance of a device of the robot. Something like:
# motor = robot.getDevice('motorname')
# ds = robot.getDevice('dsname')
# ds.enable(timestep)

# Main loop:
# - perform simulation steps until Webots is stopping the controller
while robot.step(timestep) != -1:
# Read the sensors:
# Enter here functions to read sensor data, like:
# val = ds.getValue()

# Process sensor data here.

# Enter here functions to send actuator commands, like:
# motor.setPosition(10.0)
pass

# Enter here exit cleanup code.
2 changes: 1 addition & 1 deletion mep3_simulation/webots_data/protos/ArucoTag.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PROTO ArucoTag [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
url [ %<= url >%]
url [ %<= url >% ]
}
roughness 1
metalness 0
Expand Down
16 changes: 9 additions & 7 deletions mep3_simulation/webots_data/protos/CentralTrackingDevice.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#VRML_SIM R2023b utf8
# template language: javascript
PROTO CentralTrackingDevice [
hiddenField SFColor blueColorVector 0 0.356 0.549
hiddenField SFColor yellowColorVector 0.97 0.71 0
]
{
Solid {
Expand All @@ -11,7 +13,7 @@ Solid {
children [
Shape {
appearance DEF WALL_APPEARANCE PBRAppearance {
baseColor 0.631 0.612 0.537
baseColor 0.5 0.5 0.5
roughness 1
metalness 0
}
Expand All @@ -37,7 +39,7 @@ Solid {
children [
Shape {
appearance DEF APPEARANCE_BLUE PBRAppearance {
baseColor 0 0.352941176 0.549019608
baseColor IS blueColorVector
roughness 1
metalness 0
name "blue"
Expand Down Expand Up @@ -76,11 +78,11 @@ Solid {
translation 0.1 -0.0585 0.489
children [
Shape {
appearance DEF APPEARANCE_GREEN PBRAppearance {
baseColor 0 0.439215686 0.235294118
appearance DEF APPEARANCE_YELLOW PBRAppearance {
baseColor IS yellowColorVector
roughness 1
metalness 0
name "green"
name "yellow"
}
geometry USE CENTRAL_TRACKING_TOP_BOX_HALF
}
Expand All @@ -90,7 +92,7 @@ Solid {
translation 0.0475 -0.111 0.489
children [
Shape {
appearance USE APPEARANCE_GREEN
appearance USE APPEARANCE_YELLOW
geometry USE CENTRAL_TRACKING_BOX_SLIT
}
]
Expand All @@ -99,7 +101,7 @@ Solid {
translation 0.1 -0.1635 0.489
children [
Shape {
appearance USE APPEARANCE_GREEN
appearance USE APPEARANCE_YELLOW
geometry USE CENTRAL_TRACKING_TOP_BOX_HALF
}
]
Expand Down
12 changes: 6 additions & 6 deletions mep3_simulation/webots_data/protos/GenericRobot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ PROTO GenericRobot [
field SFBool supervisor FALSE
field SFInt32 arucoNumber 1
field MFNode baseSlot []
field SFString {"blue", "green"} color "green"
field SFString {"yellow", "blue"} color "yellow"
hiddenField SFFloat mass_robot 15
hiddenField SFFloat robot_x_size 0.2
hiddenField SFFloat robot_y_size 0.3
hiddenField SFFloat robot_z_size 0.337
hiddenField SFFloat cap_cylinder_height 0.15
hiddenField SFColor blueVector 0 0.352941176 0.549019608
hiddenField SFColor greenVector 0 0.439215686 0.235294118
hiddenField SFColor blueVector 0 0.356 0.549
hiddenField SFColor yellowVector 0.97 0.71 0
]
{
%<
var color_vec;
var inverse_vec;
if (fields.color.value == "green") {
color_vec = fields.greenVector.value;
if (fields.color.value == "yellow") {
color_vec = fields.yellowVector.value;
inverse_vec = fields.blueVector.value;
}
else {
color_vec = fields.blueVector.value;
inverse_vec = fields.greenVector.value;
inverse_vec = fields.yellowVector.value;
}
let url = '"../worlds/assets/aruco/4x4_1000-' + fields.arucoNumber.value.toString() + '.png"';
>%
Expand Down
45 changes: 45 additions & 0 deletions mep3_simulation/webots_data/protos/Granary.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#VRML_SIM R2023b utf8
# template language: javascript
PROTO Granary []
{
Solid {
translation -0.775 0 0.028
children [
Pose {
translation -0.0008 0.0001 0.0278
rotation 0 0 1 1.57075
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
url [
"../worlds/assets/images/granary.png"
]
}
metalness 0
}
geometry Box {
size 1.799 0.45 0.0001
}
isPickable FALSE
}
]
}
Shape {
appearance PBRAppearance {
baseColor 0.5 0.5 0.5
metalness 0
}
geometry Box {
size 0.45 1.8 0.055
}
castShadows FALSE
isPickable FALSE
}
]
name "Granary"
boundingObject Box {
size 0.45 1.8 0.055
}
}
}
37 changes: 37 additions & 0 deletions mep3_simulation/webots_data/protos/GranaryEdge.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#VRML_SIM R2023b utf8
# template language: javascript
PROTO GranaryEdge [
field SFString {"left", "right"} location "left"
hiddenField SFVec3f leftEdgeTranslation -0.775 -0.8925 0.062
hiddenField SFVec3f rightEdgeTranslation -0.775 0.8925 0.062
]
{
%<
const location = fields.location.value;

const translation = location == "left"
? fields.leftEdgeTranslation.value
: fields.rightEdgeTranslation.value;

const granaryEdgeProtoId = `"Granary Edge [${location}]"`;
>%
Solid {
translation %<= translation.x >% %<= translation.y >% %<= translation.z >%
children [
Shape {
appearance PBRAppearance {
baseColor 0.5 0.5 0.5
metalness 0
}
geometry Box {
size 0.45 0.015 0.016
}
isPickable FALSE
}
]
name %<= granaryEdgeProtoId >%
boundingObject Box {
size 0.45 0.015 0.016
}
}
}
81 changes: 81 additions & 0 deletions mep3_simulation/webots_data/protos/Hazelnut.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#VRML_SIM R2023b utf8
# template language: javascript
PROTO Hazelnut [
field SFInt32 id 0
field SFString {"black", "yellow", "blue"} type "black"
field SFVec3f translation 0.2 0 0.015
field SFRotation rotation 0 1 0 0
hiddenField SFColor blueColorVector 0 0.356 0.549
hiddenField SFColor yellowColorVector 0.97 0.71 0
hiddenField SFColor blackColorVector 0 0 0
]
{
%<
const hazelnutType = fields.type.value; // "black" | "yellow" | "blue"

const arucoNumberMapping = {
black: 41,
yellow: 47,
blue: 36,
};
const arucoImageTextureUrl = `"../worlds/assets/aruco/aruco_${arucoNumberMapping[hazelnutType]}.png"`;

const hazelnutColorMapping = {
black: fields.blackColorVector.value,
yellow: fields.yellowColorVector.value,
blue: fields.blueColorVector.value,
};
const hazelnutColor = hazelnutColorMapping[hazelnutType];

const hazelnutId = `"[${fields.id.value}]"`;
>%
Group {
children [
Solid {
name %<= hazelnutId >%
translation IS translation
rotation IS rotation
children [
Solid {
translation 0 0 0.015515
rotation 0 0 1 1.57
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
url [
%<= arucoImageTextureUrl >%
]
}
metalness 0
}
geometry Box {
size 0.04 0.04 0.001
}
}
]
}
Shape {
appearance PBRAppearance {
baseColor %<= hazelnutColor.r >% %<= hazelnutColor.g >% %<= hazelnutColor.b >%
metalness 0
}
geometry Box {
size 0.15 0.05 0.03
}
}
]
boundingObject Shape {
appearance PBRAppearance {
baseColor 0.8 0.7 0
}
geometry Box {
size 0.15 0.05 0.03
}
}
physics Physics {
}
}
]
}
}
80 changes: 80 additions & 0 deletions mep3_simulation/webots_data/protos/HazelnutObjects.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#VRML_SIM R2023b utf8
# template language: javascript

EXTERNPROTO "Hazelnut.proto"

PROTO HazelnutObjects [
]
{
Group {
children [
Hazelnut { id 0 type "blue" translation 0.2 -0.275 0.015 }
Hazelnut { id 1 type "yellow" translation 0.2 -0.325 0.015 }
Hazelnut { id 2 type "yellow" translation 0.2 -0.375 0.015 }
Hazelnut { id 3 type "blue" translation 0.2 -0.425 0.015 }

Hazelnut { id 4 type "blue" translation 0.2 0.275 0.015 }
Hazelnut { id 5 type "yellow" translation 0.2 0.325 0.015 }
Hazelnut { id 6 type "blue" translation 0.2 0.375 0.015 }
Hazelnut { id 7 type "yellow" translation 0.2 0.425 0.015 }

Hazelnut { id 8 type "blue" translation -0.123 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 9 type "blue" translation -0.173 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 10 type "yellow" translation -0.223 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 11 type "yellow" translation -0.273 1.325 0.015 rotation 0 0 1 -1.57 }

Hazelnut { id 12 type "blue" translation 0.523 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 13 type "yellow" translation 0.573 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 14 type "blue" translation 0.623 1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 15 type "yellow" translation 0.673 1.325 0.015 rotation 0 0 1 -1.57 }

Hazelnut { id 16 type "blue" translation 0.827 0.473 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 17 type "blue" translation 0.827 0.423 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 18 type "yellow" translation 0.827 0.373 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 19 type "yellow" translation 0.827 0.323 0.015 rotation 0 0 1 -3.14 }

Hazelnut { id 20 type "yellow" translation 0.827 -0.473 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 21 type "blue" translation 0.827 -0.423 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 22 type "yellow" translation 0.827 -0.373 0.015 rotation 0 0 1 -3.14 }
Hazelnut { id 23 type "blue" translation 0.827 -0.323 0.015 rotation 0 0 1 -3.14 }

Hazelnut { id 24 type "yellow" translation 0.523 -1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 25 type "yellow" translation 0.573 -1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 26 type "blue" translation 0.623 -1.325 0.015 rotation 0 0 1 -1.57 }
Hazelnut { id 27 type "blue" translation 0.673 -1.325 0.015 rotation 0 0 1 -1.57 }

Hazelnut { id 28 type "blue" translation -0.127 -1.325 0.015 rotation 0 0 1 1.57 }
Hazelnut { id 29 type "yellow" translation -0.177 -1.325 0.015 rotation 0 0 1 1.57 }
Hazelnut { id 30 type "blue" translation -0.227 -1.325 0.015 rotation 0 0 1 1.57 }
Hazelnut { id 31 type "yellow" translation -0.277 -1.325 0.015 rotation 0 0 1 1.57 }

Hazelnut { id 32 type "yellow" translation -0.775 0.125 0.07 }
Hazelnut { id 33 type "blue" translation -0.775 0.175 0.07 }
Hazelnut { id 34 type "blue" translation -0.725 0.375 0.07 }
Hazelnut { id 35 type "yellow" translation -0.725 0.425 0.07 }

Hazelnut { id 36 type "blue" translation -0.775 -0.125 0.07 }
Hazelnut { id 37 type "yellow" translation -0.775 -0.175 0.07 }
Hazelnut { id 38 type "blue" translation -0.725 -0.375 0.07 }
Hazelnut { id 39 type "yellow" translation -0.725 -0.425 0.07 }

Hazelnut { id 40 type "yellow" translation -0.676 -0.625 0.07 }
Hazelnut { id 41 type "yellow" translation -0.676 -0.675 0.07 }
Hazelnut { id 42 type "yellow" translation -0.676 -0.725 0.07 }
Hazelnut { id 43 type "yellow" translation -0.676 -0.775 0.07 }

Hazelnut { id 44 type "blue" translation -0.676 0.625 0.07 }
Hazelnut { id 45 type "blue" translation -0.676 0.675 0.07 }
Hazelnut { id 46 type "blue" translation -0.676 0.725 0.07 }
Hazelnut { id 47 type "blue" translation -0.676 0.775 0.07 }

Hazelnut { id 48 translation -0.676 0.75 0.1 }
Hazelnut { id 49 translation -0.676 0.7 0.1 }
Hazelnut { id 50 translation -0.676 0.65 0.1 }

Hazelnut { id 51 translation -0.676 -0.75 0.1 }
Hazelnut { id 52 translation -0.676 -0.7 0.1 }
Hazelnut { id 53 translation -0.676 -0.65 0.1 }
]
}
}
Loading