Initialization of the controller

The first function executing when a controller is loaded is init(). The init() function will not start running the controller. The initialization can take any amount of time before starting the controllers. The declaration of the init function is given as follows:

 virtual bool init(pr2_mechanism_model::RobotState *robot,
ros::NodeHandle &n);

This method will not run as real time.

The function arguments are given as follows:

  • pr2_mechanism_model::  RobotState *robot:  The pr2_mechanism_model contains the robot model that can be used by the robot controller.
    The pr2_mechanism_model:: RobotState class helps us to access the
    joints of the robot model and kinematic/dynamic description of robot.
  • ros::NodeHandle &n: The controller can read the robot configuration and even advertise topics using this Nodehandle.

The init() method only executes once while the controller is loaded by the controller manager. If the init() method is not successful, it will unload from the controller manager. We can write a custom message if any error occurs inside the init() method.

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

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