launch file wont load my wont load my own controller
Hello,
I have created my own basic controller and my goal is to load it into a 2 links robot that I created too. I have created the configuration files using moveit and then created my .yawl and .launch in order to run this. My problem is that whenever I launch the launch script this warning appears and my controllers are missing. I did
rosservice list | grep controller_manager
to see if controllers are loaded but nothing... could someone help me to find my problem? I have doubts about if this can be done using only rviz or do I need to use gazebo to test my controller?
my scripts, yaml:
# Publish joint_states
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
controller_list:
name: rob_arm_controller
type: my_controller/MyPositionController
default: true
joints:
- joint1
- joint2
gains:
joint1:
gain: 0.1
joint2:
gain: 0.1
my controller:
#include <controller_interface/controller.h>
#include <hardware_interface/joint_command_interface.h>
#include </opt/ros/noetic/include/pluginlib/class_list_macros.h>
#include <std_msgs/Float64.h>
namespace my_controller_ns
{
class MyPositionController : public controller_interface::Controller<hardware_interface::PositionJointInterface>
{
bool init(hardware_interface::PositionJointInterface* hw, ros::NodeHandle &n)
{
// get the joint to control specified in the config file
// load the name of the joint of the config file into the parameter server
std::string my_joint;
if (!n.getParam("joint", my_joint))
{
ROS_ERROR("Could not find joint name");
return false;
}
//once having the joints go to hardware interface and say which joint is asociated with which hardware
joint_ = hw->getHandle(my_joint); // throws on failure
//get the current position of the joint from controller and pass next command
command_ = joint_.getPosition(); //set current joint goal
//load gain using gains set on parameter server
if( !n.getParam("gain", gain_))
{
ROS_ERROR("Could not find the gain parameter value");
return false;
}
//start command suscriber with command topic, setcommand is a callback function that gets the topic data
sub_command_ = n.subscribe<std_msgs::Float64>("command", 1 , &MyPositionController::setCommandCallBack, this);
return true;
}
private:
hardware_interface::JointHandle joint_;
double gain_;
double command_;
ros::Subscriber sub_command_;
//CONTROL!!!!
void update(const ros::Time& time, const ros::Duration& period)
{
double error = command_ - joint_.getPosition();
double commanded_pos= error*gain_;
joint_.setCommand(commanded_pos);
}
//callback para pasar la posicion siguiente del robot
void setCommandCallBack(const std_msgs::Float64ConstPtr& msg)
{
command_ = msg->data;
}
void starting(const ros::Time& time) {}
void stopping(const ros::Time& time) {}
};
PLUGINLIB_EXPORT_CLASS(my_controller_ns::MyPositionController, controller_interface::ControllerBase);
}
and my launch file:
<!-- static tf for robot root -->
<node pkg="tf2_ros" type="static_transform_publisher" name="virtual_joint_broadcaster_0" args="0 0 0 0 0 0 world base_link" />
<!-- robot description-->
<param name="robot_description" command="cat $(find planar_control)/urdf/rob.urdf"/>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find planar_moveit_config)/launch/moveit.rviz "/>
<!-- specify the planning pipeline -->
<arg name="pipeline" default="ompl" />
<!-- robot_description -->
<arg name="load_robot_description" default="true"/>
<!-- Set the param that trajectory_execution_manager needs to find the controller plugin -->
<arg name="moveit_controller_manager" default="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
<param name="moveit_controller_manager" value="$(arg moveit_controller_manager)"/>
<!-- load controller_list -->
<rosparam file="$(find planar_moveit_config)/config/my_controller.yaml"/>
<!-- Run the main MoveIt executable without trajectory execution -->
<include file="$(dirname)/move_group.launch">
<arg name="allow_trajectory_execution" value="true"/>
<arg name="info" value="true"/>
<arg name="pipeline" value="$(arg pipeline)"/>
<arg name="load_robot_description" value="$(arg load_robot_description) "/>
</include>
<!-- load controller_list -->
<rosparam file="$(find planar_moveit_config)/config/my_controller.yaml"/>
If more information is needed, ask me! I'm having a hard time here with this controller issues
Thanks in advance!
Asked by mikell on 2022-12-19 11:39:57 UTC
Comments