Dear Community,
I’m still confused about ros_control
, specifically the hardware_interface
. The tutorial of lesson 6 was great, and I tried to merge it with tutorial 3 to get some output.
my_robot_control.yaml
looks as in the tutorial:
rrbot:
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
joint1_position_controller:
type: effort_controllers/JointPositionController
joint: joint1
pid: {p: 100.0, i: 0.01, d: 10.0}
joint2_position_controller:
type: effort_controllers/JointPositionController
joint: joint2
pid: {p: 100.0, i: 0.01, d: 10.0}
I just modified my_robot_control.launch
slightly and integrated the launch commands from tutorial 6 to load the rrbot_hardware_interface
:
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="/rrbot" args="joint1_position_controller joint2_position_controller joint_state_controller"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
respawn="false" output="screen">
<remap from="/joint_states" to="/rrbot/joint_states" />
</node>
<node name="rrbot_hardware_interface" pkg="rrbot_hardware_interface" type="rrbot_hardware_interface_node">
<!-- Load standard controller joint names from YAML file to parameter server -->
<rosparam command="load" file="$(find rrbot_bringup)/config/joint_names.yaml" />
</node>
<!-- Load joint controller configurations from YAML file to parameter server -->
<rosparam command="load" file="$(find rrbot_bringup)/config/$(arg controllers_yaml).yaml" />
However I am confused about the write()
function of rrbot_hardware_interface.cpp
from tutorial 6:
bool RRBotHardwareInterface::write(const ros::Time time,
const ros::Duration period) {
// write command to hardware, in this example do mirror command to states
for (size_t i = 0; i < hw_position_commands_.size(); ++i) {
hw_position_states_[i] =
hw_position_states_[i] +
(hw_position_commands_[i] - hw_position_states_[i]) / 100.0;
}
I thought that the write()
function outputs the controller’s commands, meaning that if I assign a sine-wave to joint 1, some output should be written to the hw_position_commands_
.
As seem in this screenshot I just receive zeros for the hardware_interface, while joint 1 does a sine-wave in gazebo.
Therefore, my question: Assuming that the controller receives some input (e.g. sine wave), how can I verify that the controller and hardware_interface work correctly and print the commands in hw_position_commands_
?
Edit:
I understand that it is important to have a clear view of hardware and software setup, as explained in detail in this tutorial, however I’m still confused why the hw_position_commands_
does yield any output if I assign an input to the controller (e.g. diff_drive_controller
, as in image of the tutorial)