Skip to content

Dev - #155

Open
vikashplus wants to merge 76 commits into
mainfrom
dev
Open

Dev#155
vikashplus wants to merge 76 commits into
mainfrom
dev

Conversation

@vikashplus

Copy link
Copy Markdown
Owner

No description provided.

Wenxuan-Zhou and others added 19 commits April 20, 2023 00:03
Point cloud utility functions for mujoco [Draft]
… compliance. Envs now overwrite the correct _reset function. Gym compliance is now preserved across the defaulting envs
- gym/gymnasium compatibility doesn't port over when custom reset is provided
- we are now recommending a call to super().reset(**kwargs) to get the appropritae return type ensuring compatibility
np.product -> np.prod for np 2.0 compatibility
1. FEATURE: Explicitely marks the closure of the trace
2. BUGFIX: Introduces create_datum. create_dataset is updated and is now reserved for adding full datasets (shouldn't be edited later). If appending is needed first create_datum() and then follow it with repeated calls to append_datum().
3. BUGFIX: verify_type is stricter now. It goes beyond checking for root dtypes. It thoroughly checks for type, shapes, keys - even for nested structures. This implies that dict{datum} also needs to maintain its internal keys to support append leading to further consistency
4. FEATURE: Much like rendering of rgb datasets, now trace supports plotting of numerical datasets using a list(grp_keys)_ng and list(list(dataset_keys))_ng
5. Adds multiple tests to check for data consistency and plotting consistency
@andreh1111

andreh1111 commented May 7, 2026

Copy link
Copy Markdown
Collaborator
  • there are still a few obs, rwd, done, info = env.forward() / env.step() to be switched to obs, rwd, done, *_, info = env.forward() / env.step()
  • I think env.env should be replaced with env.unwrapped, e.g. in robohive/tutorials/ee_teleop.py
  • github actions are failing

vikashplus and others added 30 commits July 3, 2026 19:49
…rry complex data from the hardware into sensordata field of the model. Reply on sensordata field to create obs and obs_dicts
…e 0-d scalars

squeeze_dims() previously did a blanket np.squeeze(), which removed every
singleton dimension instead of just the (num_traj=1, horizon=1) wrapper
added by expand_dims(). Single-value observations (e.g. shape (1,)) were
squeezed all the way down to 0-d scalars, which then failed to concatenate
with other proprio/obs vectors in get_proprioception() and obsdict2obsvec().
Now only squeeze the leading axes that expand_dims actually added, leaving
real data dimensions (and pre-existing scalar rwd_dict entries) untouched.
Robot._resolve_data_ids caches each joint actuator's feedback address as
data_id into sim.data.qpos, but computed it with jnt_dofadr (the qvel
address).  qpos and qvel addresses coincide only while all preceding
joints are 1-DOF: any free/ball joint earlier in the model (e.g. a
manipulable object defined before the arm) shifts every subsequent
actuator's read by the qpos/qvel size difference (freejoint: 7 vs 6).

The stale read feeds the velocity limiter in process_actuator(), which
re-anchors each command to the wrong joint's position — in practice the
arm freezes at whatever pose keeps the misread error small.

Observed on anthrohive URDtriosPickPlace-v0 (box freejoint precedes the
UR5e): the arm ignored all position targets until this fix.
fix(robot): index actuator qpos reads with jnt_qposadr, not jnt_dofadr
…e base class. So there is no need to deviate away from the get_sensor() signature
- robohive/robot/hardware_base.py — new HARDWARE_REGISTRY/SENSOR_POSTPROCESS dicts and @register_hardware(type_name, sensor_postprocess=None) decorator (works on classes or factory functions).

- robohive/robot/hardware_franka.py, hardware_robotiq.py, hardware_optitrack.py, hardware_realsense.py, hardware_realsense_single.py, hardware_dynamixel.py — each now conforms to hardwareBase (adds recover(), fixes get_sensors() naming/keys to the neutral pos/vel/effort contract) and self-registers via @register_hardware(...).

- hardware_optitrack.py also had a pre-existing broken import (darwin.darwin_robot...) fixed to robohive.robot.hardware_base.

- hardware_dynamixel.py's Dynamixels was previously non-functional. Added a real adapter. It will need a consolidation effort to reconsile all dynamixel based robots
- hardware_init, hardware_get_sensors, hardware_apply_controls, hardware_close collapsed from hardcoded if/elif chains on interface['type'] into uniform registry-driven loops.
- New Robot.hardware_reset(reset_pos): a dedicated blocking/large-displacement reset path (each hardware class runs its own min-jerk trajectory), replacing the old hardware_apply_controls(..., is_reset=True) overload.
- Fixes a real bug where reset indexed by hdr_id (counts all actuators) while the ctrl vector it built only counted qpos-type actuators — silently misaligned on any device mixing qpos and tendon actuators (e.g. arm+gripper).
- get_visual_sensors() now duck-types hasattr(device['robot'], 'get_frame') instead of asserting interface['type'] == 'realsense', so UVC/webcam-style cameras (rgb-only, no depth) no longer crash it.
- adr renamed to hdr_adr throughout (configure_robot(), camera calibration) — now consistently documented as a physical hardware address (motor ID, RTDE join- adr renamed to hdr_adr throughout (confe raise NotImplemented → raise NotImplementedError(...) with descriptive messages.
- Added robot_cls = kwargs.pop('robot_cls', Robot) extension point so downstream repos never need to subclass/swap Robot.
- Added optional init_qpos param — if provided, used directly as self.init_qpos; otherwise falls back to today's auto-computed mid-actuator-range behavior. Warns if hardware-backed with no explicit init_qpos (homing to an implicit pose is likely unintended on real hardware).
- Swapped the startup call from self.step(np.zeros(...)) to self.reset() + self.forward(), so hardware now goes through Robot.reset()'s min-jerk hardware_reset() on env construction instead of jumping straight to a raw zero-ctrl command from wherever the robot currently is.
… internally (to route hardware envs through min-jerk reset) instead of self.step(zeros). Since reset() is often overridden by subclasses, this exposed a latent ordering bug across ~20 env files: they computed a task-specific self.init_qpos after calling super()._setup(), but by then super()._setup() had already triggered the first reset() using a stale/default init_qpos. In relocate_v0.py this stale pose left the hand and object permanently in collision, and the env's collision-retry logic in reset() recursed forever (RecursionError).
Vk/consolidate robot
- new hardware registery 
- hardware classes follow base class contracts
FEATURE: Improved path_utils. Better scanning of directories. Better …
…ell as calibration

hardware_reset now takes an explicit space='sim'|'hdr' parameter and indexes reset_pos via data_id (sim) or hdr_id (hdr), matching the pattern already used in hardware_apply_controls.
It now applies actuator['scale']/actuator['offset'] before handing the position to device['robot'].reset(...), same conversion hardware_apply_controls does for per-step controls.
BUGFIX robots (hardware-reset-space-&-calib-bug +vel_mode-typo)
…ng hardware connections

- env_base.py: close() now also closes robot (hardware) and sim_obsd (when it
  differs from sim), instead of only closing sim. Added close_hardware=True arg
  so callers can leave a hardware connection open across close()/make() cycles
  intentionally (env.close(close_hardware=False)). Added a warn-only __del__,
  mirroring Robot's, so a hardware-backed env that's GC'd without close() ever
  being called surfaces a RuntimeWarning instead of silently dangling.
- robot.py: Robot.__init__ was assigning the persistent session via
  self.robot_config, which only ever shadowed the class attribute on that one
  instance and silently defeated reuse across separate Robot()/env.make() calls.
  Now assigns via type(self).robot_config so the session is genuinely shared.
  Robot.close() gained the matching close_hardware arg, and tracks
  _explicitly_closed so __del__ doesn't false-positive when hardware was left
…uld get silently swallowed

- renderer.py/mj_renderer.py: replaced the private MJRenderer._user_exit flag with
  a base-class Renderer.exit_requested property so any backend can surface it.
  Also set it when the viewer window's native close ('X') button is used, not just
  Escape, which previously did nothing.
- env_base.py: added MujocoEnv.viewer_exit_requested. examine_policy()/
  examine_policy_new() now check it in their rollout while-loop (and again to break
  the outer episode loop), instead of continuing to step invisibly after the window
  closes. For offscreen/none rendering, which has no window at all, both loops now
  catch KeyboardInterrupt and stop the same way, returning whatever was completed.
  Offscreen video writes are trimmed to the frames actually rendered before an
  early stop instead of writing out the pre-allocated zero-filled tail.
- mj_sim_scene.py: SimScene.advance() had a bare , which also swallows
  KeyboardInterrupt/SystemExit, not just real errors. That meant a Ctrl+C landing
  inside sim.step() got eaten and turned into a silent physics reset instead of
  reaching the new rollout-loop handler. Narrowed to dm_control's PhysicsError and
  included the underlying exception in the warning message
…efault Robot class

Yesterday's change to persist robot_config on the class (so a hardware
session survives an env.close()/make() cycle) also applied to sim-only
robots, which all default to the same Robot class. Creating one sim env
after another in the same process left the second one silently reusing
the first's sensor/actuator config -- e.g. test_arms.py would crash with
an IndexError once a larger model's config leaked into a smaller model's
sim.data.sensordata.

- robot.py: scope the class-level persistence to is_hardware sessions
  only; sim sessions get a per-instance robot_config that can't leak.
  close() now also clears whichever level actually holds the config
  (class attr for hardware, instance attr for sim) instead of only ever
  touching the class attr.
- test_envs.py: check_env/check_old_envs now call env.close() instead of
  relying on GC via del(), exercising the real teardown path.
BUGFIX: Better handling of x-axis when keys are empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants