ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

joint_.setCommand(commanded_effort) in the joint_position_controller

asked 2019-04-18 14:25:20 -0500

steradiant gravatar image

updated 2019-04-19 14:30:48 -0500

jayess gravatar image

Hello, I'm looking through the code of ros_control right now to get a deeper understanding how all that stuff works. In my opinion, I got quite far but now I'm stuck. I'm analyzing the effort_controllers/src/joint_position_controller.cpp at the moment. And in line 217 I found this:

joint_.setCommand(commanded_effort);

The steps before are clear, you publish to the topic, the error is computed, then the effort is computed and then it seems to be sent to the joint but when I look into the setCommand in hardware_interface/include/hardware_interface/joint_command_interface.h, I just find

void setCommand(double command) {assert(cmd_); *cmd_ = command;}

and there is no .cpp file which implements this function. So what is happening here?

edit retag flag offensive close merge delete

Comments

1

Can you please update your question with links to the lines that you're referring to? It makes it easier to follow your question

jayess gravatar image jayess  ( 2019-04-18 16:45:54 -0500 )edit

I've updated my post now. Hope it is kinda clear what I'm asking.

steradiant gravatar image steradiant  ( 2019-04-19 13:49:33 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-04-05 22:11:44 -0500

RyanChen.YLC gravatar image

Hi, I have same question now, but I read the code, and found that command is written into pointer cmd_, and this pointer is defined when the constructor of JointHandle is called.

Then the class, JointHandle, will be registered, so I think this is the way that controller builds connection with the hardware interface.

I'm not sure what I said above is correct, but I think it may help.

edit flag offensive delete link more
0

answered 2019-04-19 14:35:08 -0500

jayess gravatar image

updated 2019-04-19 14:36:42 -0500

That is the implementation of the setCommand method. It's just written on one line. Maybe it'll be clearer if it's separated out onto multiple lines

void setCommand(double command)
{
    assert(cmd_);
    *cmd_ = command;
}

Many times, if a method is short, it's implementation is left in a header (*.h) file.

edit flag offensive delete link more

Comments

The command is set to where cmd_ points to. But I wasn't able to dig deeper whats happening with this cmd_

steradiant gravatar image steradiant  ( 2019-04-20 00:17:34 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-04-18 14:25:20 -0500

Seen: 399 times

Last updated: Apr 05 '22