8000 Manipulation demo: Update launching steps by knicked · Pull Request #332 · RobotecAI/rai · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Manipulation demo: Update launching steps #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 6, 2024

Conversation

knicked
Copy link
Contributor
@knicked knicked commented Dec 2, 2024

Purpose

Launching the manipulation demo required to launch the simulation and a few different nodes separately, this PR simplifies all this into one launchfile and one script for interaction with the robot.

Proposed Changes

  • Add rai-manipulation-demo to demos.repos
  • Add launch configurations for the simulation and all nodes needed to run the demo
  • Update the information about this in docs/demos/manipulation.md

Issues

N/A

Testing

The launchfile was ran successfully and the demo was tested manually.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new manipulation demo repository for enhanced user experimentation.
  • Documentation

    • Updated setup instructions for the manipulation demo to improve clarity and streamline the process.
  • Bug Fixes

    • Adjusted calibration parameters to default to zero, refining tool performance.
    • Updated task options in the manipulation tool to clarify actions (from "place" to "drop").

@maciejmajek
Copy link
Member

@CodeRabbit full review

@knicked knicked force-pushed the kd/manipulation_launch branch from 0d7c290 to 3e3495d Compare December 2, 2024 16:31
Copy link
Contributor
coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces a new repository entry for a manipulation demo and modifies related documentation and code files. It adds the src/examples/rai-manipulation-demo repository with specific attributes, updates the setup instructions in the documentation for clarity, and enhances the launch file for the manipulation demo by transitioning to a modular launch description approach. Additionally, it introduces a new parameter in the demo script and modifies calibration parameters and task options in the MoveToPointTool class to improve functionality.

Changes

File Change Summary
demos.repos Added new repository entry: src/examples/rai-manipulation-demo with type: git, url, version.
docs/demos/manipulation.md Updated setup instructions for clarity; changed command for importing repositories; renumbered steps.
examples/manipulation-demo.launch.py Replaced ExecuteProcess with IncludeLaunchDescription; added RosTimer for delayed node launch.
examples/manipulation-demo.py Added parameter conversion_ratio with default value 1.0 in RaiBaseNode.
src/rai/rai/tools/ros/manipulation.py Updated default calibration values to 0.0; changed task parameter from "place" to "drop".

Possibly related PRs

  • refactor: xml launchfiles to python #324: The changes in this PR involve refactoring launch files to Python, which is relevant to the main PR's addition of a new repository entry for a manipulation demo that likely involves similar launch configurations.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f78ceae and 0d7c290.

📒 Files selected for processing (5)
  • demos.repos (1 hunks)
  • docs/demos/manipulation.md (3 hunks)
  • examples/manipulation-demo.launch.py (2 hunks)
  • examples/manipulation-demo.py (1 hunks)
  • src/rai/rai/tools/ros/manipulation.py (1 hunks)
🔇 Additional comments (2)
demos.repos (1)

6-9: Ensure the new repository is accessible and at the correct version

Adding the rai-manipulation-demo repository is a good step. Verify that the URL is correct and that the development branch exists and is stable.

Run the following script to confirm repository accessibility:

✅ Verification successful

Repository and branch configuration is valid

The repository URL is accessible and the 'development' branch exists, confirming the configuration is correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the repository URL is correct and the 'development' branch exists.

# Test: Clone the repository's 'development' branch. Expect: Successful clone.
git ls-remote https://github.com/RobotecAI/rai-manipulation-demo.git &> /dev/null
if [ $? -ne 0 ]; then
    echo "Repository URL is invalid or inaccessible."
