ros-industrial / ur_modern_driver

(deprecated) ROS 1 driver for CB1 and CB2 controllers with UR5 or UR10 robots from Universal Robots
Apache License 2.0
302 stars 340 forks source link

How does robot commands received send to robot? #303

Closed itfanr closed 5 years ago

itfanr commented 5 years ago

I have read the code on kinetic-devel branch and I am confused about the code :

The server with 50001 port reads the packets data and deals with it:

bool LowBandwidthTrajectoryFollower::execute(const std::array<double, 6> &positions,
                                             const std::array<double, 6> &velocities, double sample_number,
                                             double time_in_seconds)
{
  if (!running_)
    return false;

  std::ostringstream out;

  out << "(";
  out << sample_number << ",";
  for (auto const &pos : positions)
  {
    out << pos << ",";
  }
  for (auto const &vel : velocities)
  {
    out << vel << ",";
  }
  out << time_in_seconds << ")\r\n";

  // I know it's ugly but it's the most efficient and fastest way
  // We have only ASCII characters and we can cast char -> uint_8
  const std::string tmp = out.str();
  const char *formatted_message = tmp.c_str();
  const uint8_t *buf = (uint8_t *)formatted_message;

  size_t written;
  LOG_DEBUG("Sending message %s", formatted_message);

  return server_.write(buf, strlen(formatted_message) + 1, written);
}

In URServer class:

bool URServer::write(const uint8_t* buf, size_t buf_len, size_t& written)
{
  return client_.write(buf, buf_len, written);
}

How does packet send to the robot? I can only find the code above. And I cannot find it is convert to URCommander. Or, can you show me the architecture about the process?

Thank you.

gavanderhoorn commented 5 years ago

Are you specifically asking about the LowBandwidthTrajectoryFollower?

gavanderhoorn commented 5 years ago

As this is not an actual issue with the package in this repository, but a general question about an implementation detail, I'm going to close this issue.

You may keep commenting on it of course.

itfanr commented 5 years ago

@gavanderhoorn Thank you all the same.

If you have known about this, could you tell me the implementation detail ?

gavanderhoorn commented 5 years ago

You haven't answered my question:

Are you specifically asking about the LowBandwidthTrajectoryFollower?

itfanr commented 5 years ago

@gavanderhoorn I want know the function how does bool LowBandwidthTrajectoryFollower::execute send the command to real UR robot with 30001 port. I didnot find the code.

itfanr commented 5 years ago

@gavanderhoorn It must call URCommander or some code. But I cannot figure it out.