ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Why sendGoal is called with one parameter

asked 2017-11-02 22:13:51 -0600

Raj gravatar image

updated 2017-11-06 09:52:48 -0600

jayess gravatar image

sendGoal is defined with 4 parameters in simple_action_client.h but while using this API we call it with one parameter viz send Goal(goal). Why ?

Following is how it is defined in simple_action_client.h

void SimpleActionClient<ActionSpec>::sendGoal(const Goal& goal,
                                              SimpleDoneCallback     done_cb,
                                              SimpleActiveCallback   active_cb,
                                              SimpleFeedbackCallback feedback_cb)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-03 08:33:46 -0600

l4ncelot gravatar image

In simple_action_client.h it's defined like this:

void sendGoal(const Goal& goal,
                SimpleDoneCallback     done_cb     = SimpleDoneCallback(),
                SimpleActiveCallback   active_cb   = SimpleActiveCallback(),
                SimpleFeedbackCallback feedback_cb = SimpleFeedbackCallback());

In C++ you can specify default function argument value with = sign. It's an optional value and therefore doesn't need to be present while calling that function. If you don't specify one it will take the default value (e.g. SimpleDoneCallback()).

edit flag offensive delete link more


Got it. Thank you

Raj gravatar image Raj  ( 2017-11-04 15:24:34 -0600 )edit

@Raj please accept the answer above with the checkmark to the left so others know it's resolved.

tfoote gravatar image tfoote  ( 2017-11-06 18:47:28 -0600 )edit

@tfoote: I guess I did it before. Sorry if I missed it.

Raj gravatar image Raj  ( 2017-11-06 19:56:45 -0600 )edit

@Raj it's still not checked. Click on the checkmark itself (it will turn green) to indicate that it's resolved.

tfoote gravatar image tfoote  ( 2017-11-06 20:52:37 -0600 )edit

@tfoote I did and it's showing green to me.

Raj gravatar image Raj  ( 2017-11-06 20:55:43 -0600 )edit

Are you sure you got the check mark and not the upvote arrow? If you mouse over it should say "mark this answer as correct"

tfoote gravatar image tfoote  ( 2017-11-07 18:30:48 -0600 )edit

@tfoote Oh My bad. Sorry as I am new user. I hope now I did it correctly

Raj gravatar image Raj  ( 2017-11-07 18:35:08 -0600 )edit

No worries, there's always a learning curve for new interfaces. I'm glad you got your question answered quickly.

tfoote gravatar image tfoote  ( 2017-11-07 18:39:17 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-11-02 22:13:51 -0600

Seen: 132 times

Last updated: Nov 06 '17