Skip to content

Commit 6aacb80

Browse files
authored
Merge pull request #10 from collaborative-robotics/rc-1.3.0
rc 1.3.0
2 parents 1de65d1 + 1dd492c commit 6aacb80

File tree

11 files changed

+308
-60
lines changed

11 files changed

+308
-60
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change log
22
==========
33

4+
1.3.0 (2024-08-09)
5+
==================
6+
7+
* Updated code, `package.xml` and `CMakeLists.txt` so the same repository can be used for both ROS1 and ROS2
8+
49
1.2.0 (2023-11-21)
510
==================
611

CMakeLists.txt

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
cmake_minimum_required (VERSION 3.1)
2-
project (crtk_python_client VERSION 1.2.0)
3-
4-
## Find catkin macros and libraries
5-
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
6-
## is used, also find other catkin packages
7-
find_package (catkin REQUIRED COMPONENTS
8-
rospy
9-
)
10-
11-
## The catkin_package macro generates cmake config files for your package
12-
## Declare things to be passed to dependent projects
13-
## INCLUDE_DIRS: uncomment this if you package contains header files
14-
## LIBRARIES: libraries you create in this project that dependent projects also need
15-
## CATKIN_DEPENDS: catkin_packages dependent projects also need
16-
## DEPENDS: system dependencies of this project that dependent projects also need
17-
catkin_package (
18-
# INCLUDE_DIRS include
19-
# LIBRARIES my_pkg
20-
CATKIN_DEPENDS rospy
21-
# DEPENDS system_lib
22-
)
23-
24-
## Mark executable scripts (Python etc.) for installation
25-
## in contrast to setup.py, you can choose the destination
26-
# install(PROGRAMS
27-
# scripts/my_python_script
28-
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
29-
# )
30-
31-
catkin_python_setup ()
1+
cmake_minimum_required (VERSION 3.10)
2+
project (crtk_python_client VERSION 1.3.0)
3+
4+
# first test for ROS1
5+
find_package (catkin QUIET
6+
COMPONENTS rospy)
7+
8+
if (catkin_FOUND)
9+
10+
catkin_package (CATKIN_DEPENDS rospy)
11+
catkin_python_setup ()
12+
13+
else (catkin_FOUND)
14+
15+
# look for ROS2
16+
find_package (ament_cmake QUIET)
17+
if (ament_cmake_FOUND)
18+
find_package (ament_cmake_python REQUIRED)
19+
ament_python_install_package (crtk
20+
PACKAGE_DIR ${crtk_python_client_SOURCE_DIR}/src/crtk)
21+
22+
file (GLOB crtk_SCRIPTS scripts/*.py)
23+
install (PROGRAMS ${crtk_SCRIPTS}
24+
DESTINATION lib/${PROJECT_NAME})
25+
26+
ament_package ()
27+
endif (ament_cmake_FOUND)
28+
29+
endif (catkin_FOUND)

__init__.py

Whitespace-only changes.

package.xml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<?xml version="1.0"?>
2-
<package>
2+
<package format="3">
33
<name>crtk_python_client</name>
4-
<version>1.2.0</version>
4+
<version>1.3.0</version>
55
<description>crtk Python client</description>
6-
76
<maintainer email="[email protected]">Anton Deguet</maintainer>
87
<maintainer email="[email protected]">Adnan Munawar</maintainer>
98
<license>MIT</license>
109

11-
<buildtool_depend>catkin</buildtool_depend>
12-
<build_depend>rospy</build_depend>
13-
<run_depend>rospy</run_depend>
10+
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
11+
<build_depend condition="$ROS_VERSION == 1">rospy</build_depend>
12+
<exec_depend condition="$ROS_VERSION == 1">rospy</exec_depend>
13+
<exec_depend condition="$ROS_VERSION == 1">crtk_msgs</exec_depend>
14+
15+
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
16+
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake_python</buildtool_depend>
17+
<depend condition="$ROS_VERSION == 2">rclpy</depend>
18+
<depend condition="$ROS_VERSION == 2">crtk_msgs</depend>
1419

15-
<!-- The export tag contains other, unspecified, tags -->
1620
<export>
21+
<build_type condition="$ROS_VERSION == 1">catkin</build_type>
22+
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
1723
</export>
1824

1925
</package>

scripts/crtk_teleop_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import crtk
2121
import math
2222
import PyKDL
23-
import rospy
2423
import sys
2524

2625

src/crtk/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@
44
# Copyright (c) 2016-2023 Johns Hopkins University, University of Washington, Worcester Polytechnic Institute
55
# Released under MIT License
66

7-
__all__ = ["ral", "wait_move_handle", "utils", "joystick_button", "measured_cp"]
7+
__all__ = ['wait_move_handle', 'utils', 'joystick_button', 'measured_cp']
88

99
# ros abstraction layer
10-
from .ral import ral
10+
import os
11+
__ros_version_string = os.environ['ROS_VERSION']
12+
if __ros_version_string == '1':
13+
__all__.append('ros_ral1')
14+
from .ral_ros1 import ral
15+
elif __ros_version_string == '2':
16+
__all__.append('ros_ral2')
17+
from .ral_ros2 import ral
18+
else:
19+
print('environment variable ROS_VERSION must be either 1 or 2, did you source your setup.bash?')
1120

1221
# handle classes
1322
from .wait_move_handle import wait_move_handle

src/crtk/measured_cp.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,21 @@
1212
# --- end cisst license ---
1313

1414
import crtk
15-
import rospy
16-
import PyKDL
1715

1816
class measured_cp(object):
1917
"""Simple class to get measured_cp over ROS
2018
"""
2119

2220
# initialize the arm
23-
def __init__(self, ros_namespace, expected_interval = 0.01):
24-
# base class constructor in separate method so it can be called in derived classes
25-
self.__init_arm(ros_namespace, expected_interval)
26-
27-
28-
def __init_arm(self,ros_namespace, expected_interval):
21+
def __init__(self, ral, expected_interval = 0.01):
2922
"""Constructor. This initializes a few data members. It
3023
requires a ros namespace, this will be used to find the ROS
3124
topic `measured_cp`."""
3225
# data members, event based
33-
self.__ros_namespace = ros_namespace
26+
self.__ral = ral
3427

3528
# crtk features
36-
self.__crtk_utils = crtk.utils(self, self.__ros_namespace, expected_interval)
29+
self.__crtk_utils = crtk.utils(self, self.__ral, expected_interval)
3730

3831
# add crtk features that we need
3932
self.__crtk_utils.add_measured_cp()
40-
41-
# create node
42-
if not rospy.get_node_uri():
43-
rospy.init_node('measured_cp_client', anonymous = True, log_level = rospy.WARN)
44-
else:
45-
rospy.logdebug(rospy.get_caller_id() + ' -> ROS already initialized')
File renamed without changes.

0 commit comments

Comments
 (0)