ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Ok I've solved this problem and I would like share it since a lot of people are complaining. The errors come usually as
1- Controller Spawner couldn't find the expected controller_manager ROS interface.
2- Failed to initialize the controller
3- Initializing controller 'joint1_position_controller' failed
This error pops up from different sources. First, make sure you installed all related control packages
ros-<rosdistro>-ros-control ros-<rosdistro>-ros-controllers ros-<rosdistro>-gazebo-ros ros-<rosdistro>-gazebo-ros-control
Second, if you are using namespace
as in the following line which is located in .urdf
file
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/rrbot</robotNamespace>
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
</plugin>
</gazebo>
Make sure you are using the same namespace
in .launch
and .yaml
files which appears as ns="/rrbot"
<node name="control_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="/rrbot" args="joint1_position_controller"/>
and the .yaml
may look like this
rrbot:
# Publish all joint states ------------------------
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
# Position Controllers ----------------------------
joint1_position_controller:
type: my_controller/MyPositionController
joint: joint1
gain: 0.1
If you are using your own plugin controller, you better check it is registered which can be done as (i.e. source your catkin_ws folder first)
rospack plugins --attrib=plugin controller_interface | grep my_controller
you should except to get something like this
my_controller /home/xxx/Desktop/RosControllers/catkin_ws1/src/my_controller/controller_plugins.xml
In my case none of the above solutions solved my problem. The interesting thing I found getParam()
is not getting the correct joint name which in the source file as
bool MyPositionController::init(hardware_interface::EffortJointInterface* hw, ros::NodeHandle &n)
{
// retrieve the joint object to control
std::string joint_name;
if( !n.getParam("joint1", joint_name) ){
ROS_ERROR("No joint name specified");
return false;
}
....
}
when I type "joint" rather than "joint1" which represents the joint's name in my .urdf
, the error gone. I've seen some books use "joint_name"
which yields an error as well. I'm not sure if this is a new update or these books use old ros version which uses joint_name
rather than joint
. I'm using Gazebo 9 and Melodic in Ubuntu 18.04.