Troubles with ros_control
Hello. I have two motors for a future robot and I want them to use the same RobotHW class. That motors have to run simultaneously. Also there are some code for only one motor. When I tried to implement the second one, a conflict error popped out. Here is the code :
void ROBOTHardwareInterface::init() {
// Create joint state interface
hardware_interface::JointStateHandle jointStateHandle("joint1", &joint_position_, &joint_velocity_, &joint_effort_);
joint_state_interface_.registerHandle(jointStateHandle);
// Create effort joint interface
hardware_interface::JointHandle jointEffortHandle(jointStateHandle, &joint_effort_command_);
effort_joint_interface_.registerHandle(jointEffortHandle);
// Create Joint Limit interface
joint_limits_interface::JointLimits limits;
joint_limits_interface::getJointLimits("joint1", nh_, limits);
joint_limits_interface::EffortJointSaturationHandle jointLimitsHandle(jointEffortHandle, limits);
effortJointSaturationInterface.registerHandle(jointLimitsHandle);
// Create joint state interface
hardware_interface::JointStateHandle jointStateHandle2("joint2", &joint_position_2, &joint_velocity_2, &joint_effort_2);
joint_state_interface_.registerHandle(jointStateHandle2);
// Create Joint Limit interface
hardware_interface::JointHandle jointEffortHandle2(jointStateHandle2, &joint_effort_command_2);
effort_joint_interface_.registerHandle(jointEffortHandle2);
// Create joint limit interface.
joint_limits_interface::getJointLimits("joint2", nh_, limits);
joint_limits_interface::EffortJointSaturationHandle jointLimitsHandle2(jointEffortHandle2, limits);
effortJointSaturationInterface.registerHandle(jointLimitsHandle2);
// Register all joints interfaces
registerInterface(&joint_state_interface_);
registerInterface(&position_joint_interface_);
registerInterface(&effort_joint_interface_);
registerInterface(&effortJointSaturationInterface);
}
And here is the launchfile :
<node name="robot_hardware_interface" pkg="ros_control_example" type="single_joint_hardware_interface" output="screen"/>
<!--
<node name="driver" pkg="ros_control_example" type="driver_node" output="screen"/>
-->
<node name="subscriber_py" pkg="ros_control_example" type="joints_receive_from_arduino.py" output="screen"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen"
args="
/ROBOT/controller/velocity/joint1_velocity_controller
/ROBOT/controller/velocity/joint2_velocity_controller
"/>
That's controllers.yaml :
ROBOT:
# Publish all joint states -----------------------------------
controller:
type: joint_state_controller/JointStateController
publish_rate: 50
velocity:
# Velocity Controllers ---------------------------------------
joint1_velocity_controller:
type: effort_controllers/JointVelocityController
joint: joint1
pid: {p: 100.0, i: 100.0, d: 0.0, i_clamp_min: -255.0, i_clamp_max: 255, antiwindup: True}
# Velocity Controllers ---------------------------------------
joint2_velocity_controller:
type: effort_controllers/JointVelocityController
joint: joint1
pid: {p: 100.0, i: 100.0, d: 0.0, i_clamp_min: -255.0, i_clamp_max: 255, antiwindup: True}
What should I do?