mujoco-react 8.9.0 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -228,14 +228,14 @@ Use control groups when a robot's actuator order does not match a simple `qpos[0
|
|
|
228
228
|
|
|
229
229
|
```tsx
|
|
230
230
|
import { useRef } from "react";
|
|
231
|
-
import { resolveControlGroup, useBeforePhysicsStep } from "mujoco-react";
|
|
231
|
+
import { resolveControlGroup, RobotSites, useBeforePhysicsStep } from "mujoco-react";
|
|
232
232
|
import type { ControlGroupInfo } from "mujoco-react";
|
|
233
233
|
|
|
234
234
|
function HoldTcpPose() {
|
|
235
235
|
const armRef = useRef<ControlGroupInfo | null>(null);
|
|
236
236
|
|
|
237
237
|
useBeforePhysicsStep((model, data) => {
|
|
238
|
-
armRef.current ??= resolveControlGroup(model, { siteName:
|
|
238
|
+
armRef.current ??= resolveControlGroup(model, { siteName: RobotSites.franka.tcp });
|
|
239
239
|
if (!armRef.current) return;
|
|
240
240
|
|
|
241
241
|
armRef.current.writeCtrl(data, armRef.current.readQpos(data));
|
|
@@ -798,7 +798,9 @@ await moveCameraTo(
|
|
|
798
798
|
Read sensor values by name. Returns a `SensorHandle` with `read()`, `dim`, and `name`:
|
|
799
799
|
|
|
800
800
|
```tsx
|
|
801
|
-
|
|
801
|
+
import { RobotSensors, useSensor } from "mujoco-react";
|
|
802
|
+
|
|
803
|
+
const force = useSensor(RobotSensors.franka.force_sensor);
|
|
802
804
|
// force.read() -> Float64Array, force.dim -> number
|
|
803
805
|
```
|
|
804
806
|
|
|
@@ -823,7 +825,9 @@ const { position, velocity } = useJointState("joint1");
|
|
|
823
825
|
Read/write actuator control by name. Returns a `CtrlHandle` with `read()`, `write()`, `name`, and `range`:
|
|
824
826
|
|
|
825
827
|
```tsx
|
|
826
|
-
|
|
828
|
+
import { RobotActuators, useCtrl } from "mujoco-react";
|
|
829
|
+
|
|
830
|
+
const gripper = useCtrl(RobotActuators.franka.gripper);
|
|
827
831
|
// gripper.read() -> number, gripper.write(0.04), gripper.range -> [min, max]
|
|
828
832
|
```
|
|
829
833
|
|
|
@@ -843,11 +847,13 @@ useContactEvents("block_1", {
|
|
|
843
847
|
Map keyboard keys to actuators:
|
|
844
848
|
|
|
845
849
|
```tsx
|
|
850
|
+
import { RobotActuators, useKeyboardTeleop } from "mujoco-react";
|
|
851
|
+
|
|
846
852
|
useKeyboardTeleop({
|
|
847
853
|
bindings: {
|
|
848
854
|
"w": { actuator: "forward", delta: 0.1 },
|
|
849
855
|
"s": { actuator: "forward", delta: -0.1 },
|
|
850
|
-
"v": { actuator:
|
|
856
|
+
"v": { actuator: RobotActuators.franka.gripper, toggle: [0, 0.04] },
|
|
851
857
|
},
|
|
852
858
|
});
|
|
853
859
|
```
|