Skip to content
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

#362 research current architecture of planning component #417

Merged

Conversation

johannaschwarz
Copy link
Contributor

@johannaschwarz johannaschwarz commented Nov 1, 2024

Description

Adds research for planning and some minor documentation updates for planning.

Fixes #362

Type of change

Please delete options that are not relevant.

Does this PR introduce a breaking change?

no

Most important changes

Update to research of planning

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (might be obsolete with CI later on)
  • New and existing unit tests pass locally with my changes (might be obsolete with CI later on)

Summary by CodeRabbit

  • New Features

    • Updated the published trajectory topic to enhance clarity in the Global Planner.
    • Expanded documentation to clarify the relationship between local and global planning in robotic systems.
  • Bug Fixes

    • Corrected typographical errors in documentation for improved accuracy.
  • Documentation

    • Enhanced clarity and organization in Global Planner and README documentation.
    • Added graphical representation in local vs global planning documentation to illustrate component relationships.
  • Refactor

    • Improved organization and clarity of code in various modules without altering functionality.

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

Walkthrough

The changes in this pull request involve updates to the PrePlanner class in global_planner.py, including a new naming convention for the published trajectory topic and reorganization of import statements. Documentation across several files has been improved for clarity, correcting typographical errors and enhancing the descriptions of the planning components. The ACC class in ACC.py has also been modified to improve code organization and clarity without altering the underlying logic.

Changes

File Path Change Summary
code/planning/src/global_planner/global_planner.py Updated published trajectory topic from /paf/{role_name}/trajectory to /paf/{role_name}/trajectory_global; reorganized imports; updated comments in global_route_callback and world_info_callback methods.
doc/planning/Global_Planner.md Corrected typographical errors; streamlined descriptions; improved organization of the table of contents.
doc/planning/README.md Corrected typographical errors; simplified explanations regarding the publication of trajectory and speed limits.
doc/research/paf24/planning/local_v_global_planning.md Expanded explanation of local vs. global planning; added graphical representation of node relationships.
code/planning/src/global_planner/preplanning_trajectory.py Adjusted import statements; improved comments and docstrings in OpenDriveConverter class methods.
code/planning/src/local_planner/ACC.py Reordered imports; updated class docstring; improved organization and clarity in subscription and publication mechanisms.

Assessment against linked issues

