latency when using ros controller

asked 2020-05-18 05:27:35 -0500

dinesh gravatar image

updated 2020-05-18 05:27:58 -0500

I am using odorid c2 in my robot and controller along with arduino uno and nano in robot. i'm using analog joystick to send the twist data to the robot. What my problem is when i sent the twist commands directly to the robot via rosserial_arduino node, the motion is smooth and latency is not present that much. But when i send the twist command first to diff drive controller and than diff drive calculates the velocity, direction of motors and to robot, than their is lot of latency.

When i view the twist msg published by the diff drive controller, it is comming without any delay. But why is not the robot wheel not moving in same way smotthely? configuration file of diff dirve controller:

<?xml version="1.0"?>
<launch>

  <!-- GDB functionality -->
  <arg name="debug" default="false" />
  <arg unless="$(arg debug)" name="launch_prefix" value="" />
  <arg     if="$(arg debug)" name="launch_prefix" value="gdb --ex run --args" />

  <!-- Load example URDF -->
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find rrbot_description)/urdf/rrbot.xacro'" />

  <group ns="rrbot">

    <!-- Load hardware interface -->
    <node name="rrbot_hardware_interface" pkg="ros_control_boilerplate" type="rrbot_hw_main"
          output="screen" launch-prefix="$(arg launch_prefix)"/>

    <!-- Load controller settings -->
    <rosparam file="$(find ros_control_boilerplate)/rrbot_control/config/rrbot_controllers.yaml" command="load"/>

    <!-- Load controller manager -->
    <node name="ros_control_controller_manager" pkg="controller_manager" type="controller_manager" respawn="false"
      output="screen" args="spawn joint_state_controller mobile_base_controller" />

    <!-- Convert joint states to /tf tranforms -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
        <remap from="/joint_states" to="/rrbot/joint_states" />
    </node>
  </group>

</launch>

write function of hw_interface.cpp:

void RRBotHWInterface::write(ros::Duration &elapsed_time)
{
  // Safety
  enforceLimits(elapsed_time);

  // ----------------------------------------------------
  // ----------------------------------------------------
  // ----------------------------------------------------
  //
  // FILL IN YOUR WRITE COMMAND TO USB/ETHERNET/ETHERCAT/SERIAL ETC HERE
  //
  // FOR A EASY SIMULATION EXAMPLE, OR FOR CODE TO CALCULATE
  // VELOCITY FROM POSITION WITH SMOOTHING, SEE
  // sim_hw_interface.cpp IN THIS PACKAGE
  //
  // DUMMY PASS-THROUGH CODE
  for (std::size_t joint_id = 0; joint_id < num_joints_; ++joint_id) { 
    joint_velocity_[joint_id] += joint_velocity_command_[joint_id];
  }

  twist.linear.x = map(joint_velocity_command_[0],-1,1,-255,255); 
  twist.linear.y = map(joint_velocity_command_[1],-1,1,-255,255);

  pub.publish(twist);
  // END DUMMY CODE
  //
  // ----------------------------------------------------
  // ----------------------------------------------------
  // ----------------------------------------------------
}

i'm using ros melodic in ubuntu 18 mate in odroid c2. Is this happeneing cas of lack of processing power nedded? Is their any way i can remove this latency in motion of robot wheels?

edit retag flag offensive close merge delete

Comments

What is the output of the diff drive controller when there are no incoming Twist messages?

maxsvetlik gravatar image maxsvetlik  ( 2020-05-18 17:06:49 -0500 )edit

its 0,0 i.e for both wheel joints the Joint_comd_velocity are comming as 0. when i move the analog joystick and send value between 0 to 1 in float format of twist type than it produces non zero output. everything is working. only problem is the latency in motion by using rosserial_arduino node.

dinesh gravatar image dinesh  ( 2020-05-18 22:37:18 -0500 )edit