Step 2 – Creating controller header file

We will get the header file my_controller_file.h from the chapter_6_codes/my_controller_pkg/include/my_controller_pkg folder.

Given in the following is the header file definition of my_controller_file.h. We have discussed each line of this code while discussing pr2_controller_interface:

#include <pr2_controller_interface/controller.h>
#include <pr2_mechanism_model/joint.h>


namespace my_controller_ns{


//Inheriting Controller class inside pr2_controller_interface
class MyControllerClass: public pr2_controller_interface::Controller
{
private:
pr2_mechanism_model::JointState* joint_state_;
double init_pos_;


public:


virtual bool init(pr2_mechanism_model::RobotState *robot,
ros::NodeHandle &n);
virtual void starting();
virtual void update();
virtual void stopping();
};
}

In the preceding code, we can see the controller class MyControllerClass and we are inheriting the base class pr2_controller_interface::Controller. We can see that each function inside the Controller class is overriding in our class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.27.244