question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Declaring parameter fails unless value and descriptor are provided

See original GitHub issue

Bug 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wjwwoodcommented, Jun 12, 2019

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.

0reactions
wjwwoodcommented, Jun 12, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found