1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 18:10:47 +02:00

Fixed minor issues

This commit is contained in:
Simon Rasmussen
2017-04-15 01:45:29 +02:00
parent dd8169d371
commit b4bb424058
7 changed files with 58 additions and 46 deletions

View File

@@ -16,7 +16,7 @@ bool RobotHardware::canSwitch(const std::list<ControllerInfo>& start_list,
if(it == interfaces_.end() || it->second != active_interface_)
return false;
}
for (auto const& ci : start_list)
{
auto it = interfaces_.find(ci.hardware_interface);
@@ -29,43 +29,39 @@ bool RobotHardware::canSwitch(const std::list<ControllerInfo>& start_list,
}
*/
void RobotHardware::doSwitch(const std::list<ControllerInfo>& start_list,
const std::list<ControllerInfo>& stop_list)
void RobotHardware::doSwitch(const std::list<ControllerInfo>& start_list, const std::list<ControllerInfo>& stop_list)
{
if(active_interface_ != nullptr && stop_list.size() > 0)
if (active_interface_ != nullptr && stop_list.size() > 0)
{
LOG_INFO("Stopping active interface");
active_interface_->stop();
active_interface_ = nullptr;
}
for(auto const& ci : start_list)
for (auto const& ci : start_list)
{
auto it = interfaces_.find(ci.hardware_interface);
if(it == interfaces_.end())
continue;
//we can only switch to one of the available interfaces
if(std::find(available_interfaces_.begin(), available_interfaces_.end(), it->second) == available_interfaces_.end())
auto ait = available_interfaces_.find(ci.hardware_interface);
if (ait == available_interfaces_.end())
continue;
auto new_interface = static_cast<HardwareInterface*>(it->second);
auto new_interface = ait->second;
if(new_interface == nullptr)
continue;
LOG_INFO("Starting %s", ci.hardware_interface.c_str());
active_interface_ = new_interface;
new_interface->start();
return;
}
LOG_WARN("Failed to start interface!");
}
void RobotHardware::write()
{
if(active_interface_ == nullptr)
if (active_interface_ == nullptr)
return;
active_interface_->write();
}

View File

@@ -91,8 +91,14 @@ bool RTPublisher::publishTemperature(RTShared& packet, Time& t)
bool RTPublisher::publish(RTShared& packet)
{
Time time = Time::now();
return publishJoints(packet, time) && publishWrench(packet, time) && publishTool(packet, time) &&
publishTransform(packet, time) && publishTemperature(packet, time);
bool res = true;
if (!temp_only_)
{
res = publishJoints(packet, time) && publishWrench(packet, time) && publishTool(packet, time) &&
publishTransform(packet, time);
}
return res && publishTemperature(packet, time);
}
bool RTPublisher::consume(RTState_V1_6__7& state)