Add graph download/upload/clear methods#30
Add graph download/upload/clear methods#30amessing-bdai merged 12 commits intorai-opensource:mainfrom
Conversation
d1bdfeb to
96cdeef
Compare
820471c to
43cac99
Compare
|
This feature is originally introduced in this old PR for spot_ros. I am using this in our lab's fork. But I would like to merge this feature to upstream repo. Who should I ask for a review about it? |
| self._clear_graph() | ||
| return True, "Success" | ||
| except Exception as e: | ||
| return False, f"Error: {e}" |
There was a problem hiding this comment.
More descriptive error message?
There was a problem hiding this comment.
Updated the error message.
| Args: | ||
| upload_path (str): Path to the directory of the map.""" | ||
| try: | ||
| self._clear_graph() |
There was a problem hiding this comment.
The upload graph function should strictly serve to upload the graph without implicitly erasing any existing data. This ensures the process is atomic, meaning it doesn't interfere with the current state of the graph.
There was a problem hiding this comment.
That makes sense. I have removed implicit _clear_graph() from here.
| ) | ||
| return success, message | ||
| except Exception as e: | ||
| return False, f"Error: {e}" |
There was a problem hiding this comment.
More descriptive error message?
There was a problem hiding this comment.
Updated the error message.
| """Download graph and snapshots from robot. | ||
|
|
||
| Args: | ||
| download_path (str): Directory where graph and snapshotw are downloaded from robot. |
| """Write data to a file. | ||
|
|
||
| Args: | ||
| filepath (str) : Path of file wher data will be written. |
| ] | ||
|
|
||
| def clear_graph(self) -> typing.Tuple[bool, str]: | ||
| """Clear a graph in a robot. |
There was a problem hiding this comment.
This could be clearer, e.g. the docstring for _clear_graph is Clear the state of the map on the robot, removing all waypoints and edges.
There was a problem hiding this comment.
Updated the method docstring. Also added that it removes snapshots only in the ram.
| return False, f"Error: {e}" | ||
|
|
||
| def upload_graph(self, upload_path: str) -> typing.Tuple[bool, str]: | ||
| """Upload graph and snapshots to robot. |
There was a problem hiding this comment.
Same here, could be more descriptive since this is meant to be used externally.
There was a problem hiding this comment.
Updated the docstring.
| os.path.join(download_path, "edge_snapshots", edge.snapshot_id), | ||
| edge_snapshot.SerializeToString(), | ||
| ) | ||
| return True, "Success" |
There was a problem hiding this comment.
Just checking, is there a SpotSDK example reference for this functionality?
There was a problem hiding this comment.
|
Thank you for review, I will update the branch. |
…to update description and error message
|
Checked with our spot. |
|
I tested this out (by running basically the code in description). I do get an error at list graph regarding logging (as expected). Uploading and downloading appears to work. The error: Commenting out list_graph I get this: |
kzheng-bdai
left a comment
There was a problem hiding this comment.
Tested after fixing the logging error and looks good.
Also tested our own GraphNav functionalities.
|
Thanks! |
Checked with a robot like
Errors will show up during
list_graphmethod. This will be fixed with #31