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

chore: sync upstream #38

Merged
merged 24 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ea9d8dc
feat(how-to-guides): add instructions for package customization based…
JianKangEgon Dec 13, 2022
70bc23d
docs(tutorial): awsim ros2 humble note (#284)
WJaworskiRobotec Dec 23, 2022
5e2e0e5
docs: modify perception architecture in node diagram (#286)
Shin-kyoto Dec 26, 2022
7b5a860
feat: add console-logging doc (#283)
kenji-miyake Dec 26, 2022
a75d24d
docs(how-to-guides): add a custom ROS message (#236)
cyn-liu Dec 28, 2022
54149fd
chore: sync files (#253)
awf-autoware-bot[bot] Dec 30, 2022
a53dca1
ci(pre-commit): autoupdate (#182)
pre-commit-ci[bot] Dec 30, 2022
eba9294
fix(dead-link): update dead autosar link (#289)
xmfcx Jan 3, 2023
2bcac77
feat: subpages added for slam implementations (#252)
enesadastec Jan 3, 2023
8da9e9c
feat(contributing): add 'topic-namespaces.md' in ros-nodes (#223)
cyn-liu Jan 6, 2023
e4d3689
docs(contributing): add coordinate-system.md in ros-nodes (#285)
cyn-liu Jan 6, 2023
1a530e8
docs(how-to-guides): add how to fix dependent package versions (#295)
IshitaTakeshi Jan 12, 2023
7bf0bf7
feat(how-to-guides): add debug autoware guides (#268)
cyn-liu Jan 12, 2023
f5012e5
docs(message-guidelines): add plural type naming (#297)
isamu-takagi Jan 16, 2023
5ee0639
docs(how-to-guides): reference fixing-dependent-package-versions.md (…
IshitaTakeshi Jan 17, 2023
919354b
fix(tutorial): fix tutorial for planning simulation with ADAPI (#301)
h-ohta Jan 17, 2023
01e6b75
docs(sensing): add sensing design documentation (#180)
xmfcx Jan 25, 2023
030c145
docs(perception): update perception node-diagram (#305)
badai-nguyen Jan 27, 2023
3775476
fix(how-to-guides/creating-maps-for-autoware): dead link in hdl_graph…
yukkysaito Jan 29, 2023
7100ac5
docs(installation): add docker installation video tutorials and refac…
cyn-liu Jan 30, 2023
ef94e2f
docs(tutorial): removed temporary note (#308)
WJaworskiRobotec Jan 30, 2023
0de2fa4
fix(docker-installaion-devel): rocker does not show any progress for …
ahmeddesokyebrahim Feb 2, 2023
2e87b68
docs(how-to-guides): add ros2_graph and ros2doctor to debug guideline…
xmfcx Feb 2, 2023
10db123
docs(support/troubleshooting): add information about setuptools issue…
lchojnack Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
pre-commit:
if: ${{ github.event.repository.private }}
if: ${{ github.event.repository.private }} # Use pre-commit.ci for public repositories
runs-on: ubuntu-latest
steps:
- name: Generate token
Expand Down
3 changes: 3 additions & 0 deletions .markdown-link-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
{
"pattern": "^https://github.com/.*/discussions/new"
},
{
"pattern": "^https://www\\.autosar\\.org/*"
}
],
"retryOn429": true,
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config-optional.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/tcort/markdown-link-check
rev: v3.10.0
rev: v3.10.3
hooks:
- id: markdown-link-check
args: [--config=.markdown-link-check.json]
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-json
- id: check-merge-conflict
Expand All @@ -19,29 +19,29 @@ repos:
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.1
rev: v0.32.2
hooks:
- id: markdownlint
args: [-c, .markdownlint.yaml, --fix]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v3.0.0-alpha.4
hooks:
- id: prettier

- repo: https://github.com/adrienverge/yamllint
rev: v1.27.1
rev: v1.28.0
hooks:
- id: yamllint
exclude: .*.param.yaml

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
rev: v0.9.0.2
hooks:
- id: shellcheck

- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.5.1-1
rev: v3.6.0-1
hooks:
- id: shfmt
args: [-w, -s, -i=4]
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/coding-guidelines/languages/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Follow the guidelines below if a rule is not defined on this page.

1. <https://docs.ros.org/en/humble/Contributing/Code-Style-Language-Versions.html>
2. <https://www.autosar.org/fileadmin/user_upload/standards/adaptive/21-11/AUTOSAR_RS_CPP14Guidelines.pdf>
2. <https://www.autosar.org/fileadmin/standards/adaptive/22-11/AUTOSAR_RS_CPP14Guidelines.pdf>
3. <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines>

Also, it is encouraged to apply Clang-Tidy to each file.
Expand Down
187 changes: 185 additions & 2 deletions docs/contributing/coding-guidelines/ros-nodes/console-logging.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,188 @@
# Console logging

!!! warning
ROS 2 logging is a powerful tool for understanding and debugging ROS nodes.

Under Construction
This page focuses on how to design console logging in Autoware and shows several practical examples.
To comprehensively understand how ROS 2 logging works, refer to the [logging documentation](https://docs.ros.org/en/humble/Concepts/About-Logging.html).

## Logging use cases in Autoware

- Developers debug code by seeing the console logs.
- Vehicle operators take appropriate risk-avoiding actions depending on the console logs.
- Log analysts analyze the console logs that are recorded in rosbag files.

To efficiently support these use cases, clean and highly visible logs are required.
For that, several rules are defined below.

## Rules

### Choose appropriate severity levels (required, non-automated)

#### Rationale

It's confusing if severity levels are inappropriate as follows:

- Useless messages are marked as `FATAL`.
- Very important error messages are marked as `INFO`.

#### Example

Use the following criteria as a reference:

- **DEBUG:** Use this level to show debug information for developers. Note that logs with this level is hidden by default.
- **INFO:** Use this level to notify events (cyclic notifications during initialization, state changes, service responses, etc.) to operators.
- **WARN:** Use this level when a node can continue working correctly, but unintended behaviors might happen.
- For example, "path optimization failed but the previous data can be used", "the localization score is low", etc.
- **ERROR:** Use this level when a node can't continue working correctly, and unintended behaviors would happen.
- For example, "path optimization failed and the path is empty", "the vehicle will trigger an emergency stop", etc.
- **FATAL:** Use this level when the entire system can't continue working correctly, and the system must be stopped.
- For example, "the vehicle control ECU doesn't respond", "the system storage crashed", etc.

### Filter out unnecessary logs by setting logging options (required, non-automated)

#### Rationale

Some third-party nodes such as drivers may not follow the Autoware's guidelines.
If the logs are noisy, unnecessary logs should be filtered out.

#### Example

Use the `--log-level {level}` option to change the minimum level of logs to be displayed:

```xml
<launch>
<!-- This outputs only FATAL level logs. -->
<node pkg="demo_nodes_cpp" exec="talker" ros_args="--log-level fatal" />
</launch>
```

If you want to disable only specific output targets, use the `--disable-stdout-logs`, `--disable-rosout-logs`, and/or `--disable-external-lib-logs` options:

```xml
<launch>
<!-- This outputs to rosout and disk. -->
<node pkg="demo_nodes_cpp" exec="talker" ros_args="--disable-stdout-logs" />
</launch>
```

```xml
<launch>
<!-- This outputs to stdout. -->
<node pkg="demo_nodes_cpp" exec="talker" ros_args="--disable-rosout-logs --disable-external-lib-logs" />
</launch>
```

### Use throttled logging when the log is unnecessarily shown repeatedly (required, non-automated)

#### Rationale

If tons of logs are shown on the console, people miss important message.

#### Example

While waiting for some messages, throttled logs are usually enough.
In such cases, wait about 5 seconds as a reference value.

```cpp
// Compliant
void FooNode::on_timer() {
if (!current_pose_) {
RCLCPP_ERROR_THROTTLE(get_logger(), *get_clock(), 5000, "Waiting for current_pose_.");
return;
}
}

// Non-compliant
void FooNode::on_timer() {
if (!current_pose_) {
RCLCPP_ERROR(get_logger(), "Waiting for current_pose_.");
return;
}
}
```

#### Exception

The following cases are acceptable even if it's not throttled.

- The message is really worth displaying every time.
- The message level is DEBUG.

### Do not depend on rclcpp::Node in core library classes but depend only on rclcpp/logging.hpp (advisory, non-automated)

#### Rationale

Core library classes, which contain reusable algorithms, may also be used for non-ROS platforms.
When porting libraries to other platforms, fewer dependencies are preferred.

#### Example

```cpp
// Compliant
#include <rclcpp/logging.hpp>

class FooCore {
public:
explicit FooCore(const rclcpp::Logger & logger) : logger_(logger) {}

void process() {
RCLCPP_INFO(logger_, "message");
}

private:
rclcpp::Logger logger_;
};

// Compliant
// Note that logs aren't published to `/rosout` if the logger name is different from the node name.
#include <rclcpp/logging.hpp>

class FooCore {
void process() {
RCLCPP_INFO(rclcpp::get_logger("foo_core_logger"), "message");
}
};


// Non-compliant
#include <rclcpp/node.hpp>

class FooCore {
public:
explicit FooCore(const rclcpp::NodeOptions & node_options) : node_("foo_core_node", node_options) {}

void process() {
RCLCPP_INFO(node_.get_logger(), "message");
}

private:
rclcpp::Node node_;
};
```

## Tips

### Use rqt_console to filter logs

To filter logs, using `rqt_console` is useful:

```bash
ros2 run rqt_console rqt_console
```

For more details, refer to [ROS 2 Documentation](https://docs.ros.org/en/rolling/Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.html).

### Useful marco expressions

To debug program, sometimes you need to see which functions and lines of code are executed.
In that case, you can use `__FILE__`, `__LINE__` and `__FUNCTION__` macro:

```cpp
void FooNode::on_timer() {
RCLCPP_DEBUG(get_logger(), "file: %s, line: %s, function: %s" __FILE__, __LINE__, __FUNCTION__);
}
```

The example output is as follows:

> [DEBUG] [1671720414.395456931] [foo]: file: /path/to/file.cpp, line: 100, function: on_timer
Loading