Skip to content

Commit

Permalink
Merge branch 'main' into gz_cmake_project
Browse files Browse the repository at this point in the history
  • Loading branch information
chapulina authored Jun 16, 2022
2 parents dd7f14b + e91782b commit e243905
Show file tree
Hide file tree
Showing 11 changed files with 636 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ but with improved human-readability..
- Header files under `ignition/...` are deprecated and will be removed in future versions.
Use `gz/...` instead.

- **sdf/Types.hh**: The `Inertia` class has been deprecated. Please use the
`Inertial` class in the `gz-math` library.

## libsdformat 11.x to 12.0

An error is now emitted instead of a warning for a file containing more than
Expand Down
2 changes: 1 addition & 1 deletion include/sdf/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace sdf
};

/// \brief A class for inertial information about a link.
class SDFORMAT_VISIBLE Inertia
class SDFORMAT_VISIBLE SDF_DEPRECATED(13) Inertia
{
public: double mass;
};
Expand Down
4 changes: 4 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pybind11_add_module(sdformat SHARED
src/sdf/pyForceTorque.cc
src/sdf/pyFrame.cc
src/sdf/pyGeometry.cc
src/sdf/pyHeightmap.cc
src/sdf/pyIMU.cc
src/sdf/pyJoint.cc
src/sdf/pyJointAxis.cc
Expand All @@ -70,6 +71,7 @@ pybind11_add_module(sdformat SHARED
src/sdf/pyRoot.cc
src/sdf/pySemanticPose.cc
src/sdf/pySensor.cc
src/sdf/pySky.cc
src/sdf/pySphere.cc
src/sdf/pySurface.cc
src/sdf/pyVisual.cc
Expand Down Expand Up @@ -106,6 +108,7 @@ if (BUILD_TESTING)
pyForceTorque_TEST
pyFrame_TEST
pyGeometry_TEST
pyHeightmap_TEST
pyIMU_TEST
pyJoint_TEST
pyJointAxis_TEST
Expand All @@ -125,6 +128,7 @@ if (BUILD_TESTING)
pyRoot_TEST
pySemanticPose_TEST
pySensor_TEST
pySky_TEST
pySphere_TEST
pySurface_TEST
pyVisual_TEST
Expand Down
6 changes: 6 additions & 0 deletions python/src/sdf/_ignition_sdformat_pybind11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pyForceTorque.hh"
#include "pyFrame.hh"
#include "pyGeometry.hh"
#include "pyHeightmap.hh"
#include "pyIMU.hh"
#include "pyJoint.hh"
#include "pyJointAxis.hh"
Expand All @@ -48,6 +49,7 @@
#include "pyRoot.hh"
#include "pySemanticPose.hh"
#include "pySensor.hh"
#include "pySky.hh"
#include "pySphere.hh"
#include "pySurface.hh"
#include "pyVisual.hh"
Expand All @@ -71,6 +73,9 @@ PYBIND11_MODULE(sdformat, m) {
sdf::python::defineFrame(m);
sdf::python::defineFriction(m);
sdf::python::defineGeometry(m);
sdf::python::defineHeightmap(m);
sdf::python::defineHeightmapBlend(m);
sdf::python::defineHeightmapTexture(m);
sdf::python::defineIMU(m);
sdf::python::defineJoint(m);
sdf::python::defineJointAxis(m);
Expand All @@ -92,6 +97,7 @@ PYBIND11_MODULE(sdformat, m) {
sdf::python::defineRoot(m);
sdf::python::defineSemanticPose(m);
sdf::python::defineSensor(m);
sdf::python::defineSky(m);
sdf::python::defineSphere(m);
sdf::python::defineSurface(m);
sdf::python::defineVisual(m);
Expand Down
132 changes: 132 additions & 0 deletions python/src/sdf/pyHeightmap.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "pyHeightmap.hh"

#include <pybind11/pybind11.h>

#include "sdf/Heightmap.hh"

using namespace pybind11::literals;

namespace sdf
{
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {
namespace python
{
/////////////////////////////////////////////////
void defineHeightmapTexture(pybind11::object module)
{
pybind11::class_<sdf::HeightmapTexture>(module, "HeightmapTexture")
.def(pybind11::init<>())
.def(pybind11::init<sdf::HeightmapTexture>())
.def("size", &sdf::HeightmapTexture::Size,
"Get the heightmap texture's size.")
.def("set_size", &sdf::HeightmapTexture::SetSize,
"Set the size of the texture in meters.")
.def("diffuse", &sdf::HeightmapTexture::Diffuse,
"Get the heightmap texture's diffuse map.")
.def("set_diffuse", &sdf::HeightmapTexture::SetDiffuse,
"Set the filename of the diffuse map.")
.def("normal", &sdf::HeightmapTexture::Normal,
"Get the heightmap texture's normal map.")
.def("set_normal", &sdf::HeightmapTexture::SetNormal,
"Set the filename of the normal map.")
.def("__copy__", [](const sdf::HeightmapTexture &self) {
return sdf::HeightmapTexture(self);
})
.def("__deepcopy__", [](const sdf::HeightmapTexture &self, pybind11::dict) {
return sdf::HeightmapTexture(self);
}, "memo"_a);
}

/////////////////////////////////////////////////
void defineHeightmapBlend(pybind11::object module)
{
pybind11::class_<sdf::HeightmapBlend>(module, "HeightmapBlend")
.def(pybind11::init<>())
.def(pybind11::init<sdf::HeightmapBlend>())
.def("min_height", &sdf::HeightmapBlend::MinHeight,
"Get the heightmap blend's minimum height.")
.def("set_min_height", &sdf::HeightmapBlend::SetMinHeight,
"Set the minimum height of the blend in meters.")
.def("fade_distance", &sdf::HeightmapBlend::FadeDistance,
"Get the heightmap blend's fade distance.")
.def("set_fade_distance", &sdf::HeightmapBlend::SetFadeDistance,
"Set the distance over which the blend occurs.")
.def("__copy__", [](const sdf::HeightmapBlend &self) {
return sdf::HeightmapBlend(self);
})
.def("__deepcopy__", [](const sdf::HeightmapBlend &self, pybind11::dict) {
return sdf::HeightmapBlend(self);
}, "memo"_a);
}

/////////////////////////////////////////////////
void defineHeightmap(pybind11::object module)
{
pybind11::class_<sdf::Heightmap>(module, "Heightmap")
.def(pybind11::init<>())
.def(pybind11::init<sdf::Heightmap>())
.def("uri", &sdf::Heightmap::Uri,
"Get the heightmap's URI.")
.def("set_uri", &sdf::Heightmap::SetUri,
"Set the URI to a grayscale image.")
.def("file_path", &sdf::Heightmap::FilePath,
"The path to the file where this element was loaded from.")
.def("set_file_path", &sdf::Heightmap::SetFilePath,
"Set the path to the file where this element was loaded from.")
.def("size", &sdf::Heightmap::Size,
"Get the heightmap's scaling factor.")
.def("set_size", &sdf::Heightmap::SetSize,
"Set the heightmap's scaling factor. Defaults to 1x1x1.")
.def("position", &sdf::Heightmap::Position,
"Get the heightmap's position offset.")
.def("set_position", &sdf::Heightmap::SetPosition,
"Set the heightmap's position offset.")
.def("use_terrain_paging", &sdf::Heightmap::UseTerrainPaging,
"Get whether the heightmap uses terrain paging.")
.def("set_use_terrain_paging", &sdf::Heightmap::SetUseTerrainPaging,
"Set whether the heightmap uses terrain paging. Defaults to false.")
.def("sampling", &sdf::Heightmap::Sampling,
"Get the heightmap's sampling per datum.")
.def("set_sampling", &sdf::Heightmap::SetSampling,
"Set the heightmap's sampling. Defaults to 1.")
.def("texture_count", &sdf::Heightmap::TextureCount,
"Get the number of heightmap textures.")
.def("texture_by_index", &sdf::Heightmap::TextureByIndex,
pybind11::return_value_policy::reference,
"Get a heightmap texture based on an index.")
.def("add_texture", &sdf::Heightmap::AddTexture,
"Add a heightmap texture.")
.def("blend_count", &sdf::Heightmap::BlendCount,
"Get the number of heightmap blends.")
.def("blend_by_index", &sdf::Heightmap::BlendByIndex,
pybind11::return_value_policy::reference,
"Get a heightmap blend based on an index.")
.def("add_blend", &sdf::Heightmap::AddBlend,
"Add a heightmap blend.")
.def("__copy__", [](const sdf::Heightmap &self) {
return sdf::Heightmap(self);
})
.def("__deepcopy__", [](const sdf::Heightmap &self, pybind11::dict) {
return sdf::Heightmap(self);
}, "memo"_a);
}
} // namespace python
} // namespace SDF_VERSION_NAMESPACE
} // namespace sdf
53 changes: 53 additions & 0 deletions python/src/sdf/pyHeightmap.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef SDFORMAT_PYTHON_HEIGHTMAP_HH_
#define SDFORMAT_PYTHON_HEIGHTMAP_HH_

#include <pybind11/pybind11.h>

#include "sdf/Heightmap.hh"

#include "sdf/config.hh"

namespace sdf
{
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {
namespace python
{
/// Define a pybind11 wrapper for an sdf::HeightmapTexture
/**
* \param[in] module a pybind11 module to add the definition to
*/
void defineHeightmapTexture(pybind11::object module);

/// Define a pybind11 wrapper for an sdf::HeightmapBlend
/**
* \param[in] module a pybind11 module to add the definition to
*/
void defineHeightmapBlend(pybind11::object module);

/// Define a pybind11 wrapper for an sdf::Heightmap
/**
* \param[in] module a pybind11 module to add the definition to
*/
void defineHeightmap(pybind11::object module);
} // namespace python
} // namespace SDF_VERSION_NAMESPACE
} // namespace sdf

#endif // SDFORMAT_PYTHON_HEIGHTMAP_HH_
78 changes: 78 additions & 0 deletions python/src/sdf/pySky.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "pySky.hh"

#include <pybind11/pybind11.h>

#include "sdf/Sky.hh"

using namespace pybind11::literals;

namespace sdf
{
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {
namespace python
{
/////////////////////////////////////////////////
void defineSky(pybind11::object module)
{
pybind11::class_<sdf::Sky>(module, "Sky")
.def(pybind11::init<>())
.def(pybind11::init<sdf::Sky>())
.def("time", &sdf::Sky::Time,
"Get time of day [0..24]")
.def("set_time", &sdf::Sky::SetTime,
"Set time of day")
.def("sunrise", &sdf::Sky::Sunrise,
"Get sunrise time")
.def("set_sunrise", &sdf::Sky::SetSunrise,
"Set Sunrise time")
.def("sunset", &sdf::Sky::Sunset,
"Get sunset time")
.def("set_sunset", &sdf::Sky::SetSunset,
"Set Sunset time")
.def("cloud_speed", &sdf::Sky::CloudSpeed,
"Get cloud speed")
.def("set_cloud_speed", &sdf::Sky::SetCloudSpeed,
"Set cloud speed")
.def("cloud_direction", &sdf::Sky::CloudDirection,
"Get cloud direction angle (angle around up axis)")
.def("set_cloud_direction", &sdf::Sky::SetCloudDirection,
"Set cloud direction angle (angle around up axis)")
.def("cloud_humidity", &sdf::Sky::CloudHumidity,
"Get cloud humidity.")
.def("set_cloud_humidity", &sdf::Sky::SetCloudHumidity,
"Set cloud humidity")
.def("cloud_mean_size", &sdf::Sky::CloudMeanSize,
"Get cloud mean size")
.def("set_cloud_mean_size", &sdf::Sky::SetCloudMeanSize,
"Set cloud mean size")
.def("cloud_ambient", &sdf::Sky::CloudAmbient,
"Get cloud ambient color")
.def("set_cloud_ambient", &sdf::Sky::SetCloudAmbient,
"Set cloud ambient color")
.def("__copy__", [](const sdf::Sky &self) {
return sdf::Sky(self);
})
.def("__deepcopy__", [](const sdf::Sky &self, pybind11::dict) {
return sdf::Sky(self);
}, "memo"_a);
}
} // namespace python
} // namespace SDF_VERSION_NAMESPACE
} // namespace sdf
41 changes: 41 additions & 0 deletions python/src/sdf/pySky.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef SDFORMAT_PYTHON_SKY_HH_
#define SDFORMAT_PYTHON_SKY_HH_

#include <pybind11/pybind11.h>

#include "sdf/Sky.hh"

#include "sdf/config.hh"

namespace sdf
{
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {
namespace python
{
/// Define a pybind11 wrapper for an sdf::Sky
/**
* \param[in] module a pybind11 module to add the definition to
*/
void defineSky(pybind11::object module);
} // namespace python
} // namespace SDF_VERSION_NAMESPACE
} // namespace sdf

#endif // SDFORMAT_PYTHON_SCENE_HH_
Loading

0 comments on commit e243905

Please sign in to comment.