Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface.py #35

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading