Skip to content

Commit

Permalink
Merge pull request #10 from collaborative-robotics/rc-1.3.0
Browse files Browse the repository at this point in the history
rc 1.3.0
  • Loading branch information
adeguet1 authored Aug 31, 2024
2 parents 1de65d1 + 1dd492c commit 6aacb80
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 60 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change log
==========

1.3.0 (2024-08-09)
==================

* Updated code, `package.xml` and `CMakeLists.txt` so the same repository can be used for both ROS1 and ROS2

1.2.0 (2023-11-21)
==================

Expand Down
60 changes: 29 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
cmake_minimum_required (VERSION 3.1)
project (crtk_python_client VERSION 1.2.0)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package (catkin REQUIRED COMPONENTS
rospy
)

## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package (
# INCLUDE_DIRS include
# LIBRARIES my_pkg
CATKIN_DEPENDS rospy
# DEPENDS system_lib
)

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

catkin_python_setup ()
cmake_minimum_required (VERSION 3.10)
project (crtk_python_client VERSION 1.3.0)

# first test for ROS1
find_package (catkin QUIET
COMPONENTS rospy)

if (catkin_FOUND)

catkin_package (CATKIN_DEPENDS rospy)
catkin_python_setup ()

else (catkin_FOUND)

# look for ROS2
find_package (ament_cmake QUIET)
if (ament_cmake_FOUND)
find_package (ament_cmake_python REQUIRED)
ament_python_install_package (crtk
PACKAGE_DIR ${crtk_python_client_SOURCE_DIR}/src/crtk)

file (GLOB crtk_SCRIPTS scripts/*.py)
install (PROGRAMS ${crtk_SCRIPTS}
DESTINATION lib/${PROJECT_NAME})

ament_package ()
endif (ament_cmake_FOUND)

endif (catkin_FOUND)
Empty file removed __init__.py
Empty file.
20 changes: 13 additions & 7 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?xml version="1.0"?>
<package>
<package format="3">
<name>crtk_python_client</name>
<version>1.2.0</version>
<version>1.3.0</version>
<description>crtk Python client</description>

<maintainer email="[email protected]">Anton Deguet</maintainer>
<maintainer email="[email protected]">Adnan Munawar</maintainer>
<license>MIT</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<run_depend>rospy</run_depend>
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<build_depend condition="$ROS_VERSION == 1">rospy</build_depend>
<exec_depend condition="$ROS_VERSION == 1">rospy</exec_depend>
<exec_depend condition="$ROS_VERSION == 1">crtk_msgs</exec_depend>

<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake_python</buildtool_depend>
<depend condition="$ROS_VERSION == 2">rclpy</depend>
<depend condition="$ROS_VERSION == 2">crtk_msgs</depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
<build_type condition="$ROS_VERSION == 1">catkin</build_type>
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
</export>

</package>
1 change: 0 additions & 1 deletion scripts/crtk_teleop_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import crtk
import math
import PyKDL
import rospy
import sys


Expand Down
13 changes: 11 additions & 2 deletions src/crtk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
# Copyright (c) 2016-2023 Johns Hopkins University, University of Washington, Worcester Polytechnic Institute
# Released under MIT License

__all__ = ["ral", "wait_move_handle", "utils", "joystick_button", "measured_cp"]
__all__ = ['wait_move_handle', 'utils', 'joystick_button', 'measured_cp']

# ros abstraction layer
from .ral import ral
import os
__ros_version_string = os.environ['ROS_VERSION']
if __ros_version_string == '1':
__all__.append('ros_ral1')
from .ral_ros1 import ral
elif __ros_version_string == '2':
__all__.append('ros_ral2')
from .ral_ros2 import ral
else:
print('environment variable ROS_VERSION must be either 1 or 2, did you source your setup.bash?')

# handle classes
from .wait_move_handle import wait_move_handle
Expand Down
19 changes: 3 additions & 16 deletions src/crtk/measured_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,21 @@
# --- end cisst license ---

import crtk
import rospy
import PyKDL

class measured_cp(object):
"""Simple class to get measured_cp over ROS
"""

# initialize the arm
def __init__(self, ros_namespace, expected_interval = 0.01):
# base class constructor in separate method so it can be called in derived classes
self.__init_arm(ros_namespace, expected_interval)


def __init_arm(self,ros_namespace, expected_interval):
def __init__(self, ral, expected_interval = 0.01):
"""Constructor. This initializes a few data members. It
requires a ros namespace, this will be used to find the ROS
topic `measured_cp`."""
# data members, event based
self.__ros_namespace = ros_namespace
self.__ral = ral

# crtk features
self.__crtk_utils = crtk.utils(self, self.__ros_namespace, expected_interval)
self.__crtk_utils = crtk.utils(self, self.__ral, expected_interval)

# add crtk features that we need
self.__crtk_utils.add_measured_cp()

# create node
if not rospy.get_node_uri():
rospy.init_node('measured_cp_client', anonymous = True, log_level = rospy.WARN)
else:
rospy.logdebug(rospy.get_caller_id() + ' -> ROS already initialized')
File renamed without changes.
Loading

0 comments on commit 6aacb80

Please sign in to comment.