JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
goal_structure.hpp
Go to the documentation of this file.
1// Copyright (c) JSim contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the LGPLv3 license file in the root directory of this project.
4
5#pragma once
6
7#include <functional>
8
10
11namespace frcsim {
12
17 enum class Shape {
39 };
40
50
56 Vector3 half_extents_m{0.2, 0.2, 0.2};
58 double radius_m{0.25};
59
64
66 std::function<bool(const Vector3&)> custom_position_checker{};
67
69 std::function<bool(const Vector3&)> custom_velocity_validator{};
70
76 bool contains(const Vector3& position_m) const {
78 return custom_position_checker(position_m);
79 }
80
81 if (shape == Shape::kSphere) {
82 return (position_m - center_m).norm() <= radius_m;
83 }
84
85 const Vector3 delta = position_m - center_m;
86 return std::abs(delta.x) <= half_extents_m.x &&
87 std::abs(delta.y) <= half_extents_m.y &&
88 std::abs(delta.z) <= half_extents_m.z;
89 }
90
96 bool velocityAllowed(const Vector3& velocity_mps) const {
98 return custom_velocity_validator(velocity_mps);
99 }
101 return velocity_mps.z > 0.0;
102 }
103 return true;
104 }
105};
106
107} // namespace frcsim
Definition vector.hpp:13
Scoring volume definition used by arena presets and projectile checks.
Definition goal_structure.hpp:15
Vector3 half_extents_m
Half-extent dimensions used when shape is kBox (meters).
Definition goal_structure.hpp:56
bool velocityAllowed(const Vector3 &velocity_mps) const
Test whether a velocity satisfies score acceptance constraints.
Definition goal_structure.hpp:96
bool require_positive_vertical_velocity
When true, scoring requires upward (+Z) velocity unless custom validator overrides.
Definition goal_structure.hpp:63
Shape shape
Definition goal_structure.hpp:52
std::function< bool(const Vector3 &)> custom_position_checker
Optional custom position test for complex geometry in kCustom mode.
Definition goal_structure.hpp:66
Shape
Built-in geometry modes for goal containment tests.
Definition goal_structure.hpp:17
@ kBox
Definition goal_structure.hpp:18
@ kCustom
Definition goal_structure.hpp:38
@ kSphere
Definition goal_structure.hpp:19
double radius_m
Sphere radius used when shape is kSphere (meters).
Definition goal_structure.hpp:58
bool contains(const Vector3 &position_m) const
Test whether a position is contained within this goal's volume.
Definition goal_structure.hpp:76
AcceptedType accepted_type
Filter for accepted gamepiece types (allows selective scoring).
Definition goal_structure.hpp:61
std::function< bool(const Vector3 &)> custom_velocity_validator
Optional custom validator for velocity constraints during scoring.
Definition goal_structure.hpp:69
Vector3 center_m
Goal center position in world coordinates (meters).
Definition goal_structure.hpp:54
AcceptedType
Supported gamepiece type filters for scoring validation.
Definition goal_structure.hpp:42
@ kAny
Definition goal_structure.hpp:43
@ kCustom4
Definition goal_structure.hpp:48
@ kCustom1
Definition goal_structure.hpp:45
@ kCustom2
Definition goal_structure.hpp:46
@ kCustom3
Definition goal_structure.hpp:47
@ kBall
Definition goal_structure.hpp:44
3D vector utility used throughout JSim physics.
Definition vector.hpp:22
double z
Z component.
Definition vector.hpp:28
double x
X component.
Definition vector.hpp:24
double y
Y component.
Definition vector.hpp:26