96118da08b
Before: ``` Simulation time : 2.24 s Steps per second : 4472 Realtime factor : 8.94 x Time per step : 223.6 µs Newton iters / step : 2.47 Contacts / step : 3.37 Constraints / step : 13.49 Degrees of freedom : 12 Dynamic memory usage : 0.2% of 14M ``` After: ``` Simulation time : 1.71 s Steps per second : 5854 Realtime factor : 11.71 x Time per step : 170.8 µs Newton iters / step : 2.19 Contacts / step : 3.45 Constraints / step : 13.79 Degrees of freedom : 12 Dynamic memory usage : 0.2% of 14M ``` PiperOrigin-RevId: 781075182 Change-Id: Ie509047ff581ab0df4b10bbd394c27d350ab5a13
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
// Copyright 2022 DeepMind Technologies Limited
|
|
//
|
|
// 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 MUJOCO_PLUGIN_SDF_SDFLIB_H_
|
|
#define MUJOCO_PLUGIN_SDF_SDFLIB_H_
|
|
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
#include <mujoco/mjdata.h>
|
|
#include <mujoco/mjmodel.h>
|
|
#include <mujoco/mjtnum.h>
|
|
#include <mujoco/mjvisualize.h>
|
|
#include "sdf.h"
|
|
|
|
namespace mujoco::plugin::sdf {
|
|
class SdfLib {
|
|
public:
|
|
// Creates a new SdfLib instance or returns null on failure.
|
|
static std::optional<SdfLib> Create(const mjModel* m, mjData* d,
|
|
int instance);
|
|
SdfLib(SdfLib&&) = default;
|
|
~SdfLib() = default;
|
|
|
|
void Reset();
|
|
void Visualize(const mjModel* m, mjData* d, const mjvOption* opt,
|
|
mjvScene* scn, int instance);
|
|
void Compute(const mjModel* m, mjData* d, int instance);
|
|
mjtNum Distance(const mjtNum point[3]) const;
|
|
void Gradient(mjtNum grad[3], const mjtNum point[3]) const;
|
|
|
|
static void RegisterPlugin();
|
|
|
|
private:
|
|
SdfLib(const mjModel* m, int meshid);
|
|
SdfVisualizer visualizer_;
|
|
std::vector<double> sdf_coeff_;
|
|
|
|
mjtNum box_[6];
|
|
std::vector<mjtNum> oct_aabb_;
|
|
std::vector<int> oct_child_;
|
|
};
|
|
|
|
} // namespace mujoco::plugin::sdf
|
|
|
|
#endif // MUJOCO_PLUGIN_SDF_SDFLIB_H_
|