Step 4 – Explaining the controller source file

In this section, we can see the explanation of each section of the code:

/// Controller initialization in non-real-time 
bool MyControllerClass::init(hardware_interface::PositionJointInterface* hw, ros::NodeHandle &n) 
{ 

The preceding is the init() function definition of the controller. This will be called when a controller is loaded by the controller manager. Inside the init() function, we are creating an instance of the state of the robot (hw) and NodeHandle, and we also get the manager of the joint interacting with the controller. In our example, we defined the joint to control in the my_contoller.yaml file, loading the joint name into the ROS parameter server. This function returns the success ...

Get Mastering ROS for Robotics Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.