-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename mr_desc_param.py script to mr_desc_param * Add command line args to mr_desc_param * Tool now takes a dict instead of kwargs * Changed Tool arg robot_namespace to namespace * Changed License holder * Improved README with more detailed usage info * Add requirements.txt file * Added ROS_PYTHON_VERSION conditionals to package dependencies * Change required version of scipy
- Loading branch information
Showing
11 changed files
with
283 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
# The namespace under which the `/robot_description` rosparam will be found, as well as | ||
# the names of each link (i.e. `/namespace/robot_description`, and `namespace/base_link`). | ||
namespace: '' | ||
|
||
# The name given to the link that will serve as the location of the robot's base, or {0} link. | ||
space_frame: '' | ||
|
||
# The name given to the link that will serve as the location of the end effector. | ||
body_frame: '' | ||
|
||
# The precision with which to print the kinematic properties. | ||
precision: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
<?xml version="1.0"?> | ||
<package format="3"> | ||
<name>kinematics_from_description</name> | ||
<version>0.0.2</version> | ||
<version>1.0.0</version> | ||
<description>This package contains a simple Python program that calculates properties required to run parts of the <a href="https://github.com/NxRLab/ModernRobotics">Modern Robotics Library</a> from a robot's robot_description parameter.</description> | ||
|
||
<license>BSD</license> | ||
|
||
<author email="luke@trossenrobotics.com">Luke Schmitt</author> | ||
<author email="trsupport@trossenrobotics.com">Luke Schmitt</author> | ||
<maintainer email="trsupport@trossenrobotics.com">Luke Schmitt</maintainer> | ||
|
||
<url type="website">https://github.com/LSinterbotix/kinematics_from_description</url> | ||
<url type="bugtracker">https://github.com/LSinterbotix/kinematics_from_description/issues</url> | ||
<url type="repository">https://github.com/LSinterbotix/kinematics_from_description</url> | ||
<url type="website">https://github.com/Interbotix/kinematics_from_description</url> | ||
<url type="bugtracker">https://github.com/Interbotix/kinematics_from_description/issues</url> | ||
<url type="repository">https://github.com/Interbotix/kinematics_from_description</url> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
<buildtool_depend>python3-setuptools</buildtool_depend> | ||
<buildtool_depend condition="$ROS_PYTHON_VERSION==2">python-setuptools</buildtool_depend> | ||
<buildtool_depend condition="$ROS_PYTHON_VERSION==3">python3-setuptools</buildtool_depend> | ||
|
||
<exec_depend>rospy</exec_depend> | ||
<exec_depend>urdfdom_py</exec_depend> | ||
<exec_depend>python3-yaml</exec_depend> | ||
<exec_depend>python3-numpy</exec_depend> | ||
<exec_depend version_gte="1.4.0">python3-scipy</exec_depend> | ||
|
||
<exec_depend condition="$ROS_PYTHON_VERSION==2">python-yaml</exec_depend> | ||
<exec_depend condition="$ROS_PYTHON_VERSION==2">python-numpy</exec_depend> | ||
<exec_depend condition="$ROS_PYTHON_VERSION==2" version_gte="1.2.0">python-scipy</exec_depend> | ||
<exec_depend condition="$ROS_PYTHON_VERSION==3">python3-yaml</exec_depend> | ||
<exec_depend condition="$ROS_PYTHON_VERSION==3">python3-numpy</exec_depend> | ||
<exec_depend condition="$ROS_PYTHON_VERSION==3" version_gte="1.2.0">python3-scipy</exec_depend> | ||
|
||
<build_depend>rostest</build_depend> | ||
|
||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# $ python -m pip install -r requirements.txt | ||
# $ python3 -m pip3 install -r requirements.txt | ||
|
||
urdf_parser_py | ||
numpy | ||
scipy>=1.2.0 | ||
pyyaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import yaml | ||
import os | ||
import numpy as np | ||
import rospkg | ||
from kinematics_from_description.kfd import KinematicsFromDescriptionTool as KFD | ||
|
||
PKG = 'kinematics_from_description' | ||
|
||
def main(args): | ||
if args.file is not None: | ||
filepath = os.path.join( | ||
rospkg.RosPack().get_path(PKG), | ||
'config', | ||
'config.yaml' | ||
) | ||
print("Loading configs from '%s'" % filepath) | ||
try: | ||
with open(filepath) as config_file: | ||
config = yaml.safe_load(config_file) | ||
except yaml.YAMLError as e: | ||
print(e) | ||
exit(1) | ||
elif args.space_frame is not None and args.body_frame is not None: | ||
config={} | ||
config['space_frame']=args.space_frame | ||
config['body_frame']=args.body_frame | ||
config['namespace']=args.namespace | ||
config['precision']=args.precision | ||
else: | ||
raise ValueError( | ||
'Either a file must be specified or the space and body frames must be specified.' | ||
'Use the --help flag for details.' | ||
) | ||
|
||
np.set_printoptions(precision=int(config["precision"]), suppress=True) | ||
|
||
print('Using configs:') | ||
print('\tspace_frame: %s' % config['space_frame']) | ||
print('\tbody_frame: %s' % config['body_frame']) | ||
print('\tnamespace: %s' % config['namespace']) | ||
print('\tprecision: %i' % config['precision']) | ||
|
||
tool = KFD(config) | ||
|
||
tool.load_desc_from_param() | ||
tool.run() | ||
|
||
print('\nThe MR Descriptions are as follows:') | ||
|
||
print("\nM:") | ||
print(repr(tool.get_M())) | ||
|
||
print("\nSlist:") | ||
print(str(repr(tool.get_Slist(transposed=False))) + ".T\n") | ||
|
||
print( | ||
( | ||
'Paste these arrays into your mr_descriptions.py file to use in the Interbotix ' | ||
'Python-ROS API.' | ||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description=( | ||
"A program that will parse a robot's kinematic properties from its " | ||
'`/robot_description` rosparam.' | ||
) | ||
) | ||
parser.add_argument( | ||
'--file', | ||
'-f', | ||
type=str, | ||
help='The path to the config file to use.', | ||
) | ||
parser.add_argument( | ||
'--space_frame', | ||
'-s', | ||
type=str, | ||
help=( | ||
"The name given to the link that will serve as the location of the robot's base, or " | ||
"{0} link. This is typically `base_link`." | ||
), | ||
) | ||
parser.add_argument( | ||
'--body_frame', | ||
'-b', | ||
type=str, | ||
help=( | ||
'The name given to the link that will serve as the location of the end effector. This' | ||
' is typically `ee_gripper_link`.' | ||
), | ||
) | ||
parser.add_argument( | ||
'--namespace', | ||
'-n', | ||
type=str, | ||
default='', | ||
help=( | ||
'The namespace under which the `/robot_description` rosparam will be found, as well as' | ||
' the names of each link (i.e. `/namespace/robot_description`, and ' | ||
'`namespace/base_link`. (default: %(default)s)' | ||
), | ||
) | ||
parser.add_argument( | ||
'--precision', | ||
'-p', | ||
type=int, | ||
help='The precision with which to print the kinematic properties. (default: %(default)s)', | ||
default=6, | ||
) | ||
main(args=parser.parse_args()) |
Oops, something went wrong.