mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
various improvements and fixes for use_ros_control=true (#6)
* Find matching hardware_interface using the required type The name of the controller was used in order to find and start the matching hardware interface. In consequence this meant that one could only define one controller for each hardware interface. Now, the controller's required type of hardware interface is used to find and start the matching hardware interface. * separate read & update in controller consume is defined as read+update, but update does not include read in ros_control terminology. * Handle latency in pipeline loop The controllers need to update at a rate of *at least* 125Hz, but the wait_dequeue_timed call could in theory slow the loop down to 62.5Hz. The old ur_modern_driver worked around this problem by sending goals at 4*125Hz. This patch exploits the onTimeout method of a consumer to update with the specified frequency of the control loop, even if no new state message arrived after the previous command. * publish wrench w.r.t. tcp frame The messages had an empty frame_id before and could not be displayed in RViz * support ros_control in indigo
This commit is contained in:
committed by
Simon Rasmussen
parent
ef7aca7fb9
commit
e4a503fe5f
@@ -126,7 +126,7 @@ private:
|
||||
{
|
||||
if (!queue_.try_enqueue(std::move(p)))
|
||||
{
|
||||
LOG_ERROR("Pipeline producer owerflowed!");
|
||||
LOG_ERROR("Pipeline producer overflowed!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,27 +141,18 @@ private:
|
||||
{
|
||||
consumer_.setupConsumer();
|
||||
unique_ptr<T> product;
|
||||
Time last_pkg = Clock::now();
|
||||
Time last_warn = last_pkg;
|
||||
while (running_)
|
||||
{
|
||||
// 16000us timeout was chosen because we should
|
||||
// roughly recieve messages at 125hz which is every
|
||||
// 8ms so double it for some error margin
|
||||
if (!queue_.wait_dequeue_timed(product, std::chrono::milliseconds(16)))
|
||||
// timeout was chosen because we should receive messages
|
||||
// at roughly 125hz (every 8ms) and have to update
|
||||
// the controllers (i.e. the consumer) with *at least* 125Hz
|
||||
// So we update the consumer more frequently via onTimeout
|
||||
if (!queue_.wait_dequeue_timed(product, std::chrono::milliseconds(8)))
|
||||
{
|
||||
Time now = Clock::now();
|
||||
auto pkg_diff = now - last_pkg;
|
||||
auto warn_diff = now - last_warn;
|
||||
if (pkg_diff > std::chrono::seconds(1) && warn_diff > std::chrono::seconds(1))
|
||||
{
|
||||
last_warn = now;
|
||||
consumer_.onTimeout();
|
||||
}
|
||||
consumer_.onTimeout();
|
||||
continue;
|
||||
}
|
||||
|
||||
last_pkg = Clock::now();
|
||||
if (!consumer_.consume(std::move(product)))
|
||||
break;
|
||||
}
|
||||
@@ -201,4 +192,4 @@ public:
|
||||
pThread_.join();
|
||||
cThread_.join();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user