Declaring parameter fails unless value and descriptor are provided
See original GitHub issueBug report
Required Info:
- Operating System:
- Ubuntu 18.04
- Installation type:
- From source
- Version or commit hash:
- 0be24021af4269ce7c83fe9db550e326a8428a9b
- DDS implementation:
- Fast-RTPS
- Client library (if applicable):
- rclpy
Steps to reproduce issue
Write the following node:
import rclpy
from rclpy.node import Node
class MyNode(Node):
def __init__(self):
super().__init__("foo")
self.declare_parameter("my_parameter")
def main(args=None):
rclpy.init(args=args)
node = MyNode()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()
if __name__ == "__main__":
main()
Expected behavior
The node should be completely useless, but run. And have a parameter available.
Actual behavior
Traceback with “rclpy.exceptions.ParameterNotDeclaredException: (‘Invalid access to undeclared parameter(s)’, ‘my_parameter’)”
Additional information
The only way this works is if one supplies the optional fields value
and descriptor
in the declare_parameter()
function. I’d say either these need to actually be optional and work by default, or actually be required in the API.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Parameters in Bicep files - Azure Resource Manager
You can define allowed values for a parameter. You provide the allowed values in an array. The deployment fails during validation if a...
Read more >Parameters - AWS CloudFormation
Parameters must be declared and referenced from within the same template. You can reference parameters from the Resources and Outputs sections of the...
Read more >Input Variables - Configuration Language | Terraform
Input variables allow you to customize modules without altering their source code. Learn how to declare, define, and reference variables in configurations.
Read more >MTA Deployment Descriptor Syntax - SAP Help Portal
If environment variables are used, one variable is created per map key, and the name of the variable equals the key value. Tip....
Read more >Documentation - Decorators - TypeScript
If we want to customize how a decorator is applied to a declaration, ... NOTE A Property Descriptor is not provided as an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Calling declare with just a name and no value is fine. It just defaults to the not set value. You can do this in rclcpp already. I think the rclpy signature should be updated to allow it. In the meantime you can just explicitly pass a default initialized parameter value there, which will have the same behavior.
Also setting a value to not set still undeclares it in dashing. See: https://github.com/ros2/rclcpp/blob/0ae3da49e705eb2a019704c85fd0bb15ec4e968b/rclcpp/include/rclcpp/node.hpp#L527