0

Rosanswers logo

I am trying to use parameters specified in my .launch.py file, but a ParameterNotDeclaredException is thrown when accessing any parameter. Does anyone know why? I try to access the parameters like this from within my Node:

self.get_parameter('buffer_size')

Here is the launch file. I'm using Foxy and Python

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description(): return LaunchDescription([ Node( package='blackfly_calibration', executable='broadcaster', parameters=[ {"capture_frequency": 20.0}, {"buffer_size": 10}, {"image_topic": "/camera/image_raw"} ], ) ])


Originally posted by rosnoob145 on ROS Answers with karma: 13 on 2021-08-15

Post score: 0

1 Answers1

0

Rosanswers logo

Before calling get_parameter, you had need to call;

self.declare_parameter(“buffer_size”,0)

Here you initialize buffer_size with a default value of 0, you can set a desired default parameter.


Originally posted by Fetullah Atas with karma: 819 on 2021-08-16

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by rosnoob145 on 2021-08-16:
thank you so much!

fet.atas
  • 418
  • 1
  • 1
  • 1