Creating Controller Plugin No joint_name specified
I'm having an issue with making the plugin works in Gazebo 9 and melodic in ubuntu 18.04. I'm keep getting these errors
[ERROR] [1653189634.080473330, 0.379000000]: No joint_name specified
[ERROR] [1653189634.080611896, 0.379000000]: Failed to initialize the controller
[ERROR] [1653189634.080791301, 0.379000000]: Initializing controller 'joint1_position_controller' failed
[INFO] [1653189634.710451, 1.015000]: Calling service /gazebo/set_model_configuration
[INFO] [1653189634.717597, 1.019000]: Set model configuration status: SetModelConfiguration: success
[spawn_urdf-4] process has finished cleanly
log file: /home/bandar/.ros/log/214f367c-d97e-11ec-baf2-f07bcb42944d/spawn_urdf-4*.log
[ERROR] [1653189635.082707, 1.369000]: Failed to load joint1_position_controller
For controller_plugins.xml
file, I have
<library path="lib/libmy_controller_lib">
<class name="my_position_controller/MyPositionController"
type="my_controller_ns::MyPositionController"
base_class_type="controller_interface::ControllerBase" />
</library>
I'm not sure what needs to be written in class name=
. Should I type the name of the package or the name of namespace in my class? I've tried both but with no success. The shared library has been created successfully though. My source file is
namespace my_controller_ns
{
class MyPositionController : public controller_interface::Controller<hardware_interface::EffortJointInterface>
{...}
}
The .yaml
file is
rrbot:
# Publish all joint states ------------------------
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
# Position Controllers ----------------------------
joint1_position_controller:
type: my_position_controller/MyPositionController
joint: joint1
gain: 0.1
I'm totally sure the name of the joint is joint1
and this is my source file related to this part
// retrieve the joint object to control
std::string joint_name;
if( !n.getParam("joint1", joint_name) ){
ROS_ERROR("No joint_name specified");
return false;
}
joint_ = hw->getHandle(joint_name);
command_ = joint_.getPosition();
When I run
>rospack plugins --attrib=plugin controller_interface
I get this listed
my_position_controller /home/xxx/Desktop/RosControllers/catkin_ws1/src/my_position_controller/controller_plugins.xml
I also made sure the gazebo_ros and transmission tags are added
<!-- ***** Transmission Tags ***** -->
<transmission name="transmission1">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor1">
<hardwareInterface>EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<!-- ros_control pluging -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/rrbot</robotNamespace>
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
</plugin>
</gazebo>
Moreover, the namespace is consistent with the launch file
<node name="control_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="/rrbot" args="joint_state_controller joint1_position_controller"/>