[fix] misc bug fixes and documentation improvements#6
Open
fanyahao1 wants to merge 4 commits intoproject-instinct:mainfrom
Open
[fix] misc bug fixes and documentation improvements#6fanyahao1 wants to merge 4 commits intoproject-instinct:mainfrom
fanyahao1 wants to merge 4 commits intoproject-instinct:mainfrom
Conversation
…scale/action_offset in TrackerAgent
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_commandsmethod 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.2. NaN check after buffer write in
send_action(ros_nodes/base.py)The NaN guard was placed after writing to
self.actionand publishing to the action topic. If the action contained NaN,self.actionwould 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_cmdwas placed after the loop that writestarget_joint_posintolow_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_scaleandaction_offsetarguments were swapped, incorrectly describing what each parameter does.Documentation
README: clarify
unitree_hg/unitree_goinstallationThe previous instruction only mentioned "install
unitree_hgandunitree_go" without explaining how. These packages come from building unitree_ros2 and sourcing its workspace. Without this step, Python will raiseModuleNotFoundErrorat import time.