Launch node action. Whats the difference between arguments and parameters?

Hi,

When we start a node from a launch file it accepts like options “arguments” and “parameters” and I don’t know the difference between them.
I had the idea that arguments are provided from the command line to the launch file and that you can pass parameters to a node. But I don’t understand to pass arguments to a node.

Can someone clarify me this doubt?

Regards.

Hi @joseecm ,

To simply describe,
arguments: these are the values that you provide to a function when you call that function.
parameters: these are the values that you provide to a function when the function is declared in the program

Example for Parameters:

# Python
def function(a: int, b: float, c: chr)  # a, b, c are parameters
    d = a * b * ord(c)
    return d
// C++
double function(int a, float b, char c)  // a, b, c are parameters
{
    double d = (double)(a * b * int(c));
    return d;
}

Example for Arguments:

# Python:
if __name__ == "__main__":
    res = function(a=1, b=3.14159, c='x')  # 1, 3.14159, 'x' are arguments
// C++
int main(int argc, char** argv) {
    double res;
    res = function(1, 3.14159, 'x')  // 1, 3.14159, 'x' are arguments
    return 0;
}

So, within a launch file in your case, when you define arguments, you are actually providing values to the functions that use the keyword parameter.
Example:

arguments=["-resolution", 0.01,
           "-keyword1", value1,
           "-keyword2", value2]
# function parameters are {resolution, keyword1, keyword2}
# and 
# function arguments are {0.01, value1, value2}

# you are NOT setting parameters - these keywords are already set
# you are setting the arguments - these are values that you set
# hence you define arguments=[...] (and not parameters=[...])

I hope this clarifies your doubts.

Regards,
Girish

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.