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
20 changes: 18 additions & 2 deletions src/software/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
#include "software/constants.h"
#include "software/estop/threaded_estop_reader.h"
#include "software/geom/algorithms/contains.h"
#include "software/geom/algorithms/intersection.h"
#include "software/geom/circle.h"
#include "software/geom/convex_polygon.h"
#include "software/geom/point.h"
#include "software/geom/polygon.h"
#include "software/geom/ray.h"
#include "software/geom/rectangle.h"
#include "software/geom/segment.h"
#include "software/geom/vector.h"
Expand Down Expand Up @@ -197,6 +199,8 @@ PYBIND11_MODULE(python_bindings, m)

py::class_<Angle>(m, "Angle")
.def(py::init<>())
.def(py::self - Angle())
.def(py::self > Angle())
.def_static("fromRadians", &Angle::fromRadians)
.def_static("fromDegrees", &Angle::fromDegrees)
.def("toRadians", &Angle::toRadians)
Expand Down Expand Up @@ -244,6 +248,8 @@ PYBIND11_MODULE(python_bindings, m)
.def("lengthSquared", &Segment::lengthSquared)
.def("reverse", &Segment::reverse);

py::class_<Ray>(m, "Ray").def(py::init<Point, Vector>());

py::class_<Circle>(m, "Circle")
.def(py::init<Point, double>())
// Overloaded
Expand Down Expand Up @@ -322,6 +328,8 @@ PYBIND11_MODULE(python_bindings, m)
m.def("contains", py::overload_cast<const Rectangle&, const Point&>(&contains));
m.def("contains", py::overload_cast<const Stadium&, const Point&>(&contains));

m.def("intersection", py::overload_cast<const Ray&, const Segment&>(&intersection));

py::class_<Robot>(m, "Robot")
.def(py::init<unsigned, Point&, Vector&, Angle&, Angle&, Timestamp&>())
.def(py::init<TbotsProto::Robot>())
Expand All @@ -347,7 +355,12 @@ PYBIND11_MODULE(python_bindings, m)

py::class_<Ball>(m, "Ball")
.def(py::init<Point, Vector, Timestamp>())
.def("position", &Ball::position);
.def("position", &Ball::position)
.def("velocity", &Ball::velocity)
.def("hasBallBeenKicked", &Ball::hasBallBeenKicked,
py::arg("expected_kick_direction"), py::arg("min_kick_speed") = 0.5,
py::arg("min_kick_speed") = Angle::fromDegrees(20))
.def("hasBallBeenKicked", &Ball::hasBallBeenKicked);

// https://pybind11.readthedocs.io/en/stable/classes.html
py::class_<Field>(m, "Field")
Expand All @@ -368,6 +381,8 @@ PYBIND11_MODULE(python_bindings, m)
.def("defenseAreaXLength", &Field::defenseAreaXLength)
.def("friendlyDefenseArea", &Field::friendlyDefenseArea)
.def("enemyDefenseArea", &Field::enemyDefenseArea)
.def("pointInFriendlyHalf", &Field::pointInFriendlyHalf)
.def("pointInEnemyHalf", &Field::pointInEnemyHalf)
.def("friendlyHalf", &Field::friendlyHalf)
.def("friendlyPositiveYQuadrant", &Field::friendlyPositiveYQuadrant)
.def("friendlyNegativeYQuadrant", &Field::friendlyNegativeYQuadrant)
Expand All @@ -388,7 +403,8 @@ PYBIND11_MODULE(python_bindings, m)
.def("enemyCornerNeg", &Field::enemyCornerNeg)
.def("friendlyGoalpostPos", &Field::friendlyGoalpostPos)
.def("friendlyGoalpostNeg", &Field::friendlyGoalpostNeg)
.def("enemyGoalpostPos", &Field::enemyGoalpostPos);
.def("enemyGoalpostPos", &Field::enemyGoalpostPos)
.def("enemyGoalpostNeg", &Field::enemyGoalpostNeg);

py::class_<World>(m, "World")
.def(py::init<Field, Ball, Team, Team>())
Expand Down
1 change: 1 addition & 0 deletions src/software/thunderscope/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ py_library(
"//software/thunderscope/gl/layers:gl_cost_vis_layer",
"//software/thunderscope/gl/layers:gl_debug_shapes_layer",
"//software/thunderscope/gl/layers:gl_draw_polygon_obstacle",
"//software/thunderscope/gl/layers:gl_fs_stats_layer",
"//software/thunderscope/gl/layers:gl_max_dribble_layer",
"//software/thunderscope/gl/layers:gl_movement_field_test_layer",
"//software/thunderscope/gl/layers:gl_obstacle_layer",
Expand Down
13 changes: 13 additions & 0 deletions src/software/thunderscope/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,19 @@ class RuntimeManagerConstants:
DEFAULT_BINARY_NAME = "Current Fullsystem"
EXTERNAL_RUNTIMES_PATH = "/opt/tbotspython/external_runtimes"
RUNTIME_CONFIG_PATH = f"{EXTERNAL_RUNTIMES_PATH}/runtime_config.toml"

RUNTIME_STATS_DIRECTORY_PATH = "/tmp/tbots/stats"
RUNTIME_FRIENDLY_STATS_FILE = "blue.toml"
RUNTIME_ENEMY_FROM_FRIENDLY_STATS_FILE = "yellow_from_blue.toml"
RUNTIME_ENEMY_STATS_FILE = "yellow.toml"
RUNTIME_FRIENDLY_FROM_ENEMY_STATS_FILE = "blue_from_yellow.toml"

RUNTIME_STATS_SCORE_KEY = "goals"
RUNTIME_STATS_RED_CARDS_KEY = "red_cards"
RUNTIME_STATS_YELLOW_CARDS_KEY = "yellow_cards"
RUNTIME_STATS_SHOTS_ON_NET = "shots_on_net"
RUNTIME_STATS_SHOTS_BLOCKED = "shots_blocked"

RELEASES_URL = "https://api.github.com/repos/UBC-Thunderbots/Software/releases"
DOWNLOAD_URL = "https://github.com/UBC-Thunderbots/Software/releases/download/"
MAX_RELEASES_FETCHED = 5
9 changes: 9 additions & 0 deletions src/software/thunderscope/gl/layers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ py_library(
],
)

py_library(
name = "gl_fs_stats_layer",
srcs = ["gl_fs_stats_layer.py"],
deps = [
":gl_layer",
requirement("pyqtgraph"),
],
)

py_library(
name = "gl_world_layer",
srcs = ["gl_world_layer.py"],
Expand Down
Loading
Loading