Control quiz: the controller is registred properly but it cannot be loaded by the launch file

for now I’m only trying to get one controller working, that is the type of controller is the custom one instead of the test one, as can be seen in the yaml file.
whenever I launch the launch file I get:

and the custom controller doesn’t work.

This is my project_controller.cpp file

#include <controller_interface/controller.h>
#include <hardware_interface/joint_command_interface.h>
#include <pluginlib/class_list_macros.h>
namespace controller_ns {
class PositionController : public controller_interface::Controller<
hardware_interface::EffortJointInterface> {
public:
bool init(hardware_interface::EffortJointInterface *hw, ros::NodeHandle &n) {
std::string my_joint;
if (!n.getParam(“joint”, my_joint)) {
ROS_ERROR(“Could not find joint name”);
return famy_joint); // throws on failure
return true; voite(const ros::Time &time, const ros::Duration &period) {
double error = setpoint_ - joint_.getPosition();
joint_.setCommand(error * gain_);
}

  void starting(const ros::Time &time) {}
  void stopping(const ros::Time &time) {}

private:
  hardware_interface::JointHandle joint_;
  static constexpr double gain_ = 2.25;
  static constexpr double setpoint_ = 1.00;
};

PLUGINLIB_EXPORT_CLASS(controller_ns::PositionController,
                       controller_interface::ControllerBase);
} // namespace controller_ns

here quiz_control_custom.launch

<launch>

  <rosparam file="$(find project_controller)/config/project_controller.yaml" command="load"/>

  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/ur5" args="joint_state_controller
                                    shoulder_pan_joint_position_controller
					                shoulder_lift_joint_position_controller
					                elbow_joint_position_controller
                                    wrist_1_joint_position_controller
                                    wrist_2_joint_position_controller
                                    wrist_3_joint_position_controller"/>

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="/joint_states" to="/ur5/joint_states" />
  </node>

</launch>

and finally quiz_control_custom.launch

ur5:
  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50  

  shoulder_pan_joint_position_controller:
    type: project_controller/PositionController
    joint: shoulder_pan_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

  shoulder_lift_joint_position_controller:
    type: position_controllers/JointPositionController
    joint: shoulder_lift_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

  elbow_joint_position_controller:
    type: position_controllers/JointPositionController
    joint: elbow_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

  wrist_1_joint_position_controller:
    type: position_controllers/JointPositionController
    joint: wrist_1_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

  wrist_2_joint_position_controller:
    type: position_controllers/JointPositionController
    joint: wrist_2_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

  wrist_3_joint_position_controller:
    type: position_controllers/JointPositionController
    joint: wrist_3_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

Since the controller is properly registered and compiled I believe there must be an error in the cpp file that I didn’t spot, like something to change, for example the interface, but I cannot figure it out.
may I get a confirmation that what I’m using isn’t complete? thank you

Hello @patruska ,

I’ve been doing some tests with your packages and the controller does not compile. There are several syntax errors in the code. For instance:

if (!n.getParam("joint", my_joint)) {
      ROS_ERROR("Could not find joint name");
      return famy_joint); // throws on failure

The bracket “{” of the if statement is not closed, the famy_joint variable does not exist, the final closing parenthesis “)” is not correct…

I suggest you revisit Chapter 4 (Create a custom controller) to better understand how the code should be, or you can also check the solution provided to this Quiz.

Hope this helps,

Buenas, I was deceived by the fact that I can compile the controller and it gets registered, don’t know what’s happens.
Thank you, I’ll did deeper in the unit 4

Hi @patruska,

I faced the same problem while doing the quiz, and I think it is because of the hardware interface you use for your custom controller. If you check the xacro files of the UR5, you will find that it doesn’t use EffortJointInterface.

Also, since the custom controller is basically a position_controllers/JointPositionController, it outputs position commands. Therefore, it should communicate with a joint that uses a position interface.

Cheers,
Jose