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