else
    BRANCH_EXISTS=$(git ls-remote --heads https://github.com/RobotecAI/rai-manipulation-demo.git development)
    if [ -z "$BRANCH_EXISTS" ]; then
        echo "Branch 'development' does not exist in the repository."
    else
        echo "Repository and branch are valid."
    fi
fi

Length of output: 416

src/rai/rai/tools/ros/manipulation.py (1)

60-62: ⚠️ Potential issue

Reconsider changing calibration defaults to zero

Setting calibration_x, calibration_y, and calibration_z defaults to zero might affect the accuracy of the robot's movements if these calibrations were compensating for known offsets.

Confirm if zeroing these calibration values is intentional and won't negatively impact the system's operation.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (7)
examples/manipulation-demo.launch.py (1)

16-20: Organize imports according to PEP 8 guidelines

For better readability and maintenance, consider grouping standard library imports, third-party imports, and local imports separately.

Apply this diff to reorganize imports:

 from launch import LaunchDescription
 from launch.actions import (
     DeclareLaunchArgument,
     ExecuteProcess,
     IncludeLaunchDescription,
 )
+from launch.event_handlers import OnProcessExit
+from launch.actions import RegisterEventHandler
 from launch.launch_description_sources import PythonLaunchDescriptionSource
 from launch.substitutions import LaunchConfiguration
 from launch_ros.actions import Node, RosTimer
 from launch_ros.substitutions import FindPackageShare
examples/manipulation-demo.py (1)

26-26: Parameter conversion_ratio is declared but not utilized

The new parameter conversion_ratio is declared but not used anywhere in the code. This may lead to confusion or maintenance issues.

Consider using the parameter or removing it if it's not needed.

node = RaiBaseNode(node_name="manipulation_demo")
-node.declare_parameter("conversion_ratio", 1.0)
docs/demos/manipulation.md (3)

12-14: Update instruction formatting for consistency

Ensure that the shell commands are properly formatted and indented for better readability.

Apply this diff to adjust the code block indentation:

 2. Download additional dependencies:

    ```shell
    poetry install --with openset
    vcs import < demos.repos
    ```

47-51: Clarify the path to the game launcher executable

In the command to start the demo, specify how to find or set the path/to/RAIManipulationDemo.GameLauncher to prevent confusion.

Provide guidance on obtaining the correct path:

 ros2 launch examples/manipulation-demo.launch.py game_launcher:=/absolute/path/to/RAIManipulationDemo.GameLauncher

Add a note:

> **Note**: Replace `/absolute/path/to/RAIManipulationDemo.GameLauncher` with the actual path to your downloaded game launcher executable.

52-59: Ensure users source the setup script before running the interactive prompt

Remind users to source the environment in the second terminal as well to avoid runtime issues.

Add the following note before step 2:

> **Note**: In the second terminal, make sure to run `source setup_shell.sh` before executing the next command.
src/rai/rai/tools/ros/manipulation.py (2)

Line range hint 83-85: Update task parameter options for clarity

In the _run method, the task parameter options have changed from "grab" and "place" to "grab" and "drop". Ensure that this change is reflected consistently throughout the codebase and documentation.

Update the method signature and internal logic if necessary.

 def _run(
     self,
     x: float,
     y: float,
     z: float,
-    task: Literal["grab", "place"],
+    task: Literal["grab", "drop"],
 ) -> str:

Also, update any conditional checks that compare task to "place".


Line range hint 83-114: Handle unexpected task parameter values

Currently, if task is neither "grab" nor "drop", the function defaults to the else branch, which might lead to unintended behavior.

Consider adding validation for the task parameter.

 if task == "grab":
     request.initial_gripper_state = True  # open
     request.final_gripper_state = False  # closed
-else:
+elif task == "drop":
     request.initial_gripper_state = False  # closed
     request.final_gripper_state = True  # open
+else:
+    return f"Invalid task: {task}. Expected 'grab' or 'drop'."
🛑 Comments failed to post (2)
examples/manipulation-demo.launch.py (2)

48-54: 🛠️ Refactor suggestion

Use FindPackageShare for consistent package path resolution

The hardcoded path in lines 51~ can lead to issues if the package is installed in a different location. It's recommended to use FindPackageShare to dynamically locate the package path.

Apply this diff to improve path resolution:

 IncludeLaunchDescription(
     PythonLaunchDescriptionSource(
         [
-            "src/examples/rai-manipulation-demo/Project/Examples/panda_moveit_config_demo.launch.py",
+            FindPackageShare("rai-manipulation-demo"),
+            "/Project/Examples/panda_moveit_config_demo.launch.py",
         ]
     ),
 ),

Committable suggestion skipped: line range outside the PR's diff.


56-65: 🛠️ Refactor suggestion

Replace RosTimer with event handling for reliable synchronization

Using a fixed delay with RosTimer may not guarantee that the MoveIt node is fully initialized before the robotic_manipulation node starts. This can lead to race conditions. It's better to use an event handler to launch the node after the MoveIt node is ready.

Consider using RegisterEventHandler and OnProcessExit as shown below:

+from launch.event_handlers import OnProcessExit
+from launch.actions import RegisterEventHandler

 # Include the MoveIt launch file and assign it to a variable
 moveit_launch = IncludeLaunchDescription(
     PythonLaunchDescriptionSource(
         [
             FindPackageShare("rai-manipulation-demo"),
             "/Project/Examples/panda_moveit_config_demo.launch.py",
         ]
     ),
 )

 return LaunchDescription(
     [
         # Previous launch actions...
         moveit_launch,
-        # Launch the robotic_manipulation node after 3 seconds
-        RosTimer(
-            period=3.0,
-            actions=[
-                Node(
-                    package="robotic_manipulation",
-                    executable="robotic_manipulation",
-                    name="robotic_manipulation_node",
-                    output="screen",
-                ),
-            ],
-        ),
+        # Launch the robotic_manipulation node after MoveIt is ready
+        RegisterEventHandler(
+            OnProcessExit(
+                target_action=moveit_launch,
+                on_exit=[
+                    Node(
+                        package="robotic_manipulation",
+                        executable="robotic_manipulation",
+                        name="robotic_manipulation_node",
+                        output="screen",
+                    ),
+                ],
+            )
+        ),
         # Remaining launch actions...
     ]
 )

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member
@maciejmaj
8000
ek maciejmajek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended. Please create a PR for the rai-manipulation-demo to include the necessary dependencies.

Below is the list of commands I had to run to get it working:

 2037  2024-12-02 12:40:04 sudo apt install ros-jazzy-ackermann-msgs
 2039  2024-12-02 12:40:27 sudo apt install ros-jazzy-gazebo-msgs ros-jazzy-fastrtps*
 2041  2024-12-02 12:42:18 sudo apt install ros-jazzy-gazebo-msgs ros-jazzy-control-toolbox
 2079  2024-12-02 12:58:14 sudo apt install ros-jazzy-moveit-configs-utils 
 2082  2024-12-02 12:59:37 sudo apt install ros-jazzy-moveit-resources-panda-*
 2083  2024-12-02 12:59:58 sudo apt install ros-jazzy-moveit*
 2084  2024-12-02 13:03:00 sudo apt install ros-jazzy-sdformat-*

Note: Some commands use *, which installs every package with the specified prefix. This may include unnecessary packages. Please determine and specify only the required packages.

To replicate the setup on a clean Ubuntu installation with ROS, first uninstall all ROS packages:

sudo apt remove ros-*

Then, reinstall ROS using the following command:

sudo apt install ros-(humble|jazzy)-ros-base

After reinstalling, use a trial-and-error approach (or some other method) to identify the minimal set of additional packages required to run the demo.

As a last step, please add rosdep instruction to the demo's README to install required dependencies.

Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
Signed-off-by: Kacper Dąbrowski <kacper.dabrowski@robotec.ai>
@knicked knicked force-pushed the kd/manipulation_launch branch from 11181c6 to 1f1cf77 Compare December 6, 2024 09:59
Copy link
Member
@maciejmajek maciejmajek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maciejmajek maciejmajek merged commit ea43a20 into development Dec 6, 2024
5 checks passed
@maciejmajek maciejmajek deleted the kd/manipulation_launch branch December 6, 2024 10:20
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
0