Skip to content

Commit

Permalink
Merge pull request #35 from iory/interface
Browse files Browse the repository at this point in the history
Add interface.py
  • Loading branch information
iory authored Feb 11, 2024
2 parents e195dee + 41e3910 commit 79aa508
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ros/kxr_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ target_link_libraries(kxr_controller
${Eigen_LIBRARIES}
)

file(GLOB PYTHON_SCRIPT_FILES node_scripts/* test/*)
file(GLOB PYTHON_SCRIPT_FILES scripts/* node_scripts/* test/*)
catkin_install_python(
PROGRAMS ${PYTHON_SCRIPT_FILES}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
Expand Down
1 change: 1 addition & 0 deletions ros/kxr_controller/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyglet==1.4.10
scikit-robot>=0.0.37
44 changes: 44 additions & 0 deletions ros/kxr_controller/scripts/interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

from __future__ import print_function

import argparse

import IPython
from kxr_controller.kxr_interface import KXRROSRobotInterface
import rospy
from skrobot.model import RobotModel


def main():
parser = argparse.ArgumentParser(
description='Run KXRROSRobotInterface')
parser.add_argument('--viewer', type=str,
help='Specify the viewer: trimesh', default=None)
parser.add_argument(
'--namespace', type=str, help='Specify the ROS namespace', default='')
args = parser.parse_args()

rospy.init_node('kxr_interface', anonymous=True)
robot_model = RobotModel()
robot_model.load_urdf_from_robot_description(
args.namespace + '/robot_description')
ri = KXRROSRobotInterface( # NOQA
robot_model, namespace=args.namespace, controller_timeout=60.0)

if args.viewer is not None:
if args.viewer == 'trimesh':
from skrobot.viewers import TrimeshSceneViewer
viewer = TrimeshSceneViewer(resolution=(640, 480))
viewer.add(robot_model)
viewer.show()
else:
raise NotImplementedError(
'Not supported viewer {}'.format(args.viewer))

# Drop into an IPython shell
IPython.embed()


if __name__ == '__main__':
main()

0 comments on commit 79aa508

Please sign in to comment.