Skip to content

Commit

Permalink
Fixes for windows (#443)
Browse files Browse the repository at this point in the history
* Fix building on windows
* Fix MSVC linker error when building tests
* Fix hang when loading controller on windows
* Use better log for configuring controller
* Be consistent with visibility control
* Use try_lock throw exception on failure
  • Loading branch information
Ace314159 authored Jul 2, 2021
1 parent 84c1e20 commit 6328200
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
14 changes: 10 additions & 4 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void ControllerManager::configure_controller_service_cb(
RCLCPP_DEBUG(
get_logger(), "configuring service called for controller '%s' ", request->name.c_str());
std::lock_guard<std::mutex> guard(services_lock_);
RCLCPP_DEBUG(get_logger(), "loading service locked");
RCLCPP_DEBUG(get_logger(), "configuring service locked");

response->ok =
configure_controller(request->name) == controller_interface::return_type::OK;
Expand Down Expand Up @@ -1153,7 +1153,9 @@ ControllerManager::RTControllerListWrapper::update_and_get_used_by_rt_list()
std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_unused_list(
const std::lock_guard<std::recursive_mutex> &)
{
assert(controllers_lock_.try_lock());
if (!controllers_lock_.try_lock()) {
throw std::runtime_error("controllers_lock_ not owned by thread");
}
controllers_lock_.unlock();
// Get the index to the outdated controller list
int free_controllers_list = get_other_list(updated_controllers_index_);
Expand All @@ -1166,15 +1168,19 @@ std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_un
const std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_updated_list(
const std::lock_guard<std::recursive_mutex> &) const
{
assert(controllers_lock_.try_lock());
if (!controllers_lock_.try_lock()) {
throw std::runtime_error("controllers_lock_ not owned by thread");
}
controllers_lock_.unlock();
return controllers_lists_[updated_controllers_index_];
}

void ControllerManager::RTControllerListWrapper::switch_updated_list(
const std::lock_guard<std::recursive_mutex> &)
{
assert(controllers_lock_.try_lock());
if (!controllers_lock_.try_lock()) {
throw std::runtime_error("controllers_lock_ not owned by thread");
}
controllers_lock_.unlock();
int former_current_controllers_list_ = updated_controllers_index_;
updated_controllers_index_ = get_other_list(former_current_controllers_list_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TestController : public controller_interface::ControllerInterface
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
on_cleanup(const rclcpp_lifecycle::State & previous_state) override;

CONTROLLER_MANAGER_PUBLIC
void set_command_interface_configuration(
const controller_interface::InterfaceConfiguration & cfg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ using hardware_interface::return_type;
namespace fake_components
{

class GenericSystem : public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
class HARDWARE_INTERFACE_PUBLIC GenericSystem
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
{
public:
return_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SensorInterface;
class SystemInterface;
class ResourceStorage;

class ResourceManager
class HARDWARE_INTERFACE_PUBLIC ResourceManager
{
public:
/// Default constructor for the Resource Manager.
Expand Down

0 comments on commit 6328200

Please sign in to comment.