-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔄 synced local 'docs/cheatsheets' with remote 'cheatsheets'
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
created: 2024-02-23 10:24:46 | ||
--- | ||
## Default Context | ||
|
||
それぞれのプロセスでは、シングルトンパターンによってデフォルトのContextが生成される。 | ||
|
||
rclcpp::initではこのデフォルトコンテキストを初期化している。 | ||
|
||
|
||
## オリジナル Contextを使ったROS 2プログラミング | ||
|
||
rclcpp::initはデフォルトContextをinitしているに過ぎないので、 | ||
オリジナルContextしか使わない場合はContext::initさえしておけばrclcpp::initする必要はない | ||
|
||
|
||
## CallbackGroup | ||
|
||
## NodeOptions | ||
ノードに対応する設定 | ||
- | ||
|
||
|
||
## InitOptions | ||
|
||
contextに対応する設定 | ||
- domain IDがセットできる | ||
|
||
|
||
## ExecutorOptions | ||
|
||
rclcpp::memory_strategy::MemoryStrategy::SharedPtr memory_strategy; | ||
rclcpp::Context::SharedPtr context; | ||
size_t max_conditions; | ||
=>デフォルトコンテキストが使われる |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
created: 2024-02-29 10:41:27 | ||
--- | ||
|
||
## パラメータ | ||
|
||
### Nodeからいじる | ||
|
||
#### get_parameter | ||
|
||
##### 1 | ||
|
||
``` | ||
rclcpp::Parameter get_parameter(const std::string & name) const | ||
``` | ||
|
||
名前を指定して、パラメータを返す。 | ||
存在しないパラメータに対しては `rclcpp::exceptions::ParameterNotDeclaredException`を送出する。 | ||
|
||
##### 2 | ||
``` | ||
bool get_parameter(const std::string & name, rclcpp::Parameter & parameter) const | ||
``` | ||
|
||
名前を指定して、引数のパラメータ参照に代入する。 | ||
存在しないパラメータの場合、falseが返る。 | ||
|
||
##### 3 | ||
|
||
``` | ||
template<typename ParameterT> | ||
bool get_parameter(const std::string & name, ParameterT & parameter) const | ||
``` | ||
|
||
2のパラメータ型をテンプレートで指定するバージョン。 | ||
名前を指定して、引数の生パラメータ型の参照に代入する。 | ||
存在しないパラメータの場合、falseが返る。 | ||
テンプレートで指定したパラメータ型と取得しようとしているパラメータの型が異なる場合、`rclcpp::ParameterTypeException`を送出する。 | ||
|
||
##### 4 | ||
``` | ||
template<typename ParameterT> | ||
bool | ||
get_parameter_or( | ||
const std::string & name, | ||
ParameterT & parameter, | ||
const ParameterT & alternative_value) const | ||
``` | ||
|
||
3のラッパーで、3の返り値がfalseのときに3番目の引数を返す。 | ||
パラメータが宣言されていないときに自動で宣言してくれるような機能はない。 | ||
返り値はROS空間からパラメータを取得できたかどうか(=alternative_valueが使われたときはfalseが返る) | ||
他のget_parameterと違って実装はnode_impl.hppにあるので注意。 | ||
|
||
##### 5 | ||
|
||
``` | ||
template<typename ParameterT> | ||
ParameterT | ||
get_parameter_or( | ||
const std::string & name, | ||
const ParameterT & alternative_value) const | ||
``` | ||
|
||
4のラッパーになっていて、パラメータを参照ではなく返り値で返してくれる。 |