This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixes #695
- Loading branch information
Showing
7 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
--- | ||
|
||
extra_includes: | ||
- wpi/sendable/SendableBuilder.h | ||
|
||
classes: | ||
Mechanism2d: | ||
ignored_bases: | ||
- wpi::SendableHelper<Mechanism2d> | ||
methods: | ||
Mechanism2d: | ||
GetRoot: | ||
return_value_policy: reference_internal | ||
SetBackgroundColor: | ||
InitSendable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
--- | ||
|
||
extra_includes: | ||
- frc/smartdashboard/MechanismLigament2d.h | ||
|
||
classes: | ||
MechanismObject2d: | ||
force_type_casters: | ||
- units::degree_t | ||
attributes: | ||
m_mutex: | ||
ignore: true | ||
methods: | ||
GetName: | ||
Append: | ||
ignore: true | ||
MechanismObject2d: | ||
ignore: true | ||
UpdateEntries: | ||
|
||
# keep this in sync with MechanismRoot2d.yml | ||
inline_code: | | ||
cls_MechanismObject2d | ||
.def("appendLigament", [](MechanismObject2d *self, | ||
std::string_view name, double length, units::degree_t angle, | ||
double lineWidth, const frc::Color8Bit& color) { | ||
return self->Append<MechanismLigament2d>(name, length, angle, lineWidth, color); | ||
}, | ||
py::arg("name"), py::arg("length"), py::arg("angle"), | ||
py::arg("lineWidth") = 6, py::arg("color") = frc::Color8Bit{235, 137, 52}, | ||
"Append a ligament node", | ||
py::return_value_policy::reference_internal) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
--- | ||
|
||
extra_includes: | ||
- frc/smartdashboard/MechanismLigament2d.h | ||
|
||
classes: | ||
MechanismRoot2d: | ||
force_type_casters: | ||
- units::degree_t | ||
methods: | ||
MechanismRoot2d: | ||
ignore: true | ||
SetPosition: | ||
|
||
# keep this in sync with MechanismRoot2d.yml | ||
inline_code: | | ||
cls_MechanismRoot2d | ||
.def("getName", [](MechanismRoot2d *self) { return self->GetName(); }, release_gil()) | ||
.def("appendLigament", [](MechanismRoot2d *self, | ||
std::string_view name, double length, units::degree_t angle, | ||
double lineWidth, const frc::Color8Bit& color) { | ||
return self->Append<MechanismLigament2d>(name, length, angle, lineWidth, color); | ||
}, | ||
py::arg("name"), py::arg("length"), py::arg("angle"), | ||
py::arg("lineWidth") = 6, py::arg("color") = frc::Color8Bit{235, 137, 52}, | ||
release_gil(), "Append a ligament node", | ||
py::return_value_policy::reference_internal) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from wpilib import Mechanism2d | ||
|
||
|
||
def test_create_mechanism(): | ||
m = Mechanism2d(100, 100) | ||
r1 = m.getRoot("r1", 10, 10) | ||
l1 = r1.appendLigament("l1", 4, 3) | ||
l2 = l1.appendLigament("l2", 4, 3) | ||
assert l2 is not None | ||
|
||
# TODO... check that they do something? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters