Skip to content

Commit

Permalink
Use the urdf_ member for _Jazzy_
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanscherzinger committed Oct 20, 2024
1 parent 106e3a8 commit 32e1b3a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Cmake will update these defines depending on our current ROS_DISTRO.
// We use this mechanism to react to API changes in ROS2-control.
//
#cmakedefine CARTESIAN_CONTROLLERS_FOXY
#cmakedefine CARTESIAN_CONTROLLERS_GALACTIC

#cmakedefine CARTESIAN_CONTROLLERS_HUMBLE
#cmakedefine CARTESIAN_CONTROLLERS_IRON
#cmakedefine CARTESIAN_CONTROLLERS_JAZZY
5 changes: 5 additions & 0 deletions cartesian_controller_base/src/cartesian_controller_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ CartesianControllerBase::on_configure(const rclcpp_lifecycle::State & previous_s
urdf::Model robot_model;
KDL::Tree robot_tree;

#if defined CARTESIAN_CONTROLLERS_JAZZY
m_robot_description = this->get_robot_description();
#else
m_robot_description = get_node()->get_parameter("robot_description").as_string();
#endif

if (m_robot_description.empty())
{
RCLCPP_ERROR(get_node()->get_logger(), "robot_description is empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def generate_launch_description():
control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_controllers],
parameters=[robot_description, robot_controllers],
# prefix="screen -d -m gdb -command=/home/stefan/.gdb_debug_config --ex run --args", # noqa E501
output="both",
remappings=[
Expand Down
18 changes: 3 additions & 15 deletions cartesian_controller_tests/integration_tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from launch.substitutions import PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare

import os
import time
import rclpy
from rclpy.node import Node
Expand All @@ -16,8 +15,6 @@
from geometry_msgs.msg import PoseStamped
from geometry_msgs.msg import WrenchStamped

distro = os.environ["ROS_DISTRO"]


def generate_test_description():
setup = IncludeLaunchDescription(
Expand Down Expand Up @@ -118,10 +115,7 @@ def test_invalid_controller_initialization(self):
controller manager contains our controllers and if they have the
expected state.
"""
if os.environ["ROS_DISTRO"] == "humble" or os.environ["ROS_DISTRO"] == "iron":
expected_state = "unconfigured"
else: # galactic, foxy
expected_state = "finalized"
expected_state = "unconfigured"
for name in self.invalid_controllers:
self.assertTrue(
self.check_state(name, expected_state),
Expand Down Expand Up @@ -215,19 +209,13 @@ def check_state(self, controller, state):
def start_controller(self, controller):
"""Start the given controller"""
req = SwitchController.Request()
if distro in ["humble", "iron"]:
req.activate_controllers = [controller]
else:
req.start_controllers = [controller]
req.activate_controllers = [controller]
self.perform_switch(req)

def stop_controller(self, controller):
"""Stop the given controller"""
req = SwitchController.Request()
if distro in ["humble", "iron"]:
req.deactivate_controllers = [controller]
else:
req.stop_controllers = [controller]
req.deactivate_controllers = [controller]
self.perform_switch(req)

def perform_switch(self, req):
Expand Down

0 comments on commit 32e1b3a

Please sign in to comment.