Renamed Elasticity to Cable and libcable to libelasticity for consistency.
PiperOrigin-RevId: 485642970 Change-Id: I279df4233963a6e514459e55a9c2d36d975da92c
This commit is contained in:
committed by
Copybara-Service
parent
c83be2bc05
commit
9833f912c1
@@ -150,12 +150,12 @@ jobs:
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
working-directory: build
|
||||
run: mkdir -p ${{ matrix.tmpdir }}/mujoco_install/plugin &&
|
||||
cp lib/libcable.* ${{ matrix.tmpdir }}/mujoco_install/plugin
|
||||
cp lib/libelasticity.* ${{ matrix.tmpdir }}/mujoco_install/plugin
|
||||
- name: Copy plugins (Windows)
|
||||
if: ${{ runner.os == 'Windows' }}
|
||||
working-directory: build
|
||||
run: mkdir -p ${{ matrix.tmpdir }}/mujoco_install/plugin &&
|
||||
cp bin/Release/cable.dll ${{ matrix.tmpdir }}/mujoco_install/plugin
|
||||
cp bin/Release/elasticity.dll ${{ matrix.tmpdir }}/mujoco_install/plugin
|
||||
- name: Configure samples
|
||||
working-directory: sample
|
||||
run: >
|
||||
|
||||
@@ -29,6 +29,7 @@ General
|
||||
- Added :ref:`mju_fill`, :ref:`mju_symmetrize` and :ref:`mju_eye` utility functions.
|
||||
- Added :at:`gravcomp` attribute to :ref:`body<body>`, implementing gravity compensation and bouyancy.
|
||||
See `balloons.xml <https://github.com/deepmind/mujoco/tree/main/model/balloons/balloons.xml>`_ example model.
|
||||
- Renamed the cable plugin library to elasticity.
|
||||
|
||||
Version 2.3.0 (October 18, 2022)
|
||||
--------------------------------
|
||||
|
||||
@@ -22,19 +22,19 @@ set(MUJOCO_ELASTICITY_SRCS
|
||||
cable.h
|
||||
)
|
||||
|
||||
add_library(cable SHARED)
|
||||
target_sources(cable PRIVATE ${MUJOCO_ELASTICITY_SRCS})
|
||||
target_include_directories(cable PRIVATE ${MUJOCO_ELASTICITY_INCLUDE})
|
||||
target_link_libraries(cable PRIVATE mujoco)
|
||||
add_library(elasticity SHARED)
|
||||
target_sources(elasticity PRIVATE ${MUJOCO_ELASTICITY_SRCS})
|
||||
target_include_directories(elasticity PRIVATE ${MUJOCO_ELASTICITY_INCLUDE})
|
||||
target_link_libraries(elasticity PRIVATE mujoco)
|
||||
target_compile_options(
|
||||
cable
|
||||
elasticity
|
||||
PRIVATE ${AVX_COMPILE_OPTIONS}
|
||||
${MUJOCO_MACOS_COMPILE_OPTIONS}
|
||||
${EXTRA_COMPILE_OPTIONS}
|
||||
${MUJOCO_CXX_FLAGS}
|
||||
)
|
||||
target_link_options(
|
||||
cable
|
||||
elasticity
|
||||
PRIVATE
|
||||
${MUJOCO_MACOS_LINK_OPTIONS}
|
||||
${EXTRA_LINK_OPTIONS}
|
||||
|
||||
@@ -89,10 +89,10 @@ bool CheckAttr(const char* name, const mjModel* m, int instance) {
|
||||
|
||||
|
||||
// factory function
|
||||
std::optional<Elasticity> Elasticity::Create(
|
||||
std::optional<Cable> Cable::Create(
|
||||
const mjModel* m, mjData* d, int instance) {
|
||||
if (CheckAttr("twist", m, instance) && CheckAttr("bend", m, instance)) {
|
||||
return Elasticity(m, d, instance);
|
||||
return Cable(m, d, instance);
|
||||
} else {
|
||||
mju_warning("Invalid parameter specification in cable plugin");
|
||||
return std::nullopt;
|
||||
@@ -100,7 +100,7 @@ std::optional<Elasticity> Elasticity::Create(
|
||||
}
|
||||
|
||||
// plugin constructor
|
||||
Elasticity::Elasticity(const mjModel* m, mjData* d, int instance) {
|
||||
Cable::Cable(const mjModel* m, mjData* d, int instance) {
|
||||
// parameters were validated by the factor function
|
||||
std::string flat = mj_getPluginConfig(m, instance, "flat");
|
||||
mjtNum G = strtod(mj_getPluginConfig(m, instance, "twist"), nullptr);
|
||||
@@ -173,7 +173,7 @@ Elasticity::Elasticity(const mjModel* m, mjData* d, int instance) {
|
||||
}
|
||||
}
|
||||
|
||||
void Elasticity::Compute(const mjModel* m, mjData* d, int instance) {
|
||||
void Cable::Compute(const mjModel* m, mjData* d, int instance) {
|
||||
for (int b = 0; b < n; b++) {
|
||||
// index into body array
|
||||
int i = i0 + b;
|
||||
@@ -234,20 +234,20 @@ mjPLUGIN_DYNAMIC_LIBRARY_INIT {
|
||||
plugin.nstate = +[](const mjModel* m, int instance) { return 0; };
|
||||
|
||||
plugin.init = +[](const mjModel* m, mjData* d, int instance) {
|
||||
auto elasticity_or_null = Elasticity::Create(m, d, instance);
|
||||
auto elasticity_or_null = Cable::Create(m, d, instance);
|
||||
if (!elasticity_or_null.has_value()) {
|
||||
return -1;
|
||||
}
|
||||
d->plugin_data[instance] = reinterpret_cast<uintptr_t>(
|
||||
new Elasticity(std::move(*elasticity_or_null)));
|
||||
new Cable(std::move(*elasticity_or_null)));
|
||||
return 0;
|
||||
};
|
||||
plugin.destroy = +[](mjData* d, int instance) {
|
||||
delete reinterpret_cast<Elasticity*>(d->plugin_data[instance]);
|
||||
delete reinterpret_cast<Cable*>(d->plugin_data[instance]);
|
||||
d->plugin_data[instance] = 0;
|
||||
};
|
||||
plugin.compute = +[](const mjModel* m, mjData* d, int instance, int type) {
|
||||
auto* elasticity = reinterpret_cast<Elasticity*>(d->plugin_data[instance]);
|
||||
auto* elasticity = reinterpret_cast<Cable*>(d->plugin_data[instance]);
|
||||
elasticity->Compute(m, d, instance);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
namespace mujoco::plugin::elasticity {
|
||||
|
||||
class Elasticity {
|
||||
class Cable {
|
||||
public:
|
||||
// Creates a new Elasticity instance (allocated with `new`) or
|
||||
// Creates a new Cable instance (allocated with `new`) or
|
||||
// returns null on failure.
|
||||
static std::optional<Elasticity> Create(const mjModel* m, mjData* d,
|
||||
static std::optional<Cable> Create(const mjModel* m, mjData* d,
|
||||
int instance);
|
||||
Elasticity(Elasticity&&) = default;
|
||||
~Elasticity() = default;
|
||||
Cable(Cable&&) = default;
|
||||
~Cable() = default;
|
||||
|
||||
void Compute(const mjModel* m, mjData* d, int instance);
|
||||
|
||||
@@ -44,7 +44,7 @@ class Elasticity {
|
||||
std::vector<mjtNum> omega0; // reference curvature (n x 3)
|
||||
|
||||
private:
|
||||
Elasticity(const mjModel* m, mjData* d, int instance);
|
||||
Cable(const mjModel* m, mjData* d, int instance);
|
||||
};
|
||||
|
||||
} // namespace mujoco::plugin::elasticity
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
mujoco_test(cable_test)
|
||||
target_link_libraries(cable_test fixture gmock cable)
|
||||
mujoco_test(elasticity_test)
|
||||
target_link_libraries(elasticity_test fixture gmock elasticity)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user