Skip to content

Commit 6328200

Browse files
authored
Fixes for windows (#443)
* 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
1 parent 84c1e20 commit 6328200

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ void ControllerManager::configure_controller_service_cb(
890890
RCLCPP_DEBUG(
891891
get_logger(), "configuring service called for controller '%s' ", request->name.c_str());
892892
std::lock_guard<std::mutex> guard(services_lock_);
893-
RCLCPP_DEBUG(get_logger(), "loading service locked");
893+
RCLCPP_DEBUG(get_logger(), "configuring service locked");
894894

895895
response->ok =
896896
configure_controller(request->name) == controller_interface::return_type::OK;
@@ -1153,7 +1153,9 @@ ControllerManager::RTControllerListWrapper::update_and_get_used_by_rt_list()
11531153
std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_unused_list(
11541154
const std::lock_guard<std::recursive_mutex> &)
11551155
{
1156-
assert(controllers_lock_.try_lock());
1156+
if (!controllers_lock_.try_lock()) {
1157+
throw std::runtime_error("controllers_lock_ not owned by thread");
1158+
}
11571159
controllers_lock_.unlock();
11581160
// Get the index to the outdated controller list
11591161
int free_controllers_list = get_other_list(updated_controllers_index_);
@@ -1166,15 +1168,19 @@ std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_un
11661168
const std::vector<ControllerSpec> & ControllerManager::RTControllerListWrapper::get_updated_list(
11671169
const std::lock_guard<std::recursive_mutex> &) const
11681170
{
1169-
assert(controllers_lock_.try_lock());
1171+
if (!controllers_lock_.try_lock()) {
1172+
throw std::runtime_error("controllers_lock_ not owned by thread");
1173+
}
11701174
controllers_lock_.unlock();
11711175
return controllers_lists_[updated_controllers_index_];
11721176
}
11731177

11741178
void ControllerManager::RTControllerListWrapper::switch_updated_list(
11751179
const std::lock_guard<std::recursive_mutex> &)
11761180
{
1177-
assert(controllers_lock_.try_lock());
1181+
if (!controllers_lock_.try_lock()) {
1182+
throw std::runtime_error("controllers_lock_ not owned by thread");
1183+
}
11781184
controllers_lock_.unlock();
11791185
int former_current_controllers_list_ = updated_controllers_index_;
11801186
updated_controllers_index_ = get_other_list(former_current_controllers_list_);

controller_manager/test/test_controller/test_controller.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class TestController : public controller_interface::ControllerInterface
6262
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
6363
on_cleanup(const rclcpp_lifecycle::State & previous_state) override;
6464

65+
CONTROLLER_MANAGER_PUBLIC
6566
void set_command_interface_configuration(
6667
const controller_interface::InterfaceConfiguration & cfg);
6768

hardware_interface/include/fake_components/generic_system.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ using hardware_interface::return_type;
3333
namespace fake_components
3434
{
3535

36-
class GenericSystem : public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
36+
class HARDWARE_INTERFACE_PUBLIC GenericSystem
37+
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
3738
{
3839
public:
3940
return_type

hardware_interface/include/hardware_interface/resource_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SensorInterface;
3333
class SystemInterface;
3434
class ResourceStorage;
3535

36-
class ResourceManager
36+
class HARDWARE_INTERFACE_PUBLIC ResourceManager
3737
{
3838
public:
3939
/// Default constructor for the Resource Manager.

0 commit comments

Comments
 (0)