Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: Import gz.math at startup to fix #1129 #1130

Merged
merged 4 commits into from
Sep 30, 2022
Merged
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
7 changes: 7 additions & 0 deletions python/src/sdf/_gz_sdformat_pybind11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <gz/math/config.hh>

#include "pyAirPressure.hh"
#include "pyAltimeter.hh"
Expand Down Expand Up @@ -65,6 +66,12 @@
PYBIND11_MODULE(BINDINGS_MODULE_NAME, m) {
m.doc() = "sdformat Python Library.";

// Import the gz.math library to automatically add the type conversions
// this module requires to pass mathematical types to python code.
std::string gzMathModule =
std::string("gz.math") + std::to_string(GZ_MATH_MAJOR_VERSION);
pybind11::module::import(gzMathModule.c_str());

sdf::python::defineAirPressure(m);
sdf::python::defineAltimeter(m);
sdf::python::defineAtmosphere(m);
Expand Down
1 change: 0 additions & 1 deletion python/test/pyAirPressure_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gz.math7 import Vector3d
from sdformat13 import AirPressure, Noise
import sdformat13 as sdf
import unittest
Expand Down
1 change: 0 additions & 1 deletion python/test/pyAltimeter_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gz.math7 import Vector3d
from sdformat13 import Altimeter, Noise
import sdformat13 as sdf
import unittest
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyAtmosphere_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gz.math7 import Pose3d, Temperature
from gz.math7 import Temperature
from sdformat13 import Atmosphere
import sdformat13 as sdf
import unittest
Expand Down
2 changes: 0 additions & 2 deletions python/test/pyCapsule_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import copy

from gz.math7 import Vector3d, Capsuled

import math

from sdformat13 import Capsule
Expand Down
2 changes: 0 additions & 2 deletions python/test/pyCylinder_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import copy

from gz.math7 import Vector3d

import math

from sdformat13 import Cylinder
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyEllipsoid_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Vector3d, Ellipsoidd
from gz.math7 import Vector3d
import math
from sdformat13 import Ellipsoid
import unittest
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyJointAxis_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Pose3d, Vector3d
from gz.math7 import Vector3d
from sdformat13 import JointAxis, Error, SDFErrorsException
import math
import unittest
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyLidar_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Angle, Pose3d, Vector3d, Helpers
from gz.math7 import Angle, Helpers
from sdformat13 import Lidar, Error, Noise
import math
import unittest
Expand Down
1 change: 0 additions & 1 deletion python/test/pyMagnetometer_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import copy
from gz.math7 import Pose3d
from sdformat13 import Magnetometer, Noise
import sdformat13 as sdf
import unittest
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyModel_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Pose3d, Vector3d
from gz.math7 import Pose3d
from sdformat13 import (Plugin, Model, Joint, Link, Error, Frame, SemanticPose,
SDFErrorsException)
import sdformat13 as sdf
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyPlane_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import copy
from sdformat13 import Plane
from gz.math7 import Vector3d, Vector2d, Planed
from gz.math7 import Vector3d, Vector2d
import unittest


Expand Down
2 changes: 1 addition & 1 deletion python/test/pyRoot_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Vector3d, Pose3d
from gz.math7 import Pose3d
from sdformat13 import (Error, Model, Light, Root, SDF_VERSION,
SDFErrorsException, SDF_PROTOCOL_VERSION, World)
import sdformat13 as sdf
Expand Down
1 change: 0 additions & 1 deletion python/test/pySphere_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import copy
from gz.math7 import Sphered
import math
from sdformat13 import Sphere
import unittest
Expand Down
2 changes: 1 addition & 1 deletion python/test/pyWorld_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from gz.math7 import Color, Pose3d, Vector3d, SphericalCoordinates
from gz.math7 import Color, Vector3d, SphericalCoordinates
from sdformat13 import Atmosphere, Gui, Physics, Plugin, Error, Frame, Light, Model, Scene, World
import sdformat13 as sdf
import unittest
Expand Down