Objective Addressed Explanation
Evaluate the interaction and dependencies between pre planning, global planning, and local planning. (#362)

Possibly related PRs

Suggested reviewers

  • victor-42
  • RoyaLxPole

🐇 In the planner's realm, we hop and play,
With clearer paths, we find our way.
From global dreams to local sights,
Our code now shines, oh what delights!
With every change, we leap and bound,
In harmony, our plans are found! 🌟


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
doc/planning/README.md (1)

13-16: Improve readability with proper punctuation and clearer structure.

The description accurately reflects the global planner's responsibilities, but could benefit from better punctuation and structure.

Apply these changes to improve readability:

-The global planner is responsible for collecting and preparing all data from the leaderboard and other internal
-components that is needed for the preplanning component.
-After finishing that this node initiates the calculation of a trajectory based on the OpenDriveConverter
-from preplanning_trajectory.py. In the end the computed trajectory and prevailing speed limits are published.
+The global planner is responsible for collecting and preparing all data from the leaderboard and other internal
+components that is needed for the preplanning component.
+After finishing that, this node initiates the calculation of a trajectory based on the OpenDriveConverter
+from preplanning_trajectory.py. In the end, the computed trajectory and prevailing speed limits are published.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~15-~15: Possible missing comma found.
Context: ... preplanning component. After finishing that this node initiates the calculation of ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~16-~16: A comma might be missing here.
Context: ... from preplanning_trajectory.py. In the end the computed trajectory and prevailing ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

doc/research/paf24/planning/local_v_global_planning.md (4)

1-1: Fix typo in title.

Correct the spelling of "beteween" to "between".

-# Relation beteween local and global planning
+# Relation between local and global planning

12-12: Fix typo in global planning description.

Correct the spelling of "consits" to "consists".

-Global planning consits of the PrePlanner Node and the OpenDriveConverter.
+Global planning consists of the PrePlanner Node and the OpenDriveConverter.

20-20: Consider breaking down the long line for better readability.

The line exceeds the recommended length of 300 characters.

-Local planning consists of the ACC, CollisionCheck and MotionPlanning nodes. It uses information from the Global Planning to make decisions in the local environment of the ego vehicle. It creates a trajectory based on the global trajectory and the current position of the vehicle that is used by the acting component.
+Local planning consists of the ACC, CollisionCheck and MotionPlanning nodes. It uses information from the Global Planning to make decisions in the local environment of the ego vehicle. 
+It creates a trajectory based on the global trajectory and the current position of the vehicle that is used by the acting component.
🧰 Tools
🪛 Markdownlint

20-20: Expected: 300; Actual: 317
Line length

(MD013, line-length)


31-31: Add missing newline at end of file.

Add a newline character at the end of the file to comply with markdown standards.

  - receives global trajectory from `/paf/hero/trajectory_global`
+
🧰 Tools
🪛 Markdownlint

31-31: null
Files should end with a single newline character

(MD047, single-trailing-newline)

doc/planning/Global_Planner.md (1)

Line range hint 26-57: Consider enhancing component interaction documentation.

Given that this PR is focused on researching the planning component's architecture (issue #362), consider adding more details about:

  • How the global planner interacts with pre-planning and local planning phases
  • The data flow and dependencies between these components
  • Any architectural constraints or considerations

This would align with the research objectives of understanding component interactions.

Would you like help drafting a new section that details these architectural aspects?

🧰 Tools
🪛 LanguageTool

[uncategorized] ~58-~58: A comma might be missing here.
Context: ...to the ODC. After smaller outliners are removed the x and y coordinates as well as the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

code/planning/src/global_planner/global_planner.py (1)

Line range hint 1-248: Consider architectural improvements for better separation of concerns

While the implementation is functional, there are opportunities for architectural improvements:

  1. The PrePlanner class currently handles multiple responsibilities:

    • OpenDrive map processing
    • Trajectory calculation
    • ROS topic management
    • Coordinate transformations
  2. Consider splitting these responsibilities into separate components:

    • A dedicated map processor
    • A trajectory calculator service
    • A ROS interface handler

This would align with the PR's research objectives by making the planning component's architecture more modular and easier to understand.

Would you like assistance in designing a more modular architecture for these components?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 495e1d5 and 26133f0.

⛔ Files ignored due to path filters (1)
  • doc/assets/research_assets/planning_internal.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • code/planning/src/global_planner/global_planner.py (2 hunks)
  • doc/planning/Collision_Check.md (1 hunks)
  • doc/planning/Global_Planner.md (3 hunks)
  • doc/planning/README.md (1 hunks)
  • doc/research/paf24/planning/local_v_global_planning.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • doc/planning/Collision_Check.md
🧰 Additional context used
🪛 LanguageTool
doc/planning/README.md

[uncategorized] ~15-~15: Possible missing comma found.
Context: ... preplanning component. After finishing that this node initiates the calculation of ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~16-~16: A comma might be missing here.
Context: ... from preplanning_trajectory.py. In the end the computed trajectory and prevailing ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 Markdownlint
doc/research/paf24/planning/local_v_global_planning.md

20-20: Expected: 300; Actual: 317
Line length

(MD013, line-length)


31-31: null
Files should end with a single newline character

(MD047, single-trailing-newline)

🔇 Additional comments (5)
doc/research/paf24/planning/local_v_global_planning.md (2)

1-31: Documentation effectively explains planning architecture.

The documentation successfully achieves the PR objective of evaluating and documenting the planning component architecture. It clearly explains the relationship between global and local planning components, their responsibilities, and communication patterns via ROS topics.

🧰 Tools
🪛 Markdownlint

20-20: Expected: 300; Actual: 317
Line length

(MD013, line-length)


31-31: null
Files should end with a single newline character

(MD047, single-trailing-newline)


8-8: Verify the referenced image exists.

Let's ensure the image file exists at the specified path.

✅ Verification successful

Image path is correctly referenced and file exists

The image file /doc/assets/research_assets/planning_internal.png exists at the specified location.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced image exists
if [ -f "doc/assets/research_assets/planning_internal.png" ]; then
    echo "Image exists"
else
    echo "Warning: Image not found at doc/assets/research_assets/planning_internal.png"
fi

Length of output: 96

doc/planning/Global_Planner.md (2)

11-15: LGTM! Well-structured table of contents.

The table of contents is clear, hierarchical, and accurately reflects the document structure.


26-26: LGTM! Improved clarity and consistency.

The terminology and sentence structure improvements make the documentation clearer and more professional.

Also applies to: 56-57

code/planning/src/global_planner/global_planner.py (1)

4-12: LGTM: Import reorganization maintains proper grouping

The reorganization of imports follows good practices by grouping standard library, third-party, and local imports while consolidating geometry_msgs imports.

@johannaschwarz johannaschwarz force-pushed the 362-research-current-architecture-of-planning-component branch 2 times, most recently from 57343d4 to 2e6729b Compare November 3, 2024 09:27
@johannaschwarz johannaschwarz force-pushed the 362-research-current-architecture-of-planning-component branch from 2e6729b to 30d12b4 Compare November 3, 2024 09:29
Copy link
Contributor

@niklasr22 niklasr22 left a comment

Choose a reason for hiding this comment

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

Nice!

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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (6)
doc/planning/README.md (2)

15-18: Improve readability with proper punctuation.

The content changes look good, but consider adding commas for better readability:

-The global planner is responsible for collecting and preparing all data from the leaderboard and other internal components that is needed for the preplanning component. After finishing that this node initiates the calculation of a trajectory based on the OpenDriveConverter from preplanning_trajectory.py. In the end the computed trajectory and prevailing speed limits are published.
+The global planner is responsible for collecting and preparing all data from the leaderboard and other internal components that is needed for the preplanning component. After finishing that, this node initiates the calculation of a trajectory based on the OpenDriveConverter from preplanning_trajectory.py. In the end, the computed trajectory and prevailing speed limits are published.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~17-~17: A comma might be missing here.
Context: ... preplanning component. After finishing that this node initiates the calculation of ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~18-~18: A comma might be missing here.
Context: ... from preplanning_trajectory.py. In the end the computed trajectory and prevailing ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


15-18: Consider adding architectural interaction details.

Since this PR focuses on evaluating the planning component's architecture, consider enhancing this section with:

  1. How the global planner interacts with pre-planning and local planning phases
  2. The data flow between these components
  3. Any dependencies or constraints in the interaction

Would you like me to help draft additional documentation sections covering these architectural aspects?

🧰 Tools
🪛 LanguageTool

[uncategorized] ~17-~17: A comma might be missing here.
Context: ... preplanning component. After finishing that this node initiates the calculation of ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~18-~18: A comma might be missing here.
Context: ... from preplanning_trajectory.py. In the end the computed trajectory and prevailing ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

doc/research/paf24/planning/local_v_global_planning.md (2)

1-1: Fix typo in heading

-# Relation beteween local and global planning
+# Relation between local and global planning

23-33: Consider standardizing ROS topic formatting

While the topic documentation is thorough, consider using consistent formatting for ROS topics, perhaps using code formatting (backticks) for better readability.

- receives Speed from `/carla/hero/Speed`
+ receives Speed from `\`/carla/hero/Speed\``

Apply similar formatting to all ROS topics in the document for consistency.

code/planning/src/local_planner/ACC.py (2)

2-9: Remove commented-out import if unused.

The CarlaWorldInfo import is commented out. If it's no longer needed, please remove it entirely rather than leaving it commented.


Line range hint 190-245: Consider extracting speed calculation logic for better maintainability.

The speed calculation logic in the loop function is quite complex. Consider extracting it into separate methods like calculate_safe_speed_with_obstacle and calculate_safe_speed_without_obstacle to improve readability and maintainability.

Example refactor:

def calculate_safe_speed_with_obstacle(self):
    safety_distance = calculate_rule_of_thumb(False, self.__current_velocity)
    if self.obstacle_distance < safety_distance:
        safe_speed = self.obstacle_speed * (self.obstacle_distance / safety_distance)
        safe_speed = interpolate_speed(safe_speed, self.__current_velocity)
        return 0 if safe_speed < 1.0 else safe_speed
    return 0 if self.__current_velocity < 1.0 else self.__current_velocity

def loop(self, timer_event=None):
    if self.obstacle_distance is not None and self.obstacle_speed is not None and self.__current_velocity is not None:
        safe_speed = self.calculate_safe_speed_with_obstacle()
        self.velocity_pub.publish(safe_speed)
    elif self.speed_limit is not None:
        self.velocity_pub.publish(self.speed_limit)
    else:
        self.velocity_pub.publish(0)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 26133f0 and a4f9eac.

📒 Files selected for processing (6)
  • code/planning/src/global_planner/global_planner.py (4 hunks)
  • code/planning/src/global_planner/preplanning_trajectory.py (3 hunks)
  • code/planning/src/local_planner/ACC.py (1 hunks)
  • doc/planning/Global_Planner.md (3 hunks)
  • doc/planning/README.md (1 hunks)
  • doc/research/paf24/planning/local_v_global_planning.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • code/planning/src/global_planner/preplanning_trajectory.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • code/planning/src/global_planner/global_planner.py
  • doc/planning/Global_Planner.md
🧰 Additional context used
🪛 LanguageTool
doc/planning/README.md

[uncategorized] ~17-~17: A comma might be missing here.
Context: ... preplanning component. After finishing that this node initiates the calculation of ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~18-~18: A comma might be missing here.
Context: ... from preplanning_trajectory.py. In the end the computed trajectory and prevailing ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🔇 Additional comments (7)
doc/research/paf24/planning/local_v_global_planning.md (3)

10-17: LGTM! Clear and accurate description of Global Planning components

The section effectively describes the Global Planning components and their responsibilities, with clear documentation of the ROS topic used for communication.


18-22: LGTM! Comprehensive overview of Local Planning

The introduction to Local Planning effectively explains its relationship with Global Planning and its role in the system.


8-8: Verify the referenced image exists

Let's ensure the image file exists at the specified path.

✅ Verification successful

Image reference is valid and accessible

The image file exists at the specified path doc/assets/research_assets/planning_internal.png, confirming that the markdown reference is correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the image exists
if [ -f "doc/assets/research_assets/planning_internal.png" ]; then
    echo "Image exists"
else
    echo "Warning: Image not found at doc/assets/research_assets/planning_internal.png"
fi

Length of output: 96

code/planning/src/local_planner/ACC.py (4)

14-15: LGTM! Clear and informative class documentation.

The updated class documentation clearly describes the ACC's purpose and its dependencies on various inputs.


Line range hint 17-89: LGTM! Well-organized initialization with improved type safety.

The subscriber and publisher initialization is well-structured with:

  • Clear type hints for better code maintainability
  • Logical grouping of related subscriptions
  • Consistent naming and documentation

Line range hint 1-245: Verify test coverage for this critical safety component.

Given that ACC is a critical safety component, we should ensure comprehensive test coverage, especially for:

  • Edge cases in collision detection
  • Speed calculation logic
  • Safety distance calculations
#!/bin/bash
# Search for test files related to ACC
fd -g "*test*ACC*.py" -g "*ACC*test*.py"

# Search for any pytest fixtures or test cases related to ACC
rg -l "def test.*ACC|class.*ACC.*Test" 

Line range hint 91-106: Consider adding validation for negative distance/speed values.

While the method correctly handles infinite values, it might be worth adding validation for negative values in data.data[0] (distance) and data.data[1] (speed) to ensure robustness.

 def __collision_callback(self, data: Float32):
     if np.isinf(data.data[0]):
         # If no obstacle is in front, we reset all values
         self.obstacle_speed = None
         self.obstacle_distance = None
         return
+    # Validate distance and speed
+    if data.data[0] < 0 or data.data[1] < 0:
+        self.logwarn("Received negative distance or speed values")
+        return
     self.obstacle_speed = data.data[1]
     self.obstacle_distance = data.data[0]

@johannaschwarz johannaschwarz merged commit 0030ae7 into main Nov 3, 2024
4 checks passed
@johannaschwarz johannaschwarz deleted the 362-research-current-architecture-of-planning-component branch November 3, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Planning: Evaluate the current architecture of the planning component
2 participants