Skip to content

Commit f6e56ce

Browse files
authored
Merge pull request #58 from kroshu/fix/combine_parameters
Fix/combine parameters
2 parents 907dd79 + deca703 commit f6e56ce

File tree

11 files changed

+239
-125
lines changed

11 files changed

+239
-125
lines changed

kuka_driver_examples/eci_demo/launch/iisy_circle.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def generate_launch_description():
5454
robot_description = {'robot_description': robot_description_config}
5555

5656
rviz_config_file = get_package_share_directory(
57-
'kuka_iisy_support') + "/launch/urdf.rviz"
57+
'kuka_iisy_support') + "/config/urdf_planning_scene.rviz"
5858

5959
controller_config = (get_package_share_directory('kuka_rox_hw_interface') +
6060
"/config/ros2_controller_config.yaml")

kuka_rox_hardware_interface/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1414
add_compile_options(-Wall -Wextra -Wpedantic)
1515
endif()
1616

17+
# A few (transitive) dependencies are available only in one of the dependencies
18+
# Set flag to suppress linker error
19+
# TODO: find better solution
20+
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--copy-dt-needed-entries")
21+
1722
set(MOCK_KUKA_LIBS TRUE)
1823

1924
find_package(ament_cmake REQUIRED)
@@ -40,13 +45,15 @@ if(NOT MOCK_KUKA_LIBS)
4045
message("Using real kuka libs")
4146
add_definitions(-DNON_MOCK_SETUP)
4247
else()
48+
find_package(Protobuf)
4349
include_directories(include/mock)
4450
add_library(os-core-udp-communication SHARED
4551
src/mock/os-core-udp-communication/udp_replier_mock.cpp
4652
src/mock/os-core-udp-communication/udp_socket_mock.cpp)
4753

4854
add_library(motion-services-ecs-proto-api-cpp INTERFACE)
4955
target_include_directories(motion-services-ecs-proto-api-cpp INTERFACE include/mock)
56+
target_link_libraries(motion-services-ecs-proto-api-cpp INTERFACE protobuf::libprotobuf)
5057

5158
add_library(motion-external-proto-api-nanopb INTERFACE)
5259
target_include_directories(motion-external-proto-api-nanopb INTERFACE include/mock)
@@ -72,7 +79,7 @@ target_link_libraries(rox_control_node kuka_rox_hw_interface)
7279
add_executable(robot_manager_node
7380
src/robot_manager_node.cpp)
7481
ament_target_dependencies(robot_manager_node rclcpp kroshu_ros2_core sensor_msgs controller_manager controller_manager_msgs)
75-
target_link_libraries(robot_manager_node kuka_rox_hw_interface kroshu_ros2_core::communication_helpers)
82+
target_link_libraries(robot_manager_node kroshu_ros2_core::communication_helpers motion-services-ecs-proto-api-cpp)
7683

7784
pluginlib_export_plugin_description_file(hardware_interface kuka_rox_hw_interface.xml)
7885

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
robot_manager:
2+
ros__parameters:
3+
control_mode: 1
4+
client_ip: "0.0.0.0"
5+
controller_ip: "0.0.0.0"
6+
position_controller_name: "joint_trajectory_controller"
7+
impedance_controller_name: "joint_impedance_controller"
8+
torque_controller_name: "effort_controller"
9+
10+
# Control mode enums:
11+
# 1 - position control
12+
# 2 - cartesian overlay (not supported yet)
13+
# 3 - joint impedance control
14+
# 4 - cartesian impedance control (not supported yet)
15+
# 5 - torque control
16+
17+

kuka_rox_hardware_interface/config/iisy.urdf.xacro

Lines changed: 0 additions & 14 deletions
This file was deleted.

kuka_rox_hardware_interface/include/kuka_rox_hw_interface/robot_manager_node.hpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@
2929
#include "std_msgs/msg/bool.hpp"
3030

3131
#include "communication_helpers/service_tools.hpp"
32-
3332
#include "kroshu_ros2_core/ROS2BaseLCNode.hpp"
3433

34+
#include "kuka/ecs/v1/motion_services_ecs.grpc.pb.h"
35+
3536
namespace kuka_rox
3637
{
37-
3838
class RobotManagerNode : public kroshu_ros2_core::ROS2BaseLCNode
3939
{
4040
public:
4141
RobotManagerNode();
42+
~RobotManagerNode();
43+
4244

4345
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
4446
on_configure(const rclcpp_lifecycle::State &) override;
@@ -52,33 +54,34 @@ class RobotManagerNode : public kroshu_ros2_core::ROS2BaseLCNode
5254
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
5355
on_deactivate(const rclcpp_lifecycle::State &) override;
5456

55-
bool onControlModeChangeRequest(const std::string & control_mode);
56-
bool onControllerNameChangeRequest(
57-
const std::string & controller_name,
58-
const std::string & controller_name_param);
57+
bool onControlModeChangeRequest(int control_mode);
5958

6059
private:
60+
void ObserveControl();
61+
6162
rclcpp::Client<controller_manager_msgs::srv::SetHardwareComponentState>::SharedPtr
6263
change_hardware_state_client_;
6364
rclcpp::Client<controller_manager_msgs::srv::SwitchController>::SharedPtr
6465
change_controller_state_client_;
6566
rclcpp::CallbackGroup::SharedPtr cbg_;
6667
std::vector<std::string> controller_names_;
67-
std::map<std::string, std::vector<std::string>> control_mode_map_;
68+
std::map<int, std::vector<std::string>> control_mode_map_;
69+
70+
std::thread observe_thread_;
71+
std::atomic<bool> terminate_{false};
72+
#ifdef NON_MOCK_SETUP
73+
std::unique_ptr<kuka::ecs::v1::ExternalControlService::Stub> stub_;
74+
std::unique_ptr<grpc::ClientContext> context_;
75+
#endif
6876

6977
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<std_msgs::msg::Bool>> is_configured_pub_;
7078
std_msgs::msg::Bool is_configured_msg_;
7179

72-
73-
const std::string POSITION_CONTROL = "position";
74-
const std::string TORQUE_CONTROL = "torque";
75-
const std::string IMPEDANCE_CONTROL = "impedance";
76-
77-
const std::string POSITION_CONTROLLER_NAME_PARAM = "position_controller_name";
78-
const std::string IMPEDANCE_CONTROLLER_NAME_PARAM = "impedance_controller_name";
79-
const std::string TORQUE_CONTROLLER_NAME_PARAM = "torque_controller_name";
80-
81-
static constexpr bool is_joint_imp_contr_ = true;
80+
// There are two kinds of control modes with different number of necessary interfaces to be set:
81+
// - in standard modes (position, torque), only the control signal to the used interface (1)
82+
// - in impedance modes, the setpoint and the parameters describing the behaviour (2)
83+
static constexpr int STANDARD_MODE_IF_SIZE = 1;
84+
static constexpr int IMPEDANCE_MODE_IF_SIZE = 2;
8285
};
8386

8487
} // namespace kuka_rox

kuka_rox_hardware_interface/include/kuka_rox_hw_interface/rox_hardware_interface.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class KukaRoXHardwareInterface : public hardware_interface::SystemInterface
5858

5959
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;
6060

61+
CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;
62+
6163
CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;
6264

6365
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
@@ -68,9 +70,9 @@ class KukaRoXHardwareInterface : public hardware_interface::SystemInterface
6870

6971
bool isActive() const;
7072

73+
private:
7174
void ObserveControl();
7275

73-
private:
7476
bool is_active_ = false;
7577
bool msg_received_ = false;
7678

@@ -88,7 +90,6 @@ class KukaRoXHardwareInterface : public hardware_interface::SystemInterface
8890
std::unique_ptr<grpc::ClientContext> context_;
8991
#endif
9092

91-
9293
std::thread observe_thread_;
9394
std::atomic<bool> terminate_{false};
9495
std::mutex observe_mutex_;

kuka_rox_hardware_interface/include/mock/kuka/motion/external/external_control_mode.pb.h

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kuka_rox_hardware_interface/launch/startup.launch.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def generate_launch_description():
2929
PathJoinSubstitution([FindExecutable(name="xacro")]),
3030
" ",
3131
PathJoinSubstitution(
32-
[FindPackageShare("kuka_rox_hw_interface"),
33-
"config", "iisy.urdf.xacro"]
32+
[FindPackageShare("kuka_iisy_support"),
33+
"urdf", "iisy.urdf.xacro"]
3434
),
3535
" ",
3636
]
@@ -50,6 +50,9 @@ def generate_launch_description():
5050
joint_imp_controller_config = (get_package_share_directory('kuka_rox_hw_interface') +
5151
"/config/joint_impedance_controller_config.yaml")
5252

53+
eci_config = (get_package_share_directory('kuka_rox_hw_interface') +
54+
"/config/eci_config.yaml")
55+
5356
controller_manager_node = '/controller_manager'
5457

5558
return LaunchDescription([
@@ -63,10 +66,7 @@ def generate_launch_description():
6366
namespace='',
6467
package="kuka_rox_hw_interface",
6568
executable="robot_manager_node",
66-
parameters=[
67-
{'position_controller_name': 'joint_trajectory_controller'},
68-
{'impedance_controller_name': 'joint_impedance_controller'},
69-
{'torque_controller_name': 'effort_controller'}]
69+
parameters=[eci_config]
7070
),
7171
Node(
7272
package='robot_state_publisher',

kuka_rox_hardware_interface/launch/startup_with_rviz.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
def generate_launch_description():
2626
rviz_config_file = os.path.join(
27-
get_package_share_directory('kuka_iisy_support'), 'launch', 'urdf_wo_planning_scene.rviz')
27+
get_package_share_directory('kuka_iisy_support'), 'config', 'simple_urdf.rviz')
2828

2929
startup_launch = IncludeLaunchDescription(PythonLaunchDescriptionSource(
3030
[get_package_share_directory('kuka_rox_hw_interface'), '/launch/startup.launch.py']))

0 commit comments

Comments
 (0)