Skip to content

[fix] misc bug fixes and documentation improvements#6

Open
fanyahao1 wants to merge 4 commits intoproject-instinct:mainfrom
fanyahao1:fix/misc-bugs
Open

[fix] misc bug fixes and documentation improvements#6
fanyahao1 wants to merge 4 commits intoproject-instinct:mainfrom
fanyahao1:fix/misc-bugs

Conversation

@fanyahao1
Copy link

Summary

This PR fixes several bugs found during code review and improves documentation clarity.

Bug Fixes

1. Missing f-string in deprecation warning (agents/base.py)

The _parse_generated_commands method printed a raw string instead of an f-string, so {command_name} was never interpolated and the warning message was always printed literally with the placeholder text.

# Before (broken)
print("Warning: '_get_{command_name}_obs' for command {command_name} shall be deprecated...")

# After
print(f"Warning: '_get_{command_name}_obs' for command {command_name} shall be deprecated...")

2. NaN check after buffer write in send_action (ros_nodes/base.py)

The NaN guard was placed after writing to self.action and publishing to the action topic. If the action contained NaN, self.action would be poisoned and _get_last_action_obs() would return NaN in the next step, causing cascading NaN propagation.

Fix: move the NaN check to the top of send_action, before any writes.

3. NaN check after motor buffer write in _publish_motor_cmd (ros_nodes/unitree.py)

Similarly, the NaN guard in _publish_motor_cmd was placed after the loop that writes target_joint_pos into low_cmd_buffer. If NaN was detected, the buffer would already be corrupted.

Fix: move the NaN check before the write loop.

4. Misleading comment in get_cold_start_agent (agents/tracking_agent.py)

The inline comments on the action_scale and action_offset arguments were swapped, incorrectly describing what each parameter does.

Documentation

README: clarify unitree_hg / unitree_go installation

The previous instruction only mentioned "install unitree_hg and unitree_go" without explaining how. These packages come from building unitree_ros2 and sourcing its workspace. Without this step, Python will raise ModuleNotFoundError at import time.

fanyahao1 and others added 4 commits March 2, 2026 19:30
…h_motor_cmd

Previously, NaN checks in send_action (base.py) and _publish_motor_cmd
(unitree.py) were placed after writing to internal buffers:
- In send_action: self.action[:] and action_publisher.publish() were
  called before the NaN guard, poisoning the action buffer and causing
  cascading NaN in subsequent _get_last_action_obs() calls.
- In _publish_motor_cmd: the write loop into low_cmd_buffer ran before
  the NaN guard, leaving corrupted values in the motor command buffer.

Move both NaN checks to the top of their respective functions so no
writes occur when the input contains NaN.
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.

2 participants