Skip to main content

ros2-parameters

ROS 2 parameter declare/get, YAML overlays, wildcards, type coercion, and empty-array pitfalls. Use when params are ignored, wrong type, YAML does not load, or the user mentions declare_parameter, allow_undeclared, or empty arrays.

معلومات المصدر

المستودع
guilyx/dotfiles
آخر نشاط في المصدر
١٢ أغسطس ٢٠٢٦ في ١٩:٣٩
لغة SKILL.md المكتشفة
الإنجليزية
النجوم
٠
التفرعات
٠

خيارات التثبيت

يُحدَّد Prompt الذي يراجع المصدر أولًا بشكل افتراضي. يمكنك التبديل إلى أمر مباشر أو تنزيل نسخة محلية.

مراجعة ملفات المصدر

اقرأ SKILL.md وأي ملفات مرافقة يعرضها SkillsMP قبل أن تقرر التثبيت.

عرض SKILL.md

SKILL.md
تعليمات المصدر · معاينة للقراءة فقط
name
ros2-parameters
description
ROS 2 parameter declare/get, YAML overlays, wildcards, type coercion, and empty-array pitfalls. Use when params are ignored, wrong type, YAML does not load, or the user mentions declare_parameter, allow_undeclared, or empty arrays.
# ROS 2 Parameters ## Declare first Undeclared params are **ignored** (or rejected) unless `allow_undeclared_parameters`. Always `declare_parameter` (with type/default) before `get`. Overrides win in this order (typical): 1. Node default in code 2. YAML from launch 3. Launch `parameters=[{...}]` dict 4. CLI `--ros-args -p foo:=bar` / `--params-file` ## YAML shape ```yaml /ns/node_name: ros__parameters: rate_hz: 30.0 frame_id: base_link nested: enabled: true ``` - Key must match **fully qualified node name** (namespace + name). Mismatch = silent unused file. - `/**:` wildcards apply broadly — easy to stomp unrelated nodes. - Lists: `[]` is untyped. rclpy/rclcpp may infer `byte[]` vs `string[]` vs `double[]` **wrong**. Empty arrays have bitten SIRB (`fix/empty-parameter-arrays`): prefer a non-empty typed default in `declare_parameter`, or pass typed CLI, or avoid empty as the declared default. ## Types - YAML `1` is int, `1.0` is double. `declare_parameter("x", 1.0)` then YAML `x: 1` can **fail** type check. - Bool: `true`/`false`, not `True`/`yes`. - Nested dicts → nested params (`nested.enabled`), not a single dict object in C++. ## Runtime `ros2 param set` only works if declared (and dynamic callback allows it). Use `add_on_set_parameters_callback` and reject invalid ranges. `ros2 param dump /node` to see what the node actually has — not what you think the YAML said. ## Launch Multiple YAML files + dicts: **last wins per key**. `use_sim_time` forgotten on one node → TF/clock bugs (`ros2-tf-clock`).
عرض على GitHub