repo_id stringlengths 19 138 | file_path stringlengths 32 200 | content stringlengths 1 12.9M | __index_level_0__ int64 0 0 |
|---|---|---|---|
apollo_public_repos/apollo-platform/ros/genlisp/src | apollo_public_repos/apollo-platform/ros/genlisp/src/genlisp/genlisp_main.py | # Software License Agreement (BSD License)
#
# Copyright (c) 2009, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Willow Garage, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
from __future__ import print_function
from optparse import OptionParser
import os
import sys
import traceback
import genmsg
import genmsg.command_line
from genmsg import MsgGenerationException
from . generate import generate_msg, generate_srv
def usage(progname):
print("%(progname)s file(s)"%vars())
def genmain(argv, progname):
parser = OptionParser("%s file"%(progname))
parser.add_option('-p', dest='package')
parser.add_option('-o', dest='outdir')
parser.add_option('-I', dest='includepath', action='append')
options, args = parser.parse_args(argv)
try:
if len(args) < 2:
parser.error("please specify args")
if not os.path.exists(options.outdir):
# This script can be run multiple times in parallel. We
# don't mind if the makedirs call fails because somebody
# else snuck in and created the directory before us.
try:
os.makedirs(options.outdir)
except OSError as e:
if not os.path.exists(options.outdir):
raise
search_path = genmsg.command_line.includepath_to_dict(options.includepath)
filename = args[1]
if filename.endswith('.msg'):
retcode = generate_msg(options.package, args[1:], options.outdir, search_path)
else:
retcode = generate_srv(options.package, args[1:], options.outdir, search_path)
except genmsg.InvalidMsgSpec as e:
print("ERROR: ", e, file=sys.stderr)
retcode = 1
except MsgGenerationException as e:
print("ERROR: ", e, file=sys.stderr)
retcode = 2
except Exception as e:
traceback.print_exc()
print("ERROR: ",e)
retcode = 3
sys.exit(retcode or 0)
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp/src | apollo_public_repos/apollo-platform/ros/genlisp/src/genlisp/generate.py | # Software License Agreement (BSD License)
#
# Copyright (c) 2009, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Willow Garage, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
## ROS message source code generation for Lisp
##
## Converts ROS .msg and .srv files in a package into Lisp source code
## t0: needed for script to work
## t1: for reference; remove once running
## t2: can be changed once we remove strict diff-compatibility requirement with old version of genmsg_lisp
import sys
import os
import traceback
import re
#import roslib.msgs
#import roslib.srvs
#import roslib.packages
#import roslib.gentools
from genmsg import SrvSpec, MsgSpec, MsgContext
from genmsg.msg_loader import load_srv_from_file, load_msg_by_type
import genmsg.gentools
try:
from cStringIO import StringIO #Python 2.x
except ImportError:
from io import StringIO #Python 3.x
############################################################
# Built in types
############################################################
def is_fixnum(t):
return t in ['int8', 'uint8', 'int16', 'uint16']
def is_integer(t):
return is_fixnum(t) or t in ['byte', 'char', 'int32', 'uint32', 'int64', 'uint64'] #t2 byte, char can be fixnum
def is_signed_int(t):
return t in ['int8', 'int16', 'int32', 'int64']
def is_unsigned_int(t):
return t in ['uint8', 'uint16', 'uint32', 'uint64']
def is_bool(t):
return t == 'bool'
def is_string(t):
return t == 'string'
def is_float(t):
return t in ['float16', 'float32', 'float64']
def is_time(t):
return t in ['time', 'duration']
def field_type(f):
if f.is_builtin:
elt_type = lisp_type(f.base_type)
else:
elt_type = msg_type(f)
if f.is_array:
return '(cl:vector %s)'%elt_type
else:
return elt_type
def parse_msg_type(f):
if f.base_type == 'Header':
return ('std_msgs', 'Header')
else:
return f.base_type.split('/')
# t2 no need for is_array
def msg_type(f):
(pkg, msg) = parse_msg_type(f)
return '%s-msg:%s'%(pkg, msg)
def lisp_type(t):
if is_fixnum(t):
return 'cl:fixnum'
elif is_integer(t):
return 'cl:integer'
elif is_bool(t):
return 'cl:boolean'
elif is_float(t):
return 'cl:float'
elif is_time(t):
return 'cl:real'
elif is_string(t):
return 'cl:string'
else:
raise ValueError('%s is not a recognized primitive type'%t)
def field_initform(f):
if f.is_builtin:
initform = lisp_initform(f.base_type)
elt_type = lisp_type(f.base_type)
else:
initform = '(cl:make-instance \'%s)'%msg_type(f)
elt_type = msg_type(f)
if f.is_array:
len = f.array_len or 0
return '(cl:make-array %s :element-type \'%s :initial-element %s)'%(len, elt_type, initform)
else:
return initform
def lisp_initform(t):
if is_integer(t):
return '0'
elif is_bool(t):
return 'cl:nil'
elif is_float(t):
return '0.0'
elif is_time(t):
return 0
elif is_string(t):
return '\"\"'
else:
raise ValueError('%s is not a recognized primitive type'%t)
NUM_BYTES = {'int8': 1, 'int16': 2, 'int32': 4, 'int64': 8,
'uint8': 1, 'uint16': 2, 'uint32': 4, 'uint64': 8}
############################################################
# Indented writer
############################################################
class IndentedWriter():
def __init__(self, s):
self.str = s
self.indentation = 0
self.block_indent = False
def write(self, s, indent=True, newline=True):
if not indent:
newline = False
if self.block_indent:
self.block_indent = False
else:
if newline:
self.str.write('\n')
if indent:
for i in range(self.indentation):
self.str.write(' ')
self.str.write(s)
def newline(self):
self.str.write('\n')
def inc_indent(self, inc=2):
self.indentation += inc
def dec_indent(self, dec=2):
self.indentation -= dec
def reset_indent(self):
self.indentation = 0
def block_next_indent(self):
self.block_indent = True
class Indent():
def __init__(self, w, inc=2, indent_first=True):
self.writer = w
self.inc = inc
self.indent_first = indent_first
def __enter__(self):
self.writer.inc_indent(self.inc)
if not self.indent_first:
self.writer.block_next_indent()
def __exit__(self, type, val, traceback):
self.writer.dec_indent(self.inc)
def write_begin(s, spec, is_service=False):
"Writes the beginning of the file: a comment saying it's auto-generated and the in-package form"
s.write('; Auto-generated. Do not edit!\n\n\n', newline=False)
suffix = 'srv' if is_service else 'msg'
s.write('(cl:in-package %s-%s)\n\n\n'%(spec.package, suffix), newline=False)
def write_html_include(s, spec, is_srv=False):
s.write(';//! \\htmlinclude %s.msg.html\n'%spec.actual_name, newline=False) # t2
def write_slot_definition(s, field):
"Write the definition of a slot corresponding to a single message field"
s.write('(%s'%field.name)
with Indent(s, 1):
s.write(':reader %s'%field.name)
s.write(':initarg :%s'%field.name)
s.write(':type %s'%field_type(field))
i = 0 if field.is_array else 1 # t2
with Indent(s, i):
s.write(':initform %s)'%field_initform(field))
def write_deprecated_readers(s, spec):
suffix = 'srv' if spec.component_type == 'service' else 'msg'
for field in spec.parsed_fields():
s.newline()
s.write('(cl:ensure-generic-function \'%s-val :lambda-list \'(m))' % field.name)
s.write('(cl:defmethod %s-val ((m %s))'%(field.name, message_class(spec)))
with Indent(s):
s.write('(roslisp-msg-protocol:msg-deprecation-warning "Using old-style slot reader %s-%s:%s-val is deprecated. Use %s-%s:%s instead.")'%(spec.package, suffix, field.name, spec.package, suffix, field.name))
s.write('(%s m))'%field.name)
def write_defclass(s, spec):
"Writes the defclass that defines the message type"
cl = message_class(spec)
new_cl = new_message_class(spec)
suffix = 'srv' if spec.component_type == 'service' else 'msg'
s.write('(cl:defclass %s (roslisp-msg-protocol:ros-message)'%cl)
with Indent(s):
s.write('(')
with Indent(s, inc=1, indent_first=False):
for field in spec.parsed_fields():
write_slot_definition(s, field)
s.write(')', indent=False)
s.write(')')
s.newline()
s.write('(cl:defclass %s (%s)'%(new_cl, cl))
with Indent(s):
s.write('())')
s.newline()
s.write('(cl:defmethod cl:initialize-instance :after ((m %s) cl:&rest args)'%cl)
with Indent(s):
s.write('(cl:declare (cl:ignorable args))')
s.write('(cl:unless (cl:typep m \'%s)'%new_cl)
with Indent(s):
s.write('(roslisp-msg-protocol:msg-deprecation-warning "using old message class name %s-%s:%s is deprecated: use %s-%s:%s instead.")))'%(spec.package, suffix, cl, spec.package, suffix, new_cl))
def message_class(spec):
"""
Return the CLOS class name for this message type
"""
return '<%s>'%spec.actual_name
def new_message_class(spec):
return spec.actual_name
def write_serialize_length(s, v, is_array=False):
#t2
var = '__ros_arr_len' if is_array else '__ros_str_len'
s.write('(cl:let ((%s (cl:length %s)))'%(var, v))
with Indent(s):
for x in range(0, 32, 8):
s.write('(cl:write-byte (cl:ldb (cl:byte 8 %s) %s) ostream)'%(x, var))
s.write(')', indent=False)
def write_serialize_bits(s, v, num_bytes):
for x in range(0, num_bytes*8, 8):
s.write('(cl:write-byte (cl:ldb (cl:byte 8 %s) %s) ostream)'%(x, v))
def write_serialize_bits_signed(s, v, num_bytes):
num_bits = num_bytes*8
s.write('(cl:let* ((signed %s) (unsigned (cl:if (cl:< signed 0) (cl:+ signed %s) signed)))'%(v, 2**num_bits))
with Indent(s):
write_serialize_bits(s, 'unsigned', num_bytes)
s.write(')')
# t2: can get rid of this lookup_slot stuff
def write_serialize_builtin(s, f, var='msg', lookup_slot=True):
v = '(cl:slot-value %s \'%s)'%(var, f.name) if lookup_slot else var
if f.base_type == 'string':
write_serialize_length(s, v)
s.write('(cl:map cl:nil #\'(cl:lambda (c) (cl:write-byte (cl:char-code c) ostream)) %s)'%v)
elif f.base_type == 'float32':
s.write('(cl:let ((bits %s))'%'(roslisp-utils:encode-single-float-bits %s)'%v)
with Indent(s):
write_serialize_bits(s, 'bits', 4)
s.write(')', False)
elif f.base_type == 'float64':
s.write('(cl:let ((bits %s))'%'(roslisp-utils:encode-double-float-bits %s)'%v)
with Indent(s):
write_serialize_bits(s, 'bits', 8)
s.write(')', False)
elif f.base_type == 'bool':
s.write('(cl:write-byte (cl:ldb (cl:byte 8 0) (cl:if %s 1 0)) ostream)'%v)
elif f.base_type in ['byte', 'char']:
s.write('(cl:write-byte (cl:ldb (cl:byte 8 0) %s) ostream)'%v)
elif f.base_type in ['duration', 'time']:
s.write('(cl:let ((__sec (cl:floor %s))'%v)
s.write(' (__nsec (cl:round (cl:* 1e9 (cl:- %s (cl:floor %s))))))'%(v,v))
with Indent(s):
write_serialize_bits(s, '__sec', 4)
write_serialize_bits(s, '__nsec', 4)
s.write(')', False)
elif is_signed_int(f.base_type):
write_serialize_bits_signed(s, v, NUM_BYTES[f.base_type])
elif is_unsigned_int(f.base_type):
write_serialize_bits(s, v, NUM_BYTES[f.base_type])
else:
raise ValueError('Unknown type: %s', f.base_type)
def write_serialize_field(s, f):
slot = '(cl:slot-value msg \'%s)'%f.name
if f.is_array:
if not f.array_len:
write_serialize_length(s, slot, True)
s.write('(cl:map cl:nil #\'(cl:lambda (ele) ')
var = 'ele'
s.block_next_indent()
lookup_slot = False
else:
var='msg'
lookup_slot = True
if f.is_builtin:
write_serialize_builtin(s, f, var, lookup_slot=lookup_slot)
else:
to_write = slot if lookup_slot else var #t2
s.write('(roslisp-msg-protocol:serialize %s ostream)'%to_write)
if f.is_array:
s.write(')', False)
s.write(' %s)'%slot)
def write_serialize(s, spec):
"""
Write the serialize method
"""
s.write('(cl:defmethod roslisp-msg-protocol:serialize ((msg %s) ostream)'%message_class(spec))
with Indent(s):
s.write('"Serializes a message object of type \'%s"'%message_class(spec))
for f in spec.parsed_fields():
write_serialize_field(s, f)
s.write(')')
# t2 can get rid of is_array
def write_deserialize_length(s, is_array=False):
var = '__ros_arr_len' if is_array else '__ros_str_len'
s.write('(cl:let ((%s 0))'%var)
with Indent(s):
for x in range(0, 32, 8):
s.write('(cl:setf (cl:ldb (cl:byte 8 %s) %s) (cl:read-byte istream))'%(x, var))
def write_deserialize_bits(s, v, num_bytes):
for x in range(0, num_bytes*8, 8):
s.write('(cl:setf (cl:ldb (cl:byte 8 %s) %s) (cl:read-byte istream))'%(x, v))
def write_deserialize_bits_signed(s, v, num_bytes):
s.write('(cl:let ((unsigned 0))')
num_bits = 8*num_bytes
with Indent(s):
write_deserialize_bits(s, 'unsigned', num_bytes)
s.write('(cl:setf %s (cl:if (cl:< unsigned %s) unsigned (cl:- unsigned %s))))'%(v, 2**(num_bits-1), 2**num_bits))
def write_deserialize_builtin(s, f, v):
if f.base_type == 'string':
write_deserialize_length(s)
with Indent(s):
s.write('(cl:setf %s (cl:make-string __ros_str_len))'%v)
s.write('(cl:dotimes (__ros_str_idx __ros_str_len msg)')
with Indent(s):
s.write('(cl:setf (cl:char %s __ros_str_idx) (cl:code-char (cl:read-byte istream)))))'%v)
elif f.base_type == 'float32':
s.write('(cl:let ((bits 0))')
with Indent(s):
write_deserialize_bits(s, 'bits', 4)
s.write('(cl:setf %s (roslisp-utils:decode-single-float-bits bits)))'%v)
elif f.base_type == 'float64':
s.write('(cl:let ((bits 0))')
with Indent(s):
write_deserialize_bits(s, 'bits', 8)
s.write('(cl:setf %s (roslisp-utils:decode-double-float-bits bits)))'%v)
elif f.base_type == 'bool':
s.write('(cl:setf %s (cl:not (cl:zerop (cl:read-byte istream))))'%v)
elif f.base_type in ['byte', 'char']:
s.write('(cl:setf (cl:ldb (cl:byte 8 0) %s) (cl:read-byte istream))'%v)
elif f.base_type in ['duration', 'time']:
s.write('(cl:let ((__sec 0) (__nsec 0))')
with Indent(s):
write_deserialize_bits(s, '__sec', 4)
write_deserialize_bits(s, '__nsec', 4)
s.write('(cl:setf %s (cl:+ (cl:coerce __sec \'cl:double-float) (cl:/ __nsec 1e9))))'%v)
elif is_signed_int(f.base_type):
write_deserialize_bits_signed(s, v, NUM_BYTES[f.base_type])
elif is_unsigned_int(f.base_type):
write_deserialize_bits(s, v, NUM_BYTES[f.base_type])
else:
raise ValueError('%s unknown'%f.base_type)
def write_deserialize_field(s, f, pkg):
slot = '(cl:slot-value msg \'%s)'%f.name
var = slot
if f.is_array:
if not f.array_len:
write_deserialize_length(s, True)
length = '__ros_arr_len'
else:
length = '%s'%f.array_len
s.write('(cl:setf %s (cl:make-array %s))'%(slot, length))
s.write('(cl:let ((vals %s))'%slot) # t2
var = '(cl:aref vals i)'
with Indent(s):
s.write('(cl:dotimes (i %s)'%length)
if f.is_builtin:
with Indent(s):
write_deserialize_builtin(s, f, var)
else:
if f.is_array:
with Indent(s):
s.write('(cl:setf %s (cl:make-instance \'%s))'%(var, msg_type(f)))
s.write('(roslisp-msg-protocol:deserialize %s istream)'%var)
if f.is_array:
s.write('))', False)
if not f.array_len:
s.write(')', False)
def write_deserialize(s, spec):
"""
Write the deserialize method
"""
s.write('(cl:defmethod roslisp-msg-protocol:deserialize ((msg %s) istream)'%message_class(spec))
with Indent(s):
s.write('"Deserializes a message object of type \'%s"'%message_class(spec))
for f in spec.parsed_fields():
write_deserialize_field(s, f, spec.package)
s.write('msg')
s.write(')')
def write_class_exports(s, msgs, pkg):
"Write the _package.lisp file"
s.write('(cl:defpackage %s-msg'%pkg, False)
with Indent(s):
s.write('(:use )')
s.write('(:export')
with Indent(s, inc=1):
for m in msgs:
msg_class = '<%s>'%m
s.write('"%s"'%msg_class.upper())
s.write('"%s"'%m.upper())
s.write('))\n\n')
def write_srv_exports(s, srvs, pkg):
"Write the _package.lisp file for a service directory"
s.write('(cl:defpackage %s-srv'%pkg, False)
with Indent(s):
s.write('(:use )')
s.write('(:export')
with Indent(s, inc=1):
for srv in srvs:
s.write('"%s"'%srv.upper())
s.write('"<%s-REQUEST>"'%srv.upper())
s.write('"%s-REQUEST"'%srv.upper())
s.write('"<%s-RESPONSE>"'%srv.upper())
s.write('"%s-RESPONSE"'%srv.upper())
s.write('))\n\n')
def write_asd_deps(s, deps, msgs):
with Indent(s):
s.write(':depends-on (:roslisp-msg-protocol :roslisp-utils ')
with Indent(s, inc=13, indent_first=False):
for d in sorted(deps):
s.write(':%s-msg'%d)
s.write(')') #t2 indentation
with Indent(s):
s.write(':components ((:file "_package")')
with Indent(s):
for name in msgs:
s.write('(:file "%s" :depends-on ("_package_%s"))'%(name, name))
s.write('(:file "_package_%s" :depends-on ("_package"))'%name)
s.write('))')
def write_srv_asd(s, pkg, srvs, context):
s.write('(cl:in-package :asdf)')
s.newline()
s.write('(defsystem "%s-srv"'%pkg)
# Figure out set of depended-upon ros packages
deps = set()
for srv in srvs:
req_spec = context.get_registered('%s/%sRequest'%(pkg, srv))
resp_spec = context.get_registered('%s/%sResponse'%(pkg, srv))
for f in req_spec.parsed_fields():
if not f.is_builtin:
(p, _) = parse_msg_type(f)
deps.add(p)
for f in resp_spec.parsed_fields():
if not f.is_builtin:
(p, _) = parse_msg_type(f)
deps.add(p)
write_asd_deps(s, deps, srvs)
def write_asd(s, pkg, msgs, context):
s.write('(cl:in-package :asdf)')
s.newline()
s.write('(defsystem "%s-msg"'%pkg)
# Figure out set of depended-upon ros packages
deps = set()
for m in msgs:
spec = context.get_registered('%s/%s'%(pkg, m))
for f in spec.parsed_fields():
if not f.is_builtin:
(p, _) = parse_msg_type(f)
deps.add(p)
if pkg in deps:
deps.remove(pkg)
write_asd_deps(s, deps, msgs)
def write_accessor_exports(s, spec):
"Write the package exports for this message/service"
is_srv = isinstance(spec, SrvSpec)
suffix = 'srv' if is_srv else 'msg'
s.write('(cl:in-package %s-%s)'%(spec.package, suffix), indent=False)
s.write('(cl:export \'(')
if is_srv:
fields = spec.request.parsed_fields()[:]
fields.extend(spec.response.parsed_fields())
else:
fields = spec.parsed_fields()
with Indent(s, inc=10, indent_first=False):
for f in fields:
accessor = '%s-val'%f.name
s.write('%s'%accessor.upper())
s.write('%s'%f.name.upper())
s.write('))')
def write_ros_datatype(s, spec):
for c in (message_class(spec), new_message_class(spec)):
s.write('(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql \'%s)))'%c)
with Indent(s):
s.write('"Returns string type for a %s object of type \'%s"'%(spec.component_type, c))
s.write('"%s")'%spec.full_name)
def write_md5sum(s, msg_context, spec, parent=None):
md5sum = genmsg.compute_md5(msg_context, parent or spec)
for c in (message_class(spec), new_message_class(spec)):
s.write('(cl:defmethod roslisp-msg-protocol:md5sum ((type (cl:eql \'%s)))'%c)
with Indent(s):
# t2 this should print 'service' instead of 'message' if it's a service request or response
s.write('"Returns md5sum for a message object of type \'%s"'%c)
s.write('"%s")'%md5sum)
def write_message_definition(s, msg_context, spec):
for c in (message_class(spec), new_message_class(spec)):
s.write('(cl:defmethod roslisp-msg-protocol:message-definition ((type (cl:eql \'%s)))'%c)
with Indent(s):
s.write('"Returns full string definition for message of type \'%s"'%c)
s.write('(cl:format cl:nil "')
definition = genmsg.compute_full_text(msg_context, spec)
lines = definition.split('\n')
for line in lines:
l = line.replace('\\', '\\\\')
l = l.replace('"', '\\"')
s.write('%s~%%'%l, indent=False)
s.write('~%', indent=False)
s.write('"))', indent=False)
def write_builtin_length(s, f, var='msg'):
if f.base_type in ['int8', 'uint8']:
s.write('1')
elif f.base_type in ['int16', 'uint16']:
s.write('2')
elif f.base_type in ['int32', 'uint32', 'float32']:
s.write('4')
elif f.base_type in ['int64', 'uint64', 'float64', 'duration', 'time']:
s.write('8')
elif f.base_type == 'string':
s.write('4 (cl:length %s)'%var)
elif f.base_type in ['bool', 'byte', 'char']:
s.write('1')
else:
raise ValueError('Unknown: %s', f.base_type)
def write_serialization_length(s, spec):
c = message_class(spec)
s.write('(cl:defmethod roslisp-msg-protocol:serialization-length ((msg %s))'%c)
with Indent(s):
s.write('(cl:+ 0')
with Indent(s, 3):
for field in spec.parsed_fields():
slot = '(cl:slot-value msg \'%s)'%field.name
if field.is_array:
l = '0' if field.array_len else '4'
s.write('%s (cl:reduce #\'cl:+ %s :key #\'(cl:lambda (ele) (cl:declare (cl:ignorable ele)) (cl:+ '%(l, slot))
var = 'ele'
s.block_next_indent()
else:
var = slot
if field.is_builtin:
write_builtin_length(s, field, var)
else:
s.write('(roslisp-msg-protocol:serialization-length %s)'%var)
if field.is_array:
s.write(')))', False)
s.write('))')
def write_list_converter(s, spec):
c = message_class(spec)
s.write('(cl:defmethod roslisp-msg-protocol:ros-message-to-list ((msg %s))'%c)
with Indent(s):
s.write('"Converts a ROS message object to a list"')
s.write('(cl:list \'%s'%new_message_class(spec))
with Indent(s):
for f in spec.parsed_fields():
s.write('(cl:cons \':%s (%s msg))'%(f.name, f.name))
s.write('))')
def write_constants(s, spec):
if spec.constants:
for cls in (message_class(spec), new_message_class(spec)):
s.write('(cl:defmethod roslisp-msg-protocol:symbol-codes ((msg-type (cl:eql \'%s)))'%cls)
with Indent(s):
s.write(' "Constants for message type \'%s"'%cls)
s.write('\'(')
with Indent(s, indent_first=False):
for c in spec.constants:
s.write('(:%s . %s)'%(c.name.upper(), c.val))
s.write(')', False)
s.write(')')
def write_srv_component(s, spec, context, parent):
spec.component_type='service'
write_html_include(s, spec)
write_defclass(s, spec)
write_deprecated_readers(s, spec)
write_constants(s, spec)
write_serialize(s, spec)
write_deserialize(s, spec)
write_ros_datatype(s, spec)
write_md5sum(s, context, spec, parent=parent)
write_message_definition(s, context, spec)
write_serialization_length(s, spec)
write_list_converter(s, spec)
def write_service_specific_methods(s, spec):
spec.actual_name=spec.short_name
s.write('(cl:defmethod roslisp-msg-protocol:service-request-type ((msg (cl:eql \'%s)))'%spec.short_name)
with Indent(s):
s.write('\'%s)'%new_message_class(spec.request))
s.write('(cl:defmethod roslisp-msg-protocol:service-response-type ((msg (cl:eql \'%s)))'%spec.short_name)
with Indent(s):
s.write('\'%s)'%new_message_class(spec.response))
s.write('(cl:defmethod roslisp-msg-protocol:ros-datatype ((msg (cl:eql \'%s)))'%spec.short_name)
with Indent(s):
s.write('"Returns string type for a service object of type \'%s"'%message_class(spec))
s.write('"%s")'%spec.full_name)
def generate_msg(pkg, files, out_dir, search_path):
"""
Generate lisp code for all messages in a package
"""
msg_context = MsgContext.create_default()
for f in files:
f = os.path.abspath(f)
infile = os.path.basename(f)
full_type = genmsg.gentools.compute_full_type_name(pkg, infile)
spec = genmsg.msg_loader.load_msg_from_file(msg_context, f, full_type)
generate_msg_from_spec(msg_context, spec, search_path, out_dir, pkg)
def generate_srv(pkg, files, out_dir, search_path):
"""
Generate lisp code for all services in a package
"""
msg_context = MsgContext.create_default()
for f in files:
f = os.path.abspath(f)
infile = os.path.basename(f)
full_type = genmsg.gentools.compute_full_type_name(pkg, infile)
spec = genmsg.msg_loader.load_srv_from_file(msg_context, f, full_type)
generate_srv_from_spec(msg_context, spec, search_path, out_dir, pkg, f)
def msg_list(pkg, search_path, ext):
dir_list = search_path[pkg]
files = []
for d in dir_list:
files.extend([f for f in os.listdir(d) if f.endswith(ext)])
return [f[:-len(ext)] for f in files]
def generate_msg_from_spec(msg_context, spec, search_path, output_dir, package):
"""
Generate a message
@param msg_path: The path to the .msg file
@type msg_path: str
"""
genmsg.msg_loader.load_depends(msg_context, spec, search_path)
spec.actual_name=spec.short_name
spec.component_type='message'
msgs = msg_list(package, search_path, '.msg')
for m in msgs:
genmsg.load_msg_by_type(msg_context, '%s/%s'%(package, m), search_path)
########################################
# 1. Write the .lisp file
########################################
io = StringIO()
s = IndentedWriter(io)
write_begin(s, spec)
write_html_include(s, spec)
write_defclass(s, spec)
write_deprecated_readers(s, spec)
write_constants(s, spec)
write_serialize(s, spec)
write_deserialize(s, spec)
write_ros_datatype(s, spec)
write_md5sum(s, msg_context, spec)
write_message_definition(s, msg_context, spec)
write_serialization_length(s, spec)
write_list_converter(s, spec)
if (not os.path.exists(output_dir)):
# if we're being run concurrently, the above test can report false but os.makedirs can still fail if
# another copy just created the directory
try:
os.makedirs(output_dir)
except OSError as e:
pass
with open('%s/%s.lisp'%(output_dir, spec.short_name), 'w') as f:
f.write(io.getvalue() + "\n")
io.close()
########################################
# 2. Write the _package file
# for this message
########################################
io = StringIO()
s = IndentedWriter(io)
write_accessor_exports(s, spec)
with open('%s/_package_%s.lisp'%(output_dir, spec.short_name), 'w') as f:
f.write(io.getvalue())
io.close()
########################################
# 3. Write the _package.lisp file
# This is being rewritten once per msg
# file, which is inefficient
########################################
io = StringIO()
s = IndentedWriter(io)
write_class_exports(s, msgs, package)
with open('%s/_package.lisp'%output_dir, 'w') as f:
f.write(io.getvalue())
io.close()
########################################
# 4. Write the .asd file
# This is being written once per msg
# file, which is inefficient
########################################
io = StringIO()
s = IndentedWriter(io)
write_asd(s, package, msgs, msg_context)
with open('%s/%s-msg.asd'%(output_dir, package), 'w') as f:
f.write(io.getvalue())
io.close()
# t0 most of this could probably be refactored into being shared with messages
def generate_srv_from_spec(msg_context, spec, search_path, output_dir, package, path):
"Generate code from .srv file"
genmsg.msg_loader.load_depends(msg_context, spec, search_path)
ext = '.srv'
srv_path = os.path.dirname(path)
srvs = msg_list(package, {package: [srv_path]}, ext)
for srv in srvs:
load_srv_from_file(msg_context, '%s/%s%s'%(srv_path, srv, ext), '%s/%s'%(package, srv))
########################################
# 1. Write the .lisp file
########################################
io = StringIO()
s = IndentedWriter(io)
write_begin(s, spec, True)
spec.request.actual_name='%s-request'%spec.short_name
spec.response.actual_name='%s-response'%spec.short_name
write_srv_component(s, spec.request, msg_context, spec)
s.newline()
write_srv_component(s, spec.response, msg_context, spec)
write_service_specific_methods(s, spec)
with open('%s/%s.lisp'%(output_dir, spec.short_name), 'w') as f:
f.write(io.getvalue())
io.close()
########################################
# 2. Write the _package file
# for this service
########################################
io = StringIO()
s = IndentedWriter(io)
write_accessor_exports(s, spec)
with open('%s/_package_%s.lisp'%(output_dir, spec.short_name), 'w') as f:
f.write(io.getvalue())
io.close()
########################################
# 3. Write the _package.lisp file
########################################
io = StringIO()
s = IndentedWriter(io)
write_srv_exports(s, srvs, package)
with open('%s/_package.lisp'%output_dir, 'w') as f:
f.write(io.getvalue())
io.close()
########################################
# 4. Write the .asd file
########################################
io = StringIO()
s = IndentedWriter(io)
write_srv_asd(s, package, srvs, msg_context)
with open('%s/%s-srv.asd'%(output_dir, package), 'w') as f:
f.write(io.getvalue())
io.close()
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp/src | apollo_public_repos/apollo-platform/ros/genlisp/src/genlisp/__init__.py | # Software License Agreement (BSD License)
#
# Copyright (c) 2011, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Willow Garage, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from . genlisp_main import *
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/pcl_conversions/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(pcl_conversions)
find_package(catkin REQUIRED COMPONENTS pcl_msgs roscpp sensor_msgs std_msgs cmake_modules)
find_package(PCL REQUIRED QUIET COMPONENTS common)
find_package(Eigen REQUIRED)
include_directories(include ${catkin_INCLUDE_DIRS} ${PCL_COMMON_INCLUDE_DIRS} ${Eigen_INCLUDE_DIRS})
catkin_package(
INCLUDE_DIRS include ${PCL_COMMON_INCLUDE_DIRS}
CATKIN_DEPENDS pcl_msgs roscpp sensor_msgs std_msgs
)
# Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
# Add gtest based cpp test target
if(CATKIN_ENABLE_TESTING)
catkin_add_gtest(${PROJECT_NAME}-test test/test_pcl_conversions.cpp)
target_link_libraries(${PROJECT_NAME}-test ${catkin_LIBRARIES})
endif()
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/pcl_conversions/package.xml | <?xml version="1.0"?>
<package>
<name>pcl_conversions</name>
<version>0.2.1</version>
<description>Provides conversions from PCL data types and ROS message types</description>
<author email="william@osrfoundation.org">William Woodall</author>
<maintainer email="paul@bovbel.com">Paul Bovbel</maintainer>
<maintainer email="bill@neautomation.com">Bill Morris</maintainer>
<license>BSD</license>
<url>http://wiki.ros.org/pcl_conversions</url>
<url type="repository">https://github.com/ros-perception/pcl_conversions</url>
<url type="bugtracker">https://github.com/ros-perception/pcl_conversions/issues</url>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>cmake_modules</build_depend>
<build_depend>libpcl-all-dev</build_depend>
<build_depend>pcl_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>libpcl-all</run_depend>
<run_depend>libpcl-all-dev</run_depend>
<run_depend>pcl_msgs</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>std_msgs</run_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/pcl_conversions/README.rst | pcl_conversions
===============
This package provides conversions from PCL data types and ROS message types.
Code & tickets
--------------
.. Build status: |Build Status|
.. .. |Build Status| image:: https://secure.travis-ci.org/ros-perception/pcl_conversions.png
:target: http://travis-ci.org/ros-perception/pcl_conversions
+-----------------+------------------------------------------------------------+
| pcl_conversions | http://ros.org/wiki/pcl_conversions |
+-----------------+------------------------------------------------------------+
| Issues | http://github.com/ros-perception/pcl_conversions/issues |
+-----------------+------------------------------------------------------------+
.. | Documentation | http://ros-perception.github.com/pcl_conversions/doc |
.. +-----------------+------------------------------------------------------------+
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/pcl_conversions/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package pcl_conversions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.2.1 (2015-06-08)
------------------
* Added a test for rounding errors in stamp conversion
for some values the test fails.
* add pcl::PointCloud to Image msg converter for extracting the rgb component of a cloud
* Contributors: Brice Rebsamen, Lucid One, Michael Ferguson, Paul Bovbel
0.2.0 (2014-04-10)
------------------
* Added conversions for stamp types
* update maintainer info, add eigen dependency
* fix Eigen dependency
* Make pcl_conversions run_depend on libpcl-all-dev
* Contributors: Brice Rebsamen, Paul Bovbel, Scott K Logan, William Woodall
0.1.5 (2013-08-27)
------------------
* Use new pcl rosdep keys (libpcl-all and libpcl-all-dev)
0.1.4 (2013-07-13)
------------------
* Fixup dependencies and CMakeLists.txt:
* Added a versioned dependency on pcl, fixes `#1 <https://github.com/ros-perception/pcl_conversions/issues/1>`_
* Added a dependency on pcl_msgs, fixes `#2 <https://github.com/ros-perception/pcl_conversions/issues/2>`_
* Wrapped the test target in a CATKIN_ENABLE_TESTING check
0.1.3 (2013-07-13)
------------------
* Add missing dependency on roscpp
* Fixup tests and pcl usage in CMakeList.txt
0.1.2 (2013-07-12)
------------------
* small fix for conversion functions
0.1.1 (2013-07-10)
------------------
* Fix find_package bug with pcl
0.1.0 (2013-07-09 21:49:26 -0700)
---------------------------------
- Initial release
- This package is designed to allow users to more easily convert between pcl-1.7+ types and ROS message types
| 0 |
apollo_public_repos/apollo-platform/ros/pcl_conversions | apollo_public_repos/apollo-platform/ros/pcl_conversions/test/test_pcl_conversions.cpp | #include <string>
#include "gtest/gtest.h"
#include "pcl_conversions/pcl_conversions.h"
namespace {
class PCLConversionTests : public ::testing::Test {
protected:
virtual void SetUp() {
pcl_image.header.frame_id = "pcl";
pcl_image.height = 1;
pcl_image.width = 2;
pcl_image.step = 1;
pcl_image.is_bigendian = true;
pcl_image.encoding = "bgr8";
pcl_image.data.resize(2);
pcl_image.data[0] = 0x42;
pcl_image.data[1] = 0x43;
pcl_pc2.header.frame_id = "pcl";
pcl_pc2.height = 1;
pcl_pc2.width = 2;
pcl_pc2.point_step = 1;
pcl_pc2.row_step = 1;
pcl_pc2.is_bigendian = true;
pcl_pc2.is_dense = true;
pcl_pc2.fields.resize(2);
pcl_pc2.fields[0].name = "XYZ";
pcl_pc2.fields[0].datatype = pcl::PCLPointField::INT8;
pcl_pc2.fields[0].count = 3;
pcl_pc2.fields[0].offset = 0;
pcl_pc2.fields[1].name = "RGB";
pcl_pc2.fields[1].datatype = pcl::PCLPointField::INT8;
pcl_pc2.fields[1].count = 3;
pcl_pc2.fields[1].offset = 8 * 3;
pcl_pc2.data.resize(2);
pcl_pc2.data[0] = 0x42;
pcl_pc2.data[1] = 0x43;
}
pcl::PCLImage pcl_image;
sensor_msgs::Image image;
pcl::PCLPointCloud2 pcl_pc2;
sensor_msgs::PointCloud2 pc2;
};
template<class T>
void test_image(T &image) {
EXPECT_EQ(std::string("pcl"), image.header.frame_id);
EXPECT_EQ(1, image.height);
EXPECT_EQ(2, image.width);
EXPECT_EQ(1, image.step);
EXPECT_TRUE(image.is_bigendian);
EXPECT_EQ(std::string("bgr8"), image.encoding);
EXPECT_EQ(2, image.data.size());
EXPECT_EQ(0x42, image.data[0]);
EXPECT_EQ(0x43, image.data[1]);
}
TEST_F(PCLConversionTests, imageConversion) {
pcl_conversions::fromPCL(pcl_image, image);
test_image(image);
pcl::PCLImage pcl_image2;
pcl_conversions::toPCL(image, pcl_image2);
test_image(pcl_image2);
}
template<class T>
void test_pc(T &pc) {
EXPECT_EQ(std::string("pcl"), pc.header.frame_id);
EXPECT_EQ(1, pc.height);
EXPECT_EQ(2, pc.width);
EXPECT_EQ(1, pc.point_step);
EXPECT_EQ(1, pc.row_step);
EXPECT_TRUE(pc.is_bigendian);
EXPECT_TRUE(pc.is_dense);
EXPECT_EQ("XYZ", pc.fields[0].name);
EXPECT_EQ(pcl::PCLPointField::INT8, pc.fields[0].datatype);
EXPECT_EQ(3, pc.fields[0].count);
EXPECT_EQ(0, pc.fields[0].offset);
EXPECT_EQ("RGB", pc.fields[1].name);
EXPECT_EQ(pcl::PCLPointField::INT8, pc.fields[1].datatype);
EXPECT_EQ(3, pc.fields[1].count);
EXPECT_EQ(8 * 3, pc.fields[1].offset);
EXPECT_EQ(2, pc.data.size());
EXPECT_EQ(0x42, pc.data[0]);
EXPECT_EQ(0x43, pc.data[1]);
}
TEST_F(PCLConversionTests, pointcloud2Conversion) {
pcl_conversions::fromPCL(pcl_pc2, pc2);
test_pc(pc2);
pcl::PCLPointCloud2 pcl_pc2_2;
pcl_conversions::toPCL(pc2, pcl_pc2_2);
test_pc(pcl_pc2_2);
}
} // namespace
struct StampTestData
{
const ros::Time stamp_;
ros::Time stamp2_;
explicit StampTestData(const ros::Time &stamp)
: stamp_(stamp)
{
pcl::uint64_t pcl_stamp;
pcl_conversions::toPCL(stamp_, pcl_stamp);
pcl_conversions::fromPCL(pcl_stamp, stamp2_);
}
};
TEST(PCLConversionStamp, Stamps)
{
{
const StampTestData d(ros::Time(1.000001));
EXPECT_TRUE(d.stamp_==d.stamp2_);
}
{
const StampTestData d(ros::Time(1.999999));
EXPECT_TRUE(d.stamp_==d.stamp2_);
}
{
const StampTestData d(ros::Time(1.999));
EXPECT_TRUE(d.stamp_==d.stamp2_);
}
{
const StampTestData d(ros::Time(1423680574, 746000000));
EXPECT_TRUE(d.stamp_==d.stamp2_);
}
{
const StampTestData d(ros::Time(1423680629, 901000000));
EXPECT_TRUE(d.stamp_==d.stamp2_);
}
}
int main(int argc, char **argv) {
try {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} catch (std::exception &e) {
std::cerr << "Unhandled Exception: " << e.what() << std::endl;
}
return 1;
}
| 0 |
apollo_public_repos/apollo-platform/ros/pcl_conversions/include | apollo_public_repos/apollo-platform/ros/pcl_conversions/include/pcl_conversions/pcl_conversions.h | /*
* Software License Agreement (BSD License)
*
* Copyright (c) 2013, Open Source Robotics Foundation, Inc.
* Copyright (c) 2010-2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation, Inc. nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PCL_CONVERSIONS_H__
#define PCL_CONVERSIONS_H__
#include <vector>
#include <ros/ros.h>
#include <pcl/conversions.h>
#include <pcl/PCLHeader.h>
#include <std_msgs/Header.h>
#include <pcl/PCLImage.h>
#include <sensor_msgs/Image.h>
#include <pcl/PCLPointField.h>
#include <sensor_msgs/PointField.h>
#include <pcl/PCLPointCloud2.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl/PointIndices.h>
#include <pcl_msgs/PointIndices.h>
#include <pcl/ModelCoefficients.h>
#include <pcl_msgs/ModelCoefficients.h>
#include <pcl/Vertices.h>
#include <pcl_msgs/Vertices.h>
#include <pcl/PolygonMesh.h>
#include <pcl_msgs/PolygonMesh.h>
#include <pcl/io/pcd_io.h>
#include <Eigen/StdVector>
#include <Eigen/Geometry>
namespace pcl_conversions {
/** PCLHeader <=> Header **/
inline
void fromPCL(const pcl::uint64_t &pcl_stamp, ros::Time &stamp)
{
stamp.fromNSec(pcl_stamp * 1000ull); // Convert from us to ns
}
inline
void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)
{
pcl_stamp = stamp.toNSec() / 1000ull; // Convert from ns to us
}
inline
ros::Time fromPCL(const pcl::uint64_t &pcl_stamp)
{
ros::Time stamp;
fromPCL(pcl_stamp, stamp);
return stamp;
}
inline
pcl::uint64_t toPCL(const ros::Time &stamp)
{
pcl::uint64_t pcl_stamp;
toPCL(stamp, pcl_stamp);
return pcl_stamp;
}
/** PCLHeader <=> Header **/
inline
void fromPCL(const pcl::PCLHeader &pcl_header, std_msgs::Header &header)
{
fromPCL(pcl_header.stamp, header.stamp);
header.seq = pcl_header.seq;
header.frame_id = pcl_header.frame_id;
}
inline
void toPCL(const std_msgs::Header &header, pcl::PCLHeader &pcl_header)
{
toPCL(header.stamp, pcl_header.stamp);
pcl_header.seq = header.seq;
pcl_header.frame_id = header.frame_id;
}
inline
std_msgs::Header fromPCL(const pcl::PCLHeader &pcl_header)
{
std_msgs::Header header;
fromPCL(pcl_header, header);
return header;
}
inline
pcl::PCLHeader toPCL(const std_msgs::Header &header)
{
pcl::PCLHeader pcl_header;
toPCL(header, pcl_header);
return pcl_header;
}
/** PCLImage <=> Image **/
inline
void copyPCLImageMetaData(const pcl::PCLImage &pcl_image, sensor_msgs::Image &image)
{
fromPCL(pcl_image.header, image.header);
image.height = pcl_image.height;
image.width = pcl_image.width;
image.encoding = pcl_image.encoding;
image.is_bigendian = pcl_image.is_bigendian;
image.step = pcl_image.step;
}
inline
void fromPCL(const pcl::PCLImage &pcl_image, sensor_msgs::Image &image)
{
copyPCLImageMetaData(pcl_image, image);
image.data = pcl_image.data;
}
inline
void moveFromPCL(pcl::PCLImage &pcl_image, sensor_msgs::Image &image)
{
copyPCLImageMetaData(pcl_image, image);
image.data.swap(pcl_image.data);
}
inline
void copyImageMetaData(const sensor_msgs::Image &image, pcl::PCLImage &pcl_image)
{
toPCL(image.header, pcl_image.header);
pcl_image.height = image.height;
pcl_image.width = image.width;
pcl_image.encoding = image.encoding;
pcl_image.is_bigendian = image.is_bigendian;
pcl_image.step = image.step;
}
inline
void toPCL(const sensor_msgs::Image &image, pcl::PCLImage &pcl_image)
{
copyImageMetaData(image, pcl_image);
pcl_image.data = image.data;
}
inline
void moveToPCL(sensor_msgs::Image &image, pcl::PCLImage &pcl_image)
{
copyImageMetaData(image, pcl_image);
pcl_image.data.swap(image.data);
}
/** PCLPointField <=> PointField **/
inline
void fromPCL(const pcl::PCLPointField &pcl_pf, sensor_msgs::PointField &pf)
{
pf.name = pcl_pf.name;
pf.offset = pcl_pf.offset;
pf.datatype = pcl_pf.datatype;
pf.count = pcl_pf.count;
}
inline
void fromPCL(const std::vector<pcl::PCLPointField> &pcl_pfs, std::vector<sensor_msgs::PointField> &pfs)
{
pfs.resize(pcl_pfs.size());
std::vector<pcl::PCLPointField>::const_iterator it = pcl_pfs.begin();
int i = 0;
for(; it != pcl_pfs.end(); ++it, ++i) {
fromPCL(*(it), pfs[i]);
}
}
inline
void toPCL(const sensor_msgs::PointField &pf, pcl::PCLPointField &pcl_pf)
{
pcl_pf.name = pf.name;
pcl_pf.offset = pf.offset;
pcl_pf.datatype = pf.datatype;
pcl_pf.count = pf.count;
}
inline
void toPCL(const std::vector<sensor_msgs::PointField> &pfs, std::vector<pcl::PCLPointField> &pcl_pfs)
{
pcl_pfs.resize(pfs.size());
std::vector<sensor_msgs::PointField>::const_iterator it = pfs.begin();
int i = 0;
for(; it != pfs.end(); ++it, ++i) {
toPCL(*(it), pcl_pfs[i]);
}
}
/** PCLPointCloud2 <=> PointCloud2 **/
inline
void copyPCLPointCloud2MetaData(const pcl::PCLPointCloud2 &pcl_pc2, sensor_msgs::PointCloud2 &pc2)
{
fromPCL(pcl_pc2.header, pc2.header);
pc2.height = pcl_pc2.height;
pc2.width = pcl_pc2.width;
fromPCL(pcl_pc2.fields, pc2.fields);
pc2.is_bigendian = pcl_pc2.is_bigendian;
pc2.point_step = pcl_pc2.point_step;
pc2.row_step = pcl_pc2.row_step;
pc2.is_dense = pcl_pc2.is_dense;
}
inline
void fromPCL(const pcl::PCLPointCloud2 &pcl_pc2, sensor_msgs::PointCloud2 &pc2)
{
copyPCLPointCloud2MetaData(pcl_pc2, pc2);
pc2.data = pcl_pc2.data;
}
inline
void moveFromPCL(pcl::PCLPointCloud2 &pcl_pc2, sensor_msgs::PointCloud2 &pc2)
{
copyPCLPointCloud2MetaData(pcl_pc2, pc2);
pc2.data.swap(pcl_pc2.data);
}
inline
void copyPointCloud2MetaData(const sensor_msgs::PointCloud2 &pc2, pcl::PCLPointCloud2 &pcl_pc2)
{
toPCL(pc2.header, pcl_pc2.header);
pcl_pc2.height = pc2.height;
pcl_pc2.width = pc2.width;
toPCL(pc2.fields, pcl_pc2.fields);
pcl_pc2.is_bigendian = pc2.is_bigendian;
pcl_pc2.point_step = pc2.point_step;
pcl_pc2.row_step = pc2.row_step;
pcl_pc2.is_dense = pc2.is_dense;
}
inline
void toPCL(const sensor_msgs::PointCloud2 &pc2, pcl::PCLPointCloud2 &pcl_pc2)
{
copyPointCloud2MetaData(pc2, pcl_pc2);
pcl_pc2.data = pc2.data;
}
inline
void moveToPCL(sensor_msgs::PointCloud2 &pc2, pcl::PCLPointCloud2 &pcl_pc2)
{
copyPointCloud2MetaData(pc2, pcl_pc2);
pcl_pc2.data.swap(pc2.data);
}
/** pcl::PointIndices <=> pcl_msgs::PointIndices **/
inline
void fromPCL(const pcl::PointIndices &pcl_pi, pcl_msgs::PointIndices &pi)
{
fromPCL(pcl_pi.header, pi.header);
pi.indices = pcl_pi.indices;
}
inline
void moveFromPCL(pcl::PointIndices &pcl_pi, pcl_msgs::PointIndices &pi)
{
fromPCL(pcl_pi.header, pi.header);
pi.indices.swap(pcl_pi.indices);
}
inline
void toPCL(const pcl_msgs::PointIndices &pi, pcl::PointIndices &pcl_pi)
{
toPCL(pi.header, pcl_pi.header);
pcl_pi.indices = pi.indices;
}
inline
void moveToPCL(pcl_msgs::PointIndices &pi, pcl::PointIndices &pcl_pi)
{
toPCL(pi.header, pcl_pi.header);
pcl_pi.indices.swap(pi.indices);
}
/** pcl::ModelCoefficients <=> pcl_msgs::ModelCoefficients **/
inline
void fromPCL(const pcl::ModelCoefficients &pcl_mc, pcl_msgs::ModelCoefficients &mc)
{
fromPCL(pcl_mc.header, mc.header);
mc.values = pcl_mc.values;
}
inline
void moveFromPCL(pcl::ModelCoefficients &pcl_mc, pcl_msgs::ModelCoefficients &mc)
{
fromPCL(pcl_mc.header, mc.header);
mc.values.swap(pcl_mc.values);
}
inline
void toPCL(const pcl_msgs::ModelCoefficients &mc, pcl::ModelCoefficients &pcl_mc)
{
toPCL(mc.header, pcl_mc.header);
pcl_mc.values = mc.values;
}
inline
void moveToPCL(pcl_msgs::ModelCoefficients &mc, pcl::ModelCoefficients &pcl_mc)
{
toPCL(mc.header, pcl_mc.header);
pcl_mc.values.swap(mc.values);
}
/** pcl::Vertices <=> pcl_msgs::Vertices **/
inline
void fromPCL(const pcl::Vertices &pcl_vert, pcl_msgs::Vertices &vert)
{
vert.vertices = pcl_vert.vertices;
}
inline
void fromPCL(const std::vector<pcl::Vertices> &pcl_verts, std::vector<pcl_msgs::Vertices> &verts)
{
verts.resize(pcl_verts.size());
std::vector<pcl::Vertices>::const_iterator it = pcl_verts.begin();
std::vector<pcl_msgs::Vertices>::iterator jt = verts.begin();
for (; it != pcl_verts.end() && jt != verts.end(); ++it, ++jt) {
fromPCL(*(it), *(jt));
}
}
inline
void moveFromPCL(pcl::Vertices &pcl_vert, pcl_msgs::Vertices &vert)
{
vert.vertices.swap(pcl_vert.vertices);
}
inline
void fromPCL(std::vector<pcl::Vertices> &pcl_verts, std::vector<pcl_msgs::Vertices> &verts)
{
verts.resize(pcl_verts.size());
std::vector<pcl::Vertices>::iterator it = pcl_verts.begin();
std::vector<pcl_msgs::Vertices>::iterator jt = verts.begin();
for (; it != pcl_verts.end() && jt != verts.end(); ++it, ++jt) {
moveFromPCL(*(it), *(jt));
}
}
inline
void toPCL(const pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
{
pcl_vert.vertices = vert.vertices;
}
inline
void toPCL(const std::vector<pcl_msgs::Vertices> &verts, std::vector<pcl::Vertices> &pcl_verts)
{
pcl_verts.resize(verts.size());
std::vector<pcl_msgs::Vertices>::const_iterator it = verts.begin();
std::vector<pcl::Vertices>::iterator jt = pcl_verts.begin();
for (; it != verts.end() && jt != pcl_verts.end(); ++it, ++jt) {
toPCL(*(it), *(jt));
}
}
inline
void moveToPCL(pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
{
pcl_vert.vertices.swap(vert.vertices);
}
inline
void moveToPCL(std::vector<pcl_msgs::Vertices> &verts, std::vector<pcl::Vertices> &pcl_verts)
{
pcl_verts.resize(verts.size());
std::vector<pcl_msgs::Vertices>::iterator it = verts.begin();
std::vector<pcl::Vertices>::iterator jt = pcl_verts.begin();
for (; it != verts.end() && jt != pcl_verts.end(); ++it, ++jt) {
moveToPCL(*(it), *(jt));
}
}
/** pcl::PolygonMesh <=> pcl_msgs::PolygonMesh **/
inline
void fromPCL(const pcl::PolygonMesh &pcl_mesh, pcl_msgs::PolygonMesh &mesh)
{
fromPCL(pcl_mesh.header, mesh.header);
fromPCL(pcl_mesh.cloud, mesh.cloud);
fromPCL(pcl_mesh.polygons, mesh.polygons);
}
inline
void moveFromPCL(pcl::PolygonMesh &pcl_mesh, pcl_msgs::PolygonMesh &mesh)
{
fromPCL(pcl_mesh.header, mesh.header);
moveFromPCL(pcl_mesh.cloud, mesh.cloud);
}
inline
void toPCL(const pcl_msgs::PolygonMesh &mesh, pcl::PolygonMesh &pcl_mesh)
{
toPCL(mesh.header, pcl_mesh.header);
toPCL(mesh.cloud, pcl_mesh.cloud);
toPCL(mesh.polygons, pcl_mesh.polygons);
}
inline
void moveToPCL(pcl_msgs::PolygonMesh &mesh, pcl::PolygonMesh &pcl_mesh)
{
toPCL(mesh.header, pcl_mesh.header);
moveToPCL(mesh.cloud, pcl_mesh.cloud);
moveToPCL(mesh.polygons, pcl_mesh.polygons);
}
} // namespace pcl_conversions
namespace pcl {
/** Overload pcl::getFieldIndex **/
inline int getFieldIndex(const sensor_msgs::PointCloud2 &cloud, const std::string &field_name)
{
// Get the index we need
for (size_t d = 0; d < cloud.fields.size(); ++d) {
if (cloud.fields[d].name == field_name) {
return (static_cast<int>(d));
}
}
return (-1);
}
/** Overload pcl::getFieldsList **/
inline std::string getFieldsList(const sensor_msgs::PointCloud2 &cloud)
{
std::string result;
for (size_t i = 0; i < cloud.fields.size () - 1; ++i) {
result += cloud.fields[i].name + " ";
}
result += cloud.fields[cloud.fields.size () - 1].name;
return (result);
}
/** Provide pcl::toROSMsg **/
inline
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
{
pcl::PCLPointCloud2 pcl_cloud;
pcl_conversions::toPCL(cloud, pcl_cloud);
pcl::PCLImage pcl_image;
pcl::toPCLPointCloud2(pcl_cloud, pcl_image);
pcl_conversions::moveFromPCL(pcl_image, image);
}
inline
void moveToROSMsg(sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
{
pcl::PCLPointCloud2 pcl_cloud;
pcl_conversions::moveToPCL(cloud, pcl_cloud);
pcl::PCLImage pcl_image;
pcl::toPCLPointCloud2(pcl_cloud, pcl_image);
pcl_conversions::moveFromPCL(pcl_image, image);
}
template<typename T> void
toROSMsg (const pcl::PointCloud<T> &cloud, sensor_msgs::Image& msg)
{
// Ease the user's burden on specifying width/height for unorganized datasets
if (cloud.width == 0 && cloud.height == 0)
{
throw std::runtime_error("Needs to be a dense like cloud!!");
}
else
{
if (cloud.points.size () != cloud.width * cloud.height)
throw std::runtime_error("The width and height do not match the cloud size!");
msg.height = cloud.height;
msg.width = cloud.width;
}
// sensor_msgs::image_encodings::BGR8;
msg.encoding = "bgr8";
msg.step = msg.width * sizeof (uint8_t) * 3;
msg.data.resize (msg.step * msg.height);
for (size_t y = 0; y < cloud.height; y++)
{
for (size_t x = 0; x < cloud.width; x++)
{
uint8_t * pixel = &(msg.data[y * msg.step + x * 3]);
memcpy (pixel, &cloud (x, y).rgb, 3 * sizeof(uint8_t));
}
}
}
/** Provide to/fromROSMsg for sensor_msgs::PointCloud2 <=> pcl::PointCloud<T> **/
template<typename T>
void toROSMsg(const pcl::PointCloud<T> &pcl_cloud, sensor_msgs::PointCloud2 &cloud)
{
pcl::PCLPointCloud2 pcl_pc2;
pcl::toPCLPointCloud2(pcl_cloud, pcl_pc2);
pcl_conversions::moveFromPCL(pcl_pc2, cloud);
}
template<typename T>
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud<T> &pcl_cloud)
{
pcl::PCLPointCloud2 pcl_pc2;
pcl_conversions::toPCL(cloud, pcl_pc2);
pcl::fromPCLPointCloud2(pcl_pc2, pcl_cloud);
}
template<typename T>
void moveFromROSMsg(sensor_msgs::PointCloud2 &cloud, pcl::PointCloud<T> &pcl_cloud)
{
pcl::PCLPointCloud2 pcl_pc2;
pcl_conversions::moveToPCL(cloud, pcl_pc2);
pcl::fromPCLPointCloud2(pcl_pc2, pcl_cloud);
}
/** Overload pcl::createMapping **/
template<typename PointT>
void createMapping(const std::vector<sensor_msgs::PointField>& msg_fields, MsgFieldMap& field_map)
{
std::vector<pcl::PCLPointField> pcl_msg_fields;
pcl_conversions::toPCL(msg_fields, pcl_msg_fields);
return createMapping<PointT>(pcl_msg_fields, field_map);
}
namespace io {
/** Overload pcl::io::savePCDFile **/
inline int
savePCDFile(const std::string &file_name, const sensor_msgs::PointCloud2 &cloud,
const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
const bool binary_mode = false)
{
pcl::PCLPointCloud2 pcl_cloud;
pcl_conversions::toPCL(cloud, pcl_cloud);
return pcl::io::savePCDFile(file_name, pcl_cloud, origin, orientation, binary_mode);
}
inline int
destructiveSavePCDFile(const std::string &file_name, sensor_msgs::PointCloud2 &cloud,
const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
const bool binary_mode = false)
{
pcl::PCLPointCloud2 pcl_cloud;
pcl_conversions::moveToPCL(cloud, pcl_cloud);
return pcl::io::savePCDFile(file_name, pcl_cloud, origin, orientation, binary_mode);
}
/** Overload pcl::io::loadPCDFile **/
inline int loadPCDFile(const std::string &file_name, sensor_msgs::PointCloud2 &cloud)
{
pcl::PCLPointCloud2 pcl_cloud;
int ret = pcl::io::loadPCDFile(file_name, pcl_cloud);
pcl_conversions::moveFromPCL(pcl_cloud, cloud);
return ret;
}
} // namespace io
/** Overload asdf **/
inline
bool concatenatePointCloud (const sensor_msgs::PointCloud2 &cloud1,
const sensor_msgs::PointCloud2 &cloud2,
sensor_msgs::PointCloud2 &cloud_out)
{
//if one input cloud has no points, but the other input does, just return the cloud with points
if (cloud1.width * cloud1.height == 0 && cloud2.width * cloud2.height > 0)
{
cloud_out = cloud2;
return (true);
}
else if (cloud1.width*cloud1.height > 0 && cloud2.width*cloud2.height == 0)
{
cloud_out = cloud1;
return (true);
}
bool strip = false;
for (size_t i = 0; i < cloud1.fields.size (); ++i)
if (cloud1.fields[i].name == "_")
strip = true;
for (size_t i = 0; i < cloud2.fields.size (); ++i)
if (cloud2.fields[i].name == "_")
strip = true;
if (!strip && cloud1.fields.size () != cloud2.fields.size ())
{
PCL_ERROR ("[pcl::concatenatePointCloud] Number of fields in cloud1 (%u) != Number of fields in cloud2 (%u)\n", cloud1.fields.size (), cloud2.fields.size ());
return (false);
}
// Copy cloud1 into cloud_out
cloud_out = cloud1;
size_t nrpts = cloud_out.data.size ();
// Height = 1 => no more organized
cloud_out.width = cloud1.width * cloud1.height + cloud2.width * cloud2.height;
cloud_out.height = 1;
if (!cloud1.is_dense || !cloud2.is_dense)
cloud_out.is_dense = false;
else
cloud_out.is_dense = true;
// We need to strip the extra padding fields
if (strip)
{
// Get the field sizes for the second cloud
std::vector<sensor_msgs::PointField> fields2;
std::vector<int> fields2_sizes;
for (size_t j = 0; j < cloud2.fields.size (); ++j)
{
if (cloud2.fields[j].name == "_")
continue;
fields2_sizes.push_back (cloud2.fields[j].count *
pcl::getFieldSize (cloud2.fields[j].datatype));
fields2.push_back (cloud2.fields[j]);
}
cloud_out.data.resize (nrpts + (cloud2.width * cloud2.height) * cloud_out.point_step);
// Copy the second cloud
for (size_t cp = 0; cp < cloud2.width * cloud2.height; ++cp)
{
int i = 0;
for (size_t j = 0; j < fields2.size (); ++j)
{
if (cloud1.fields[i].name == "_")
{
++i;
continue;
}
// We're fine with the special RGB vs RGBA use case
if ((cloud1.fields[i].name == "rgb" && fields2[j].name == "rgba") ||
(cloud1.fields[i].name == "rgba" && fields2[j].name == "rgb") ||
(cloud1.fields[i].name == fields2[j].name))
{
memcpy (reinterpret_cast<char*> (&cloud_out.data[nrpts + cp * cloud1.point_step + cloud1.fields[i].offset]),
reinterpret_cast<const char*> (&cloud2.data[cp * cloud2.point_step + cloud2.fields[j].offset]),
fields2_sizes[j]);
++i; // increment the field size i
}
}
}
}
else
{
for (size_t i = 0; i < cloud1.fields.size (); ++i)
{
// We're fine with the special RGB vs RGBA use case
if ((cloud1.fields[i].name == "rgb" && cloud2.fields[i].name == "rgba") ||
(cloud1.fields[i].name == "rgba" && cloud2.fields[i].name == "rgb"))
continue;
// Otherwise we need to make sure the names are the same
if (cloud1.fields[i].name != cloud2.fields[i].name)
{
PCL_ERROR ("[pcl::concatenatePointCloud] Name of field %d in cloud1, %s, does not match name in cloud2, %s\n", i, cloud1.fields[i].name.c_str (), cloud2.fields[i].name.c_str ());
return (false);
}
}
cloud_out.data.resize (nrpts + cloud2.data.size ());
memcpy (&cloud_out.data[nrpts], &cloud2.data[0], cloud2.data.size ());
}
return (true);
}
} // namespace pcl
namespace ros
{
template<>
struct DefaultMessageCreator<pcl::PCLPointCloud2>
{
boost::shared_ptr<pcl::PCLPointCloud2> operator() ()
{
boost::shared_ptr<pcl::PCLPointCloud2> msg(new pcl::PCLPointCloud2());
return msg;
}
};
namespace message_traits
{
template<>
struct MD5Sum<pcl::PCLPointCloud2>
{
static const char* value() { return MD5Sum<sensor_msgs::PointCloud2>::value(); }
static const char* value(const pcl::PCLPointCloud2&) { return value(); }
static const uint64_t static_value1 = MD5Sum<sensor_msgs::PointCloud2>::static_value1;
static const uint64_t static_value2 = MD5Sum<sensor_msgs::PointCloud2>::static_value2;
// If the definition of sensor_msgs/PointCloud2 changes, we'll get a compile error here.
ROS_STATIC_ASSERT(static_value1 == 0x1158d486dd51d683ULL);
ROS_STATIC_ASSERT(static_value2 == 0xce2f1be655c3c181ULL);
};
template<>
struct DataType<pcl::PCLPointCloud2>
{
static const char* value() { return DataType<sensor_msgs::PointCloud2>::value(); }
static const char* value(const pcl::PCLPointCloud2&) { return value(); }
};
template<>
struct Definition<pcl::PCLPointCloud2>
{
static const char* value() { return Definition<sensor_msgs::PointCloud2>::value(); }
static const char* value(const pcl::PCLPointCloud2&) { return value(); }
};
template<> struct HasHeader<pcl::PCLPointCloud2> : TrueType {};
} // namespace ros::message_traits
namespace serialization
{
/*
* Provide a custom serialization for pcl::PCLPointCloud2
*/
template<>
struct Serializer<pcl::PCLPointCloud2>
{
template<typename Stream>
inline static void write(Stream& stream, const pcl::PCLPointCloud2& m)
{
std_msgs::Header header;
pcl_conversions::fromPCL(m.header, header);
stream.next(header);
stream.next(m.height);
stream.next(m.width);
std::vector<sensor_msgs::PointField> pfs;
pcl_conversions::fromPCL(m.fields, pfs);
stream.next(pfs);
stream.next(m.is_bigendian);
stream.next(m.point_step);
stream.next(m.row_step);
stream.next(m.data);
stream.next(m.is_dense);
}
template<typename Stream>
inline static void read(Stream& stream, pcl::PCLPointCloud2& m)
{
std_msgs::Header header;
stream.next(header);
pcl_conversions::toPCL(header, m.header);
stream.next(m.height);
stream.next(m.width);
std::vector<sensor_msgs::PointField> pfs;
stream.next(pfs);
pcl_conversions::toPCL(pfs, m.fields);
stream.next(m.is_bigendian);
stream.next(m.point_step);
stream.next(m.row_step);
stream.next(m.data);
stream.next(m.is_dense);
}
inline static uint32_t serializedLength(const pcl::PCLPointCloud2& m)
{
uint32_t length = 0;
std_msgs::Header header;
pcl_conversions::fromPCL(m.header, header);
length += serializationLength(header);
length += 4; // height
length += 4; // width
std::vector<sensor_msgs::PointField> pfs;
pcl_conversions::fromPCL(m.fields, pfs);
length += serializationLength(pfs); // fields
length += 1; // is_bigendian
length += 4; // point_step
length += 4; // row_step
length += 4; // data's size
length += m.data.size() * sizeof(pcl::uint8_t);
length += 1; // is_dense
return length;
}
};
/*
* Provide a custom serialization for pcl::PCLPointField
*/
template<>
struct Serializer<pcl::PCLPointField>
{
template<typename Stream>
inline static void write(Stream& stream, const pcl::PCLPointField& m)
{
stream.next(m.name);
stream.next(m.offset);
stream.next(m.datatype);
stream.next(m.count);
}
template<typename Stream>
inline static void read(Stream& stream, pcl::PCLPointField& m)
{
stream.next(m.name);
stream.next(m.offset);
stream.next(m.datatype);
stream.next(m.count);
}
inline static uint32_t serializedLength(const pcl::PCLPointField& m)
{
uint32_t length = 0;
length += serializationLength(m.name);
length += serializationLength(m.offset);
length += serializationLength(m.datatype);
length += serializationLength(m.count);
return length;
}
};
/*
* Provide a custom serialization for pcl::PCLHeader
*/
template<>
struct Serializer<pcl::PCLHeader>
{
template<typename Stream>
inline static void write(Stream& stream, const pcl::PCLHeader& m)
{
std_msgs::Header header;
pcl_conversions::fromPCL(m, header);
stream.next(header);
}
template<typename Stream>
inline static void read(Stream& stream, pcl::PCLHeader& m)
{
std_msgs::Header header;
stream.next(header);
pcl_conversions::toPCL(header, m);
}
inline static uint32_t serializedLength(const pcl::PCLHeader& m)
{
uint32_t length = 0;
std_msgs::Header header;
pcl_conversions::fromPCL(m, header);
length += serializationLength(header);
return length;
}
};
} // namespace ros::serialization
} // namespace ros
#endif /* PCL_CONVERSIONS_H__ */
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/CMakeLists.txt | cmake_minimum_required(VERSION 2.4.6)
project(python_orocos_kdl)
find_package(orocos_kdl)
include_directories(${orocos_kdl_INCLUDE_DIRS})
link_directories(${orocos_kdl_LIBRARY_DIRS})
find_package(PythonInterp REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} REQUIRED)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(SIP REQUIRED)
include(SIPMacros)
include_directories(${SIP_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
file(GLOB SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.sip")
set(SIP_INCLUDES ${SIP_FILES})
set(SIP_EXTRA_OPTIONS "-o")
set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES})
add_sip_python_module(PyKDL PyKDL/PyKDL.sip ${orocos_kdl_LIBRARIES})
install(FILES package.xml DESTINATION share/python_orocos_kdl) | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/package.xml | <package>
<name>python_orocos_kdl</name>
<version>1.3.1</version>
<description>
This package contains the python bindings PyKDL for the Kinematics and Dynamics
Library (KDL), distributed by the Orocos Project.
</description>
<maintainer email="ruben@intermodalics.eu">Ruben Smits</maintainer>
<url>http://wiki.ros.org/python_orocos_kdl</url>
<license>LGPL</license>
<buildtool_depend>cmake</buildtool_depend>
<build_depend>orocos_kdl</build_depend>
<build_depend>python-sip</build_depend>
<run_depend>catkin</run_depend>
<run_depend>orocos_kdl</run_depend>
<run_depend>python-sip</run_depend>
<export>
<build_type>cmake</build_type>
</export>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/mainpage.dox | /**
\mainpage
\htmlinclude manifest.html
\b python_orocos_kdl is ...
<!--
Provide an overview of your package.
-->
\section codeapi Code API
<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.
If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->
*/
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/rosdoc.yaml | - builder: sphinx
output_dir: doc
sphinx_root_dir: doc | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/manifest.xml | <package>
<description brief="python_orocos_kdl">
python_orocos_kdl
</description>
<author>Ruben Smits</author>
<license>LGPL</license>
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/python_orocos_kdl</url>
<depend package="orocos_kdl"/>
<rosdep name="python-sip"/>
<export>
<python path="${prefix}/lib" />
<rosdoc config="rosdoc.yaml"/>
</export>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/.tar | {!!python/unicode 'url': 'https://github.com/smits/orocos-kdl-release/archive/release/indigo/python_orocos_kdl/1.3.1-0.tar.gz',
!!python/unicode 'version': orocos-kdl-release-release-indigo-python_orocos_kdl-1.3.1-0}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/frames.sip | //Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//
//Version: 1.0
//Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//URL: http://www.orocos.org/kdl
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class Vector{
%TypeHeaderCode
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <sstream>
using namespace KDL;
%End
public:
Vector();
Vector(double x, double y, double z);
Vector(const Vector& arg);
void x(double);
void y(double);
void z(double);
double x() const;
double y() const;
double z() const;
double __getitem__ (int index) const;
%MethodCode
if (a0 < 0 || a0 > 2) {
PyErr_SetString(PyExc_IndexError, "Vector index out of range");
return 0;
}
sipRes=(*sipCpp)(a0);
%End
void __setitem__(int index, double value);
%MethodCode
if (a0 < 0 || a0 > 2) {
PyErr_SetString(PyExc_IndexError, "Vector index out of range");
return 0;
}
(*sipCpp)(a0)=a1;
%End
const char* __repr__() const;
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
void ReverseSign();
Vector& operator-=(const Vector& arg);
Vector& operator +=(const Vector& arg);
static Vector Zero()/Factory/;
double Norm();
double Normalize(double eps=epsilon);
%PickleCode
sipRes = Py_BuildValue("ddd", sipCpp->x(), sipCpp->y(), sipCpp->z());
%End
};
void SetToZero(Vector& v);
Vector operator-(const Vector& arg)/Factory/;
Vector operator*(const Vector& lhs,double rhs)/Factory/;
Vector operator*(double lhs,const Vector& rhs)/Factory/;
Vector operator/(const Vector& lhs,double rhs)/Factory/;
Vector operator+(const Vector& lhs,const Vector& rhs)/Factory/;
Vector operator-(const Vector& lhs,const Vector& rhs)/Factory/;
Vector operator*(const Vector& lhs,const Vector& rhs)/Factory/;
double dot(const Vector& lhs,const Vector& rhs);
bool operator==(const Vector& a,const Vector& b);
bool operator!=(const Vector& a,const Vector& b);
bool Equal(const Vector& a,const Vector& b,double eps=epsilon);
class Rotation{
%TypeHeaderCode
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <sstream>
using namespace KDL;
%End
public:
Rotation();
Rotation(double Xx,double Yx,double Zx,
double Xy,double Yy,double Zy,
double Xz,double Yz,double Zz);
Rotation(const Vector& x,const Vector& y,const Vector& z);
double __getitem__(SIP_PYTUPLE) const;
%MethodCode
int i,j;
PyArg_ParseTuple(a0, "ii", &i, &j);
if (i < 0 || j < 0 || i > 2 || j > 2) {
PyErr_SetString(PyExc_IndexError, "Rotation index out of range");
return 0;
}
sipRes=((const Rotation)(*sipCpp))(i,j);
%End
void __setitem__(SIP_PYTUPLE,double value);
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > 2 || j > 2) {
PyErr_SetString(PyExc_IndexError, "Rotation index out of range");
return 0;
}
(*sipCpp)(i,j)=a1;
%End
const char* __repr__() const;
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
void SetInverse();
Rotation Inverse() const /Factory/;
Vector Inverse(const Vector& v) const /Factory/;
Wrench Inverse(const Wrench& w) const /Factory/;
Twist Inverse(const Twist& t) const /Factory/;
static Rotation Identity()/Factory/;
static Rotation RotX(double angle)/Factory/;
static Rotation RotY(double angle)/Factory/;
static Rotation RotZ(double angle)/Factory/;
static Rotation Rot(const Vector& vec,double angle)/Factory/;
static Rotation Rot2(const Vector& vec,double angle)/Factory/;
static Rotation EulerZYZ(double Alfa,double Beta,double Gamma)/Factory/;
static Rotation RPY(double roll,double pitch,double yaw)/Factory/;
static Rotation EulerZYX(double Alfa,double Beta,double Gamma)/Factory/;
static Rotation Quaternion(double x, double y, double z, double w)/Factory/;
void DoRotX(double angle);
void DoRotY(double angle);
void DoRotZ(double angle);
Vector GetRot() const /Factory/;
double GetRotAngle(Vector& axis /Out/,double eps=epsilon) const;
void GetEulerZYZ(double& alfa /Out/,double& beta /Out/,double& gamma /Out/) const;
void GetRPY(double& roll /Out/,double& pitch /Out/,double& yaw /Out/) const;
void GetEulerZYX(double& Alfa /Out/,double& Beta /Out/,double& Gamma /Out/) const;
void GetQuaternion(double& x /Out/,double& y /Out/,double& z /Out/, double& w) const;
Vector operator*(const Vector& v) const /Numeric,Factory/;
Twist operator*(const Twist& arg) const /Numeric,Factory/;
Wrench operator*(const Wrench& arg) const /Numeric,Factory/;
Vector UnitX() const /Factory/;
Vector UnitY() const /Factory/;
Vector UnitZ() const /Factory/;
void UnitX(const Vector& X);
void UnitY(const Vector& X);
void UnitZ(const Vector& X);
%PickleCode
sipRes = Py_BuildValue("ddddddddd", (*sipCpp)(0,0), (*sipCpp)(0,1), (*sipCpp)(0,2),
(*sipCpp)(1,0), (*sipCpp)(1,1), (*sipCpp)(1,2),
(*sipCpp)(2,0), (*sipCpp)(2,1), (*sipCpp)(2,2));
%End
};
bool Equal(const Rotation& a,const Rotation& b,double eps=epsilon);
bool operator==(const Rotation& a,const Rotation& b);
bool operator!=(const Rotation& a,const Rotation& b);
Rotation operator *(const Rotation& lhs,const Rotation& rhs)/Factory/;
class Frame{
%TypeHeaderCode
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <sstream>
using namespace KDL;
%End
public:
Frame(const Rotation& R,const Vector& V);
Frame(const Vector& V);
Frame(const Rotation& R);
Frame();
Vector p;
Rotation M;
double __getitem__ (SIP_PYTUPLE) const;
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > 2 || j > 3) {
PyErr_SetString(PyExc_IndexError, "Frame index out of range");
return 0;
}
sipRes=(*sipCpp)(i,j);
%End
void __setitem__(SIP_PYTUPLE,double value);
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > 2 || j > 3) {
PyErr_SetString(PyExc_IndexError, "Frame index out of range");
return 0;
}
if(j==3)
(*sipCpp).p(i)=a1;
else
(*sipCpp).M(i,j)=a1;
%End
const char* __repr__() const;
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
Frame DH_Craig1989(double a,double alpha,double d,double theta);
Frame DH(double a,double alpha,double d,double theta);
Frame Inverse()/Factory/;
Vector Inverse(const Vector& arg) const /Factory/;
Wrench Inverse(const Wrench& arg) const /Factory/;
Twist Inverse(const Twist& arg) const /Factory/;
Vector operator*(const Vector& arg) const /Numeric,Factory/;
Wrench operator * (const Wrench& arg) const /Numeric,Factory/;
Twist operator * (const Twist& arg) const /Numeric,Factory/;
static Frame Identity() /Factory/;
void Integrate(const Twist& t_this,double frequency);
%PickleCode
const sipTypeDef *vector_type = sipFindType("Vector");
const sipTypeDef *rotation_type = sipFindType("Rotation");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->M), rotation_type, Py_None),
sipConvertFromType(&(sipCpp->p), vector_type, Py_None));
%End
};
Frame operator *(const Frame& lhs,const Frame& rhs)/Factory/;
bool Equal(const Frame& a,const Frame& b,double eps=epsilon);
bool operator==(const Frame& a,const Frame& b);
bool operator!=(const Frame& a,const Frame& b);
class Twist
{
%TypeHeaderCode
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <sstream>
using namespace KDL;
%End
public:
Vector vel;
Vector rot;
Twist();
Twist(const Vector& _vel,const Vector& _rot);
Twist& operator-=(const Twist& arg);
Twist& operator+=(const Twist& arg);
double __getitem__ (int i) const;
%MethodCode
if (a0 < 0 || a0 > 5) {
PyErr_SetString(PyExc_IndexError, "Twist index out of range");
return 0;
}
sipRes=(*sipCpp)(a0);
%End
void __setitem__(int i, double value);
%MethodCode
if (a0 < 0 || a0 > 5) {
PyErr_SetString(PyExc_IndexError, "Twist index out of range");
return 0;
}
(*sipCpp)(a0)=a1;
%End
const char* __repr__() const;
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
static Twist Zero() /Factory/;
void ReverseSign();
Twist RefPoint(const Vector& v_base_AB) const /Factory/;
%PickleCode
const sipTypeDef *vector_type = sipFindType("Vector");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->vel), vector_type, Py_None),
sipConvertFromType(&(sipCpp->rot), vector_type, Py_None));
%End
};
Twist operator*(const Twist& lhs,double rhs)/Factory/;
Twist operator*(double lhs,const Twist& rhs)/Factory/;
Twist operator/(const Twist& lhs,double rhs)/Factory/;
Twist operator+(const Twist& lhs,const Twist& rhs)/Factory/;
Twist operator-(const Twist& lhs,const Twist& rhs)/Factory/;
Twist operator-(const Twist& arg)/Factory/;
double dot(const Twist& lhs,const Wrench& rhs);
double dot(const Wrench& rhs,const Twist& lhs);
void SetToZero(Twist& v);
bool Equal(const Twist& a,const Twist& b,double eps=epsilon);
bool operator==(const Twist& a,const Twist& b);
bool operator!=(const Twist& a,const Twist& b);
class Wrench
{
%TypeHeaderCode
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <sstream>
using namespace KDL;
%End
public:
Vector force;
Vector torque;
Wrench();
Wrench(const Vector& force,const Vector& torque);
Wrench& operator-=(const Wrench& arg);
Wrench& operator+=(const Wrench& arg);
double __getitem__ (int i) const;
%MethodCode
if (a0 < 0 || a0 > 5) {
PyErr_SetString(PyExc_IndexError, "Twist index out of range");
return 0;
}
sipRes=(*sipCpp)(a0);
%End
void __setitem__(int i, double value);
%MethodCode
if (a0 < 0 || a0 > 5) {
PyErr_SetString(PyExc_IndexError, "Twist index out of range");
return 0;
}
(*sipCpp)(a0)=a1;
%End
const char* __repr__() const;
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
static Wrench Zero() /Factory/;
void ReverseSign();
Wrench RefPoint(const Vector& v_base_AB) const /Factory/;
%PickleCode
const sipTypeDef *vector_type = sipFindType("Vector");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->force), vector_type, Py_None),
sipConvertFromType(&(sipCpp->torque), vector_type, Py_None));
%End
};
Wrench operator*(const Wrench& lhs,double rhs) /Factory/;
Wrench operator*(double lhs,const Wrench& rhs) /Factory/;
Wrench operator/(const Wrench& lhs,double rhs) /Factory/;
Wrench operator+(const Wrench& lhs,const Wrench& rhs) /Factory/;
Wrench operator-(const Wrench& lhs,const Wrench& rhs) /Factory/;
Wrench operator-(const Wrench& arg) /Factory/;
void SetToZero(Wrench& v);
bool Equal(const Wrench& a,const Wrench& b,double eps=epsilon);
bool operator==(const Wrench& a,const Wrench& b);
bool operator!=(const Wrench& a,const Wrench& b);
Vector diff(const Vector& a,const Vector& b,double dt=1)/Factory/;
Vector diff(const Rotation& R_a_b1,const Rotation& R_a_b2,double dt=1)/Factory/;
Twist diff(const Frame& F_a_b1,const Frame& F_a_b2,double dt=1)/Factory/;
Twist diff(const Twist& a,const Twist& b,double dt=1)/Factory/;
Wrench diff(const Wrench& W_a_p1,const Wrench& W_a_p2,double dt=1)/Factory/;
Vector addDelta(const Vector& a,const Vector&da,double dt=1)/Factory/;
Rotation addDelta(const Rotation& a,const Vector&da,double dt=1)/Factory/;
Frame addDelta(const Frame& a,const Twist& da,double dt=1)/Factory/;
Twist addDelta(const Twist& a,const Twist&da,double dt=1)/Factory/;
Wrench addDelta(const Wrench& a,const Wrench&da,double dt=1)/Factory/;
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/PyKDL.sip | //Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//
//Version: 1.0
//Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//URL: http://www.orocos.org/kdl
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
%Module(name = PyKDL,version=0)
%License(type="LGPL",licensee="Ruben Smits",signature="ruben@intermodalics.eu",timestamp="2014")
%Include std_string.sip
%Include frames.sip
%Include kinfam.sip
%Include framevel.sip
%Include dynamics.sip
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/framevel.sip | //Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//
//Version: 1.0
//Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//URL: http://www.orocos.org/kdl
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class doubleVel
{
%TypeHeaderCode
#include <kdl/framevel.hpp>
using namespace KDL;
%End
public:
typedef Rall1d<double> doubleVel;
double t;
double grad;
};
doubleVel diff(const doubleVel& a,const doubleVel& b,double dt=1.0);
doubleVel addDelta(const doubleVel& a,const doubleVel&da,double dt=1.0);
bool Equal(const doubleVel& r1,const doubleVel& r2,double eps=epsilon);
//bool Equal(const double& r1,const doubleVel& r2,double eps=epsilon);
//bool Equal(const doubleVel& r1,const double& r2,double eps=epsilon);
class VectorVel
{
%TypeHeaderCode
#include <kdl/framevel.hpp>
using namespace KDL;
%End
public:
Vector p;
Vector v;
VectorVel();
VectorVel(const Vector& _p,const Vector& _v);
VectorVel(const Vector& _p);
Vector value() const;
Vector deriv() const;
VectorVel& operator += (const VectorVel& arg);
VectorVel& operator -= (const VectorVel& arg);
static VectorVel Zero();
void ReverseSign();
doubleVel Norm() const;
%PickleCode
const sipTypeDef *vector_type = sipFindType("Vector");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->p), vector_type, Py_None),
sipConvertFromType(&(sipCpp->v), vector_type, Py_None));
%End
};
VectorVel operator + (const VectorVel& r1,const VectorVel& r2);
VectorVel operator - (const VectorVel& r1,const VectorVel& r2);
VectorVel operator + (const Vector& r1,const VectorVel& r2);
VectorVel operator - (const Vector& r1,const VectorVel& r2);
VectorVel operator + (const VectorVel& r1,const Vector& r2);
VectorVel operator - (const VectorVel& r1,const Vector& r2);
VectorVel operator * (const VectorVel& r1,const VectorVel& r2);
VectorVel operator * (const VectorVel& r1,const Vector& r2);
VectorVel operator * (const Vector& r1,const VectorVel& r2);
VectorVel operator * (const VectorVel& r1,double r2);
VectorVel operator * (double r1,const VectorVel& r2);
VectorVel operator * (const doubleVel& r1,const VectorVel& r2);
VectorVel operator * (const VectorVel& r2,const doubleVel& r1);
VectorVel operator*(const Rotation& R,const VectorVel& x);
VectorVel operator / (const VectorVel& r1,double r2);
VectorVel operator / (const VectorVel& r2,const doubleVel& r1);
bool Equal(const VectorVel& r1,const VectorVel& r2,double eps=epsilon);
bool Equal(const Vector& r1,const VectorVel& r2,double eps=epsilon);
bool Equal(const VectorVel& r1,const Vector& r2,double eps=epsilon);
VectorVel operator - (const VectorVel& r);
doubleVel dot(const VectorVel& lhs,const VectorVel& rhs);
doubleVel dot(const VectorVel& lhs,const Vector& rhs);
doubleVel dot(const Vector& lhs,const VectorVel& rhs);
class RotationVel
{
%TypeHeaderCode
#include <kdl/framevel.hpp>
using namespace KDL;
%End
public:
Rotation R;
Vector w;
RotationVel();
RotationVel(const Rotation& _R);
RotationVel(const Rotation& _R,const Vector& _w);
Rotation value() const;
Vector deriv() const;
VectorVel UnitX() const;
VectorVel UnitY() const;
VectorVel UnitZ() const;
static RotationVel Identity();
RotationVel Inverse() const;
VectorVel Inverse(const VectorVel& arg) const;
VectorVel Inverse(const Vector& arg) const;
VectorVel operator*(const VectorVel& arg) const;
VectorVel operator*(const Vector& arg) const;
void DoRotX(const doubleVel& angle);
void DoRotY(const doubleVel& angle);
void DoRotZ(const doubleVel& angle);
static RotationVel RotX(const doubleVel& angle);
static RotationVel RotY(const doubleVel& angle);
static RotationVel RotZ(const doubleVel& angle);
static RotationVel Rot(const Vector& rotvec,const doubleVel& angle);
static RotationVel Rot2(const Vector& rotvec,const doubleVel& angle);
TwistVel Inverse(const TwistVel& arg) const;
TwistVel Inverse(const Twist& arg) const;
TwistVel operator * (const TwistVel& arg) const;
TwistVel operator * (const Twist& arg) const;
%PickleCode
const sipTypeDef *vector_type = sipFindType("Vector");
const sipTypeDef *rotation_type = sipFindType("Rotation");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->R), rotation_type, Py_None),
sipConvertFromType(&(sipCpp->w), vector_type, Py_None));
%End
};
RotationVel operator* (const RotationVel& r1,const RotationVel& r2);
RotationVel operator* (const Rotation& r1,const RotationVel& r2);
RotationVel operator* (const RotationVel& r1,const Rotation& r2);
bool Equal(const RotationVel& r1,const RotationVel& r2,double eps=epsilon);
bool Equal(const Rotation& r1,const RotationVel& r2,double eps=epsilon);
bool Equal(const RotationVel& r1,const Rotation& r2,double eps=epsilon);
class FrameVel
{
%TypeHeaderCode
#include <kdl/framevel.hpp>
using namespace KDL;
%End
public:
RotationVel M;
VectorVel p;
FrameVel();
FrameVel(const Frame& _T);
FrameVel(const Frame& _T,const Twist& _t);
FrameVel(const RotationVel& _M,const VectorVel& _p);
Frame value() const;
Twist deriv() const;
static FrameVel Identity();
FrameVel Inverse() const;
VectorVel Inverse(const VectorVel& arg) const;
VectorVel operator*(const VectorVel& arg) const;
VectorVel operator*(const Vector& arg) const;
VectorVel Inverse(const Vector& arg) const;
Frame GetFrame() const;
Twist GetTwist() const;
TwistVel Inverse(const TwistVel& arg) const;
TwistVel Inverse(const Twist& arg) const;
TwistVel operator * (const TwistVel& arg) const;
TwistVel operator * (const Twist& arg) const;
%PickleCode
const sipTypeDef *vectorvel_type = sipFindType("VectorVel");
const sipTypeDef *rotationvel_type = sipFindType("RotationVel");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->M), rotationvel_type, Py_None),
sipConvertFromType(&(sipCpp->p), vectorvel_type, Py_None));
%End
};
FrameVel operator * (const FrameVel& f1,const FrameVel& f2);
FrameVel operator * (const Frame& f1,const FrameVel& f2);
FrameVel operator * (const FrameVel& f1,const Frame& f2);
bool Equal(const FrameVel& r1,const FrameVel& r2,double eps=epsilon);
bool Equal(const Frame& r1,const FrameVel& r2,double eps=epsilon);
bool Equal(const FrameVel& r1,const Frame& r2,double eps=epsilon);
class TwistVel
{
%TypeHeaderCode
#include <kdl/framevel.hpp>
using namespace KDL;
%End
public:
VectorVel vel;
VectorVel rot;
TwistVel();
TwistVel(const VectorVel& _vel,const VectorVel& _rot);
TwistVel(const Twist& p,const Twist& v);
TwistVel(const Twist& p);
Twist value() const;
Twist deriv() const;
TwistVel& operator-=(const TwistVel& arg);
TwistVel& operator+=(const TwistVel& arg);
static TwistVel Zero();
void ReverseSign();
TwistVel RefPoint(const VectorVel& v_base_AB);
Twist GetTwist() const;
Twist GetTwistDot() const;
%PickleCode
const sipTypeDef *vectorvel_type = sipFindType("VectorVel");
sipRes = Py_BuildValue("OO", sipConvertFromType(&(sipCpp->vel), vectorvel_type, Py_None),
sipConvertFromType(&(sipCpp->rot), vectorvel_type, Py_None));
%End
};
TwistVel operator*(const TwistVel& lhs,double rhs);
TwistVel operator*(double lhs,const TwistVel& rhs);
TwistVel operator/(const TwistVel& lhs,double rhs);
TwistVel operator*(const TwistVel& lhs,const doubleVel& rhs);
TwistVel operator*(const doubleVel& lhs,const TwistVel& rhs);
TwistVel operator/(const TwistVel& lhs,const doubleVel& rhs);
TwistVel operator+(const TwistVel& lhs,const TwistVel& rhs);
TwistVel operator-(const TwistVel& lhs,const TwistVel& rhs);
TwistVel operator-(const TwistVel& arg);
void SetToZero(TwistVel& v);
bool Equal(const TwistVel& a,const TwistVel& b,double eps=epsilon);
bool Equal(const Twist& a,const TwistVel& b,double eps=epsilon);
bool Equal(const TwistVel& a,const Twist& b,double eps=epsilon);
VectorVel diff(const VectorVel& a,const VectorVel& b,double dt=1.0);
VectorVel addDelta(const VectorVel& a,const VectorVel&da,double dt=1.0);
VectorVel diff(const RotationVel& a,const RotationVel& b,double dt = 1.0);
RotationVel addDelta(const RotationVel& a,const VectorVel&da,double dt=1.0);
TwistVel diff(const FrameVel& a,const FrameVel& b,double dt=1.0);
FrameVel addDelta(const FrameVel& a,const TwistVel& da,double dt=1.0);
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/kinfam.sip | //Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//
//Version: 1.0
//Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//URL: http://www.orocos.org/kdl
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class Joint{
%TypeHeaderCode
#include <kdl/joint.hpp>
#include <kdl/kinfam_io.hpp>
using namespace KDL;
%End
public:
enum JointType {RotAxis,RotX,RotY,RotZ,TransAxis,TransX,TransY,TransZ,None};
Joint(std::string name, JointType type=None,double scale=1,double offset=0,
double inertia=0,double damping=0,double stiffness=0);
Joint(JointType type=None,double scale=1,double offset=0,
double inertia=0,const double damping=0,double stiffness=0);
Joint(std::string name, Vector origin, Vector axis, JointType type, double scale=1, double offset=0,
double inertia=0, double damping=0, double stiffness=0);
Joint(Vector origin, Vector axis, JointType type, double scale=1, double offset=0,
double inertia=0, double damping=0, double stiffness=0);
Joint(const Joint& in);
Frame pose(const double& q)const /Factory/ ;
Twist twist(const double& qdot)const /Factory/ ;
Vector JointAxis() const /Factory/;
Vector JointOrigin() const /Factory/;
std::string getName()const;
JointType getType() const;
std::string getTypeName() const;
const char* __repr__();
%MethodCode
std::ostringstream oss;
oss<<(*sipCpp);
std::string s(oss.str());
sipRes=s.c_str();
%End
};
class RotationalInertia
{
%TypeHeaderCode
#include <kdl/rotationalinertia.hpp>
#include <kdl/kinfam_io.hpp>
using namespace KDL;
%End
public:
RotationalInertia(double Ixx=0,double Iyy=0,double Izz=0,double Ixy=0,double Ixz=0,double Iyz=0);
static RotationalInertia Zero()/Factory/;
Vector operator*(Vector omega) const /Factory/;
};
RotationalInertia operator*(double a, const RotationalInertia& I)/Factory/;
RotationalInertia operator+(const RotationalInertia& Ia, const RotationalInertia& Ib)/Factory/;
class RigidBodyInertia
{
%TypeHeaderCode
#include <kdl/rigidbodyinertia.hpp>
#include <kdl/kinfam_io.hpp>
using namespace KDL;
%End
public:
RigidBodyInertia(double m=0, const Vector& oc=Vector::Zero(), const RotationalInertia& Ic=RotationalInertia::Zero());
static RigidBodyInertia Zero() /Factory/;
RigidBodyInertia RefPoint(const Vector& p) /Factory/;
double getMass()const /Factory/;
Vector getCOG() const /Factory/;
RotationalInertia getRotationalInertia() const /Factory/;
};
RigidBodyInertia operator*(double a,const RigidBodyInertia& I) /Factory/;
RigidBodyInertia operator+(const RigidBodyInertia& Ia,const RigidBodyInertia& Ib) /Factory/;
Wrench operator*(const RigidBodyInertia& I,const Twist& t) /Factory/;
RigidBodyInertia operator*(const Frame& T,const RigidBodyInertia& I) /Factory/;
RigidBodyInertia operator*(const Rotation& R,const RigidBodyInertia& I) /Factory/;
class Segment
{
%TypeHeaderCode
#include <kdl/segment.hpp>
#include <kdl/kinfam_io.hpp>
using namespace KDL;
%End
public:
Segment(const std::string& name, const Joint& joint=Joint(Joint::None), const Frame& f_tip=Frame::Identity(),const RigidBodyInertia& I = RigidBodyInertia::Zero());
Segment(const Joint& joint=Joint(Joint::None), const Frame& f_tip=Frame::Identity(),const RigidBodyInertia& I = RigidBodyInertia::Zero());
Segment(const Segment& in);
const char* __repr__();
%MethodCode
std::stringstream ss;
ss<<(*sipCpp);
std::string s(ss.str());
sipRes=s.c_str();
%End
const Frame& getFrameToTip()const /Factory/;
Frame pose(const double& q)const /Factory/ ;
Twist twist(const double& q,const double& qdot)const /Factory/ ;
const std::string& getName()const /Factory/;
const Joint& getJoint()const /Factory/;
const RigidBodyInertia& getInertia()const /Factory/;
void setInertia(const RigidBodyInertia& Iin);
};
class Chain
{
%TypeHeaderCode
#include <kdl/chain.hpp>
using namespace KDL;
%End
public:
Chain();
Chain(const Chain& in);
void addSegment(const Segment& segment);
void addChain(const Chain& chain);
unsigned int getNrOfJoints()const;
unsigned int getNrOfSegments()const;
const Segment& getSegment(unsigned int nr)const /Factory/;
};
class Tree {
%TypeHeaderCode
#include <kdl/tree.hpp>
using namespace KDL;
%End
public:
Tree(const std::string& root_name="root");
bool addSegment(const Segment& segment, const std::string& hook_name);
unsigned int getNrOfJoints()const;
unsigned int getNrOfSegments()const;
Chain* getChain(const std::string& chain_root, const std::string& chain_tip)const;
%MethodCode
Chain* chain = new Chain();
sipCpp->getChain(*a0, *a1, *chain);
sipRes = chain;
%End
};
class JntArray{
%TypeHeaderCode
#include <kdl/jntarray.hpp>
using namespace KDL;
%End
public:
JntArray(unsigned int size);
JntArray(const JntArray& arg);
unsigned int rows()const;
unsigned int columns()const;
void resize(unsigned int newSize);
double __getitem__ (int index);
%MethodCode
if (a0 < 0 || a0 >= (int)sipCpp->rows()) {
PyErr_SetString(PyExc_IndexError, "JntArray index out of range");
return 0;
}
sipRes=(*sipCpp)(a0);
%End
void __setitem__(int index, double value);
%MethodCode
if (a0 < 0 || a0 >= (int)sipCpp->rows()) {
PyErr_SetString(PyExc_IndexError, "JntArray index out of range");
return 0;
}
(*sipCpp)(a0)=a1;
%End
const char* __repr__();
%MethodCode
std::stringstream ss;
ss<<sipCpp->data;
std::string s(ss.str());
sipRes=s.c_str();
%End
};
void Add(const JntArray& src1,const JntArray& src2,JntArray& dest);
void Subtract(const JntArray& src1,const JntArray& src2,JntArray& dest);
void Multiply(const JntArray& src,const double& factor,JntArray& dest);
void Divide(const JntArray& src,const double& factor,JntArray& dest);
void MultiplyJacobian(const Jacobian& jac, const JntArray& src, Twist& dest);
void SetToZero(JntArray& array);
bool Equal(const JntArray& src1,const JntArray& src2,double eps=epsilon);
bool operator==(const JntArray& src1,const JntArray& src2);
//bool operator!=(const JntArray& src1,const JntArray& src2);
class JntArrayVel
{
%TypeHeaderCode
#include <kdl/jntarrayvel.hpp>
using namespace KDL;
%End
public:
JntArray q;
JntArray qdot;
JntArrayVel(unsigned int size);
JntArrayVel(const JntArray& q,const JntArray& qdot);
JntArrayVel(const JntArray& q);
void resize(unsigned int newSize);
JntArray value()const /Factory/;
JntArray deriv()const /Factory/;
};
void Add(const JntArrayVel& src1,const JntArrayVel& src2,JntArrayVel& dest);
void Add(const JntArrayVel& src1,const JntArray& src2,JntArrayVel& dest);
void Subtract(const JntArrayVel& src1,const JntArrayVel& src2,JntArrayVel& dest);
void Subtract(const JntArrayVel& src1,const JntArray& src2,JntArrayVel& dest);
void Multiply(const JntArrayVel& src,const double& factor,JntArrayVel& dest);
void Multiply(const JntArrayVel& src,const doubleVel& factor,JntArrayVel& dest);
void Divide(const JntArrayVel& src,const double& factor,JntArrayVel& dest);
void Divide(const JntArrayVel& src,const doubleVel& factor,JntArrayVel& dest);
void SetToZero(JntArrayVel& array);
bool Equal(const JntArrayVel& src1,const JntArrayVel& src2,double eps=epsilon);
class Jacobian
{
%TypeHeaderCode
#include <kdl/jntarray.hpp>
using namespace KDL;
%End
public:
Jacobian(unsigned int size);
Jacobian(const Jacobian& arg);
unsigned int rows()const;
unsigned int columns()const;
void resize(unsigned int newNrOfColumns);
double __getitem__ (SIP_PYTUPLE);
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > 5 || j >= (int)sipCpp->columns()) {
PyErr_SetString(PyExc_IndexError, "Jacobian index out of range");
return 0;
}
sipRes=(*sipCpp)(i,j);
%End
void __setitem__(SIP_PYTUPLE,double value);
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > 5 || j >= (int)sipCpp->columns()) {
PyErr_SetString(PyExc_IndexError, "Jacobian index out of range");
return 0;
}
(*sipCpp)(i,j)=a1;
%End
const char* __repr__();
%MethodCode
std::stringstream ss;
ss<<sipCpp->data;
std::string s(ss.str());
sipRes=s.c_str();
%End
Twist getColumn(unsigned int i) const /Factory/;
void setColumn(unsigned int i,const Twist& t);
void changeRefPoint(const Vector& base_AB);
void changeBase(const Rotation& rot);
void changeRefFrame(const Frame& frame);
};
void SetToZero(Jacobian& jac);
void changeRefPoint(const Jacobian& src1, const Vector& base_AB, Jacobian& dest);
void changeBase(const Jacobian& src1, const Rotation& rot, Jacobian& dest);
void changeRefFrame(const Jacobian& src1,const Frame& frame, Jacobian& dest);
class ChainFkSolverPos
{
%TypeHeaderCode
#include <kdl/chainfksolver.hpp>
using namespace KDL;
%End
virtual int JntToCart(const JntArray& q_in, Frame& p_out,int segmentNr=-1)=0;
};
class ChainFkSolverVel
{
%TypeHeaderCode
#include <kdl/chainfksolver.hpp>
using namespace KDL;
%End
virtual int JntToCart(const JntArrayVel& q_in, FrameVel& p_out,int
segmentNr=-1)=0;
};
class ChainFkSolverPos_recursive : ChainFkSolverPos
{
%TypeHeaderCode
#include <kdl/chainfksolverpos_recursive.hpp>
using namespace KDL;
%End
public:
ChainFkSolverPos_recursive(const Chain& chain);
virtual int JntToCart(const JntArray& q_in, Frame& p_out,int segmentNr=-1);
};
class ChainFkSolverVel_recursive : ChainFkSolverVel
{
%TypeHeaderCode
#include <kdl/chainfksolvervel_recursive.hpp>
using namespace KDL;
%End
public:
ChainFkSolverVel_recursive(const Chain& chain);
virtual int JntToCart(const JntArrayVel& q_in ,FrameVel& out,int
segmentNr=-1 );
};
class ChainIkSolverPos {
%TypeHeaderCode
#include <kdl/chainiksolver.hpp>
using namespace KDL;
%End
public:
virtual int CartToJnt(const JntArray& q_init , const Frame& p_in, JntArray& q_out )=0;
};
class ChainIkSolverVel {
%TypeHeaderCode
#include <kdl/chainiksolver.hpp>
using namespace KDL;
%End
public:
virtual int CartToJnt(const JntArray& q_in , const Twist& v_in , JntArray& qdot_out )=0;
virtual int CartToJnt(const JntArray& q_init , const FrameVel& v_in , JntArrayVel& q_out )=0;
};
class ChainIkSolverPos_NR : ChainIkSolverPos
{
%TypeHeaderCode
#include <kdl/chainiksolverpos_nr.hpp>
using namespace KDL;
%End
public:
ChainIkSolverPos_NR(const Chain& chain,ChainFkSolverPos& fksolver,ChainIkSolverVel& iksolver,
unsigned int maxiter=100,double eps=epsilon);
virtual int CartToJnt(const JntArray& q_init , const Frame& p_in ,JntArray& q_out);
};
class ChainIkSolverPos_NR_JL : ChainIkSolverPos
{
%TypeHeaderCode
#include <kdl/chainiksolverpos_nr_jl.hpp>
using namespace KDL;
%End
public:
ChainIkSolverPos_NR_JL(const Chain& chain,const JntArray &q_min,const JntArray &q_max,
ChainFkSolverPos& fksolver,ChainIkSolverVel& iksolver,
unsigned int maxiter=100,double eps=epsilon);
virtual int CartToJnt(const JntArray& q_init , const Frame& p_in ,JntArray& q_out);
};
class ChainIkSolverVel_pinv : ChainIkSolverVel
{
%TypeHeaderCode
#include <kdl/chainiksolvervel_pinv.hpp>
using namespace KDL;
%End
public:
ChainIkSolverVel_pinv(const Chain& chain,double eps=0.00001,int maxiter=150);
virtual int CartToJnt(const JntArray& q_in, const Twist& v_in, JntArray& qdot_out);
};
class ChainIkSolverVel_wdls : ChainIkSolverVel
{
%TypeHeaderCode
#include <kdl/chainiksolvervel_wdls.hpp>
using namespace KDL;
%End
public:
ChainIkSolverVel_wdls(const Chain& chain,double eps=0.00001,int maxiter=150);
virtual int CartToJnt(const JntArray& q_in, const Twist& v_in, JntArray& qdot_out);
void setWeightTS(SIP_PYLIST);
%MethodCode
//void setWeightTS(const Eigen::MatrixXd& Mx);
//Mx has to be a 6x6 Matrix
Py_ssize_t numRows,numCols;
double c_item;
PyObject *list=a0;
numRows=PyList_Size(list);
PyObject *temp1;
temp1=PyList_GetItem(list,0);
numCols=PyList_Size(temp1);
if (numRows!=numCols) {
sipIsErr=1; //todo: raise exception
}
if (numRows!=6) {
sipIsErr=1; //todo: raise exception
}
Eigen::MatrixXd Mx;
Mx=Eigen::MatrixXd::Identity(numRows,numCols);
for (Py_ssize_t r=0;r<numRows;r++) {
PyObject *row;
row=PyList_GetItem(list,r);
if (numCols!=PyList_Size(row)) {
sipIsErr=1; //todo: raise exception
}
for (Py_ssize_t c=0;c<numCols;c++) {
PyObject *item;
item=PyList_GetItem(row,c);
c_item=PyFloat_AsDouble(item);
Mx(r,c)= c_item;
}
}
sipCpp->setWeightTS(Mx);
%End
void setWeightJS(SIP_PYLIST);
%MethodCode
//void setWeightJS(const Eigen::MatrixXd& Mx);
//Mx has to be a simetric positive definite Matrix
//unsigned int nOfJoints=sipCpp->chain.getNrOfJoints(); //To check that we are receiving valid data dimensions. This doesn't work, chain is a private member. todo: How can we check for this?
Py_ssize_t numRows,numCols;
double c_item;
PyObject *list=a0;
numRows=PyList_Size(list);
PyObject *temp1;
temp1=PyList_GetItem(list,0);
numCols=PyList_Size(temp1);
if (numRows!=numCols) {
sipIsErr=1; //todo: raise exception
}
Eigen::MatrixXd Mq;
Mq=Eigen::MatrixXd::Identity(numRows,numCols);
for (Py_ssize_t r=0;r<numRows;r++) {
PyObject *row;
row=PyList_GetItem(list,r);
if (numCols!=PyList_Size(row)) {
sipIsErr=1; //todo: raise exception
}
for (Py_ssize_t c=0;c<numCols;c++) {
PyObject *item;
item=PyList_GetItem(row,c);
c_item=PyFloat_AsDouble(item);
Mq(r,c)= c_item;
}
}
sipCpp->setWeightJS(Mq);
%End
void setLambda(const double& lambda);
};
class ChainIkSolverPos_LMA : ChainIkSolverPos
{
%TypeHeaderCode
#include <kdl/chainiksolverpos_lma.hpp>
using namespace KDL;
%End
public:
ChainIkSolverPos_LMA(const Chain& chain, double eps=0.00001, int _maxiter=500, double _eps_joints=0.000000000000001);
virtual int CartToJnt(const JntArray& q_init , const Frame& p_in ,JntArray& q_out);
};
class ChainIkSolverVel_pinv_nso : ChainIkSolverVel
{
%TypeHeaderCode
#include <kdl/chainiksolvervel_pinv_nso.hpp>
using namespace KDL;
%End
public:
ChainIkSolverVel_pinv_nso(const Chain& chain,double eps=0.00001,int maxiter=150, double alpha=0.25);
virtual int CartToJnt(const JntArray& q_in, const Twist& v_in, JntArray& qdot_out);
};
class ChainIkSolverVel_pinv_givens : ChainIkSolverVel
{
%TypeHeaderCode
#include <kdl/chainiksolvervel_pinv_givens.hpp>
using namespace KDL;
%End
public:
ChainIkSolverVel_pinv_givens(const Chain& chain);
virtual int CartToJnt(const JntArray& q_in, const Twist& v_in, JntArray& qdot_out);
};
class ChainJntToJacSolver
{
%TypeHeaderCode
#include <kdl/chainjnttojacsolver.hpp>
using namespace KDL;
%End
public:
ChainJntToJacSolver(const Chain& chain);
int JntToJac(const JntArray& q_in,Jacobian& jac);
};
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/dynamics.sip | //Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//
//Version: 1.0
//Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
//URL: http://www.orocos.org/kdl
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
%Include std_string.sip
class JntSpaceInertiaMatrix {
%TypeHeaderCode
#include <kdl/jntspaceinertiamatrix.hpp>
using namespace KDL;
%End
public:
JntSpaceInertiaMatrix();
JntSpaceInertiaMatrix(int size);
JntSpaceInertiaMatrix(const JntSpaceInertiaMatrix& arg);
void resize(unsigned int newSize);
unsigned int rows()const;
unsigned int columns()const;
//JntSpaceInertiaMatrix& operator = ( const JntSpaceInertiaMatrix& arg);
double __getitem__(SIP_PYTUPLE);
%MethodCode
int i,j;
PyArg_ParseTuple(a0,"ii",&i,&j);
if (i < 0 || j < 0 || i > (int)sipCpp->rows() || j >= (int)sipCpp->columns()) {
PyErr_SetString(PyExc_IndexError, "Inertia index out of range");
return NULL;
}
sipRes=(*sipCpp)(i,j);
%End
//double operator()(unsigned int i,unsigned int j)const;
//double& operator()(unsigned int i,unsigned int j);
//bool operator==(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2);
//bool operator!=(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2);
};
void Add(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2,JntSpaceInertiaMatrix& dest);
void Subtract(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2,JntSpaceInertiaMatrix& dest);
void Multiply(const JntSpaceInertiaMatrix& src,const double& factor,JntSpaceInertiaMatrix& dest);
void Divide(const JntSpaceInertiaMatrix& src,const double& factor,JntSpaceInertiaMatrix& dest);
void Multiply(const JntSpaceInertiaMatrix& src, const JntArray& vec, JntArray& dest);
void SetToZero(JntSpaceInertiaMatrix& matrix);
bool Equal(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2,double eps=epsilon);
bool operator==(const JntSpaceInertiaMatrix& src1,const JntSpaceInertiaMatrix& src2);
class ChainDynParam {
%TypeHeaderCode
#include <kdl/chaindynparam.hpp>
using namespace KDL;
%End
public:
ChainDynParam(const Chain& chain, Vector _grav);
int JntToCoriolis(const JntArray &q, const JntArray &q_dot, JntArray &coriolis);
int JntToMass(const JntArray &q, JntSpaceInertiaMatrix& H);
int JntToGravity(const JntArray &q,JntArray &gravity);
};
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/PyKDL/std_string.sip | //Copyright (C) 2005 Torsten Marek <shlomme at gmx.net>
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
%MappedType std::string
{
%TypeHeaderCode
#include <string>
%End
%ConvertFromTypeCode
// convert an std::string to a Python (unicode) string
PyObject* newstring;
newstring = PyUnicode_DecodeUTF8(sipCpp->c_str(), sipCpp->length(), NULL);
if(newstring == NULL) {
PyErr_Clear();
newstring = PyUnicode_FromString(sipCpp->c_str());
}
return newstring;
%End
%ConvertToTypeCode
// Allow a Python string (or a unicode string) whenever a string is
// expected.
// If argument is a Unicode string, just decode it to UTF-8
// If argument is a Python string, assume it's UTF-8
if (sipIsErr == NULL)
#if PY_MAJOR_VERSION < 3
return (PyString_Check(sipPy) || PyUnicode_Check(sipPy));
#else
return PyUnicode_Check(sipPy);
#endif
if (sipPy == Py_None) {
*sipCppPtr = new std::string;
return 1;
}
if (PyUnicode_Check(sipPy)) {
PyObject* s = PyUnicode_AsEncodedString(sipPy, "UTF-8", "");
*sipCppPtr = new std::string(PyUnicode_AS_DATA(s));
Py_DECREF(s);
return 1;
}
#if PY_MAJOR_VERSION < 3
if (PyString_Check(sipPy)) {
*sipCppPtr = new std::string(PyString_AS_STRING(sipPy));
return 1;
}
#endif
return 0;
%End
};
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/cmake/FindEigen3.cmake | FIND_PATH(EIGEN3_INCLUDE_DIR Eigen/Core /usr/include /usr/include/eigen3)
IF ( EIGEN3_INCLUDE_DIR )
MESSAGE(STATUS "-- Looking for Eigen3 - found")
ELSE ( EIGEN3_INCLUDE_DIR )
MESSAGE(FATAL_ERROR "-- Looking for Eigen3 - not found")
ENDIF ( EIGEN3_INCLUDE_DIR )
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/cmake/FindSIP.cmake | # Find SIP
# ~~~~~~~~
#
# SIP website: http://www.riverbankcomputing.co.uk/sip/index.php
#
# Find the installed version of SIP. FindSIP should be called after Python
# has been found.
#
# This file defines the following variables:
#
# SIP_VERSION - The version of SIP found expressed as a 6 digit hex number
# suitable for comparision as a string.
#
# SIP_VERSION_STR - The version of SIP found as a human readable string.
#
# SIP_EXECUTABLE - Path and filename of the SIP command line executable.
#
# SIP_INCLUDE_DIR - Directory holding the SIP C++ header file.
#
# SIP_DEFAULT_SIP_DIR - Default directory where .sip files should be installed
# into.
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF(SIP_VERSION)
# Already in cache, be silent
SET(SIP_FOUND TRUE)
ELSE(SIP_VERSION)
FIND_FILE(_find_sip_py FindSIP.py PATHS ${CMAKE_MODULE_PATH} NO_CMAKE_FIND_ROOT_PATH)
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
IF(sip_config)
STRING(REGEX REPLACE "^sip_version:([^\n]+).*$" "\\1" SIP_VERSION ${sip_config})
STRING(REGEX REPLACE ".*\nsip_version_str:([^\n]+).*$" "\\1" SIP_VERSION_STR ${sip_config})
IF(NOT SIP_DEFAULT_SIP_DIR)
STRING(REGEX REPLACE ".*\ndefault_sip_dir:([^\n]+).*$" "\\1" SIP_DEFAULT_SIP_DIR ${sip_config})
ENDIF(NOT SIP_DEFAULT_SIP_DIR)
IF(CMAKE_CROSSCOMPILING)
FIND_PROGRAM(SIP_EXECUTABLE sip)
STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
LIST(GET CMAKE_FIND_ROOT_PATH 0 SIP_SYSROOT)
SET(SIP_INCLUDE_DIR "${SIP_SYSROOT}${SIP_INCLUDE_DIR}")
ELSE(CMAKE_CROSSCOMPILING)
STRING(REGEX REPLACE ".*\nsip_bin:([^\n]+).*$" "\\1" SIP_EXECUTABLE ${sip_config})
STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
ENDIF(CMAKE_CROSSCOMPILING)
SET(SIP_FOUND TRUE)
ENDIF(sip_config)
IF(SIP_FOUND)
IF(NOT SIP_FIND_QUIETLY)
MESSAGE(STATUS "Found SIP version: ${SIP_VERSION_STR}")
ENDIF(NOT SIP_FIND_QUIETLY)
ELSE(SIP_FOUND)
IF(SIP_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find SIP")
ENDIF(SIP_FIND_REQUIRED)
ENDIF(SIP_FOUND)
ENDIF(SIP_VERSION)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/cmake/FindSIP.py | # FindSIP.py
#
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
import sys
import sipconfig
sipcfg = sipconfig.Configuration()
print("sip_version:%06.0x" % sipcfg.sip_version)
print("sip_version_str:%s" % sipcfg.sip_version_str)
print("sip_bin:%s" % sipcfg.sip_bin)
print("default_sip_dir:%s" % sipcfg.default_sip_dir)
print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/cmake/SIPMacros.cmake | # Macros for SIP
# ~~~~~~~~~~~~~~
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# SIP website: http://www.riverbankcomputing.co.uk/sip/index.php
#
# This file defines the following macros:
#
# ADD_SIP_PYTHON_MODULE (MODULE_NAME MODULE_SIP [library1, libaray2, ...])
# Specifies a SIP file to be built into a Python module and installed.
# MODULE_NAME is the name of Python module including any path name. (e.g.
# os.sys, Foo.bar etc). MODULE_SIP the path and filename of the .sip file
# to process and compile. libraryN are libraries that the Python module,
# which is typically a shared library, should be linked to. The built
# module will also be install into Python's site-packages directory.
#
# The behaviour of the ADD_SIP_PYTHON_MODULE macro can be controlled by a
# number of variables:
#
# SIP_INCLUDES - List of directories which SIP will scan through when looking
# for included .sip files. (Corresponds to the -I option for SIP.)
#
# SIP_TAGS - List of tags to define when running SIP. (Corresponds to the -t
# option for SIP.)
#
# SIP_CONCAT_PARTS - An integer which defines the number of parts the C++ code
# of each module should be split into. Defaults to 8. (Corresponds to the
# -j option for SIP.)
#
# SIP_DISABLE_FEATURES - List of feature names which should be disabled
# running SIP. (Corresponds to the -x option for SIP.)
#
# SIP_EXTRA_OPTIONS - Extra command line options which should be passed on to
# SIP.
SET(SIP_INCLUDES)
SET(SIP_TAGS)
SET(SIP_CONCAT_PARTS 8)
SET(SIP_DISABLE_FEATURES)
SET(SIP_EXTRA_OPTIONS)
MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
SET(EXTRA_LINK_LIBRARIES ${ARGN})
STRING(REPLACE "." "/" _x ${MODULE_NAME})
GET_FILENAME_COMPONENT(_parent_module_path ${_x} PATH)
GET_FILENAME_COMPONENT(_child_module_name ${_x} NAME)
GET_FILENAME_COMPONENT(_module_path ${MODULE_SIP} PATH)
if(_module_path STREQUAL "")
set(CMAKE_CURRENT_SIP_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
else(_module_path STREQUAL "")
set(CMAKE_CURRENT_SIP_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_module_path}")
endif(_module_path STREQUAL "")
GET_FILENAME_COMPONENT(_abs_module_sip ${MODULE_SIP} ABSOLUTE)
# We give this target a long logical target name.
# (This is to avoid having the library name clash with any already
# install library names. If that happens then cmake dependancy
# tracking get confused.)
STRING(REPLACE "." "_" _logical_name ${MODULE_NAME})
SET(_logical_name "python_module_${_logical_name}")
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_SIP_OUTPUT_DIR}) # Output goes in this dir.
SET(_sip_includes)
FOREACH (_inc ${SIP_INCLUDES})
GET_FILENAME_COMPONENT(_abs_inc ${_inc} ABSOLUTE)
LIST(APPEND _sip_includes -I ${_abs_inc})
ENDFOREACH (_inc )
SET(_sip_tags)
FOREACH (_tag ${SIP_TAGS})
LIST(APPEND _sip_tags -t ${_tag})
ENDFOREACH (_tag)
SET(_sip_x)
FOREACH (_x ${SIP_DISABLE_FEATURES})
LIST(APPEND _sip_x -x ${_x})
ENDFOREACH (_x ${SIP_DISABLE_FEATURES})
SET(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
SET(_sip_output_files)
FOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
IF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
SET(_sip_output_files ${_sip_output_files} ${CMAKE_CURRENT_SIP_OUTPUT_DIR}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
IF(NOT WIN32)
SET(TOUCH_COMMAND touch)
ELSE(NOT WIN32)
SET(TOUCH_COMMAND echo)
# instead of a touch command, give out the name and append to the files
# this is basically what the touch command does.
FOREACH(filename ${_sip_output_files})
FILE(APPEND filename "")
ENDFOREACH(filename ${_sip_output_files})
ENDIF(NOT WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_SIP_OUTPUT_DIR} ${_sip_includes} ${_abs_module_sip}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
IF (CYGWIN OR APPLE)
ADD_LIBRARY(${_logical_name} MODULE ${_sip_output_files} )
ELSE (CYGWIN OR APPLE)
ADD_LIBRARY(${_logical_name} SHARED ${_sip_output_files} )
ENDIF (CYGWIN OR APPLE)
TARGET_LINK_LIBRARIES(${_logical_name} ${PYTHON_LIBRARY})
TARGET_LINK_LIBRARIES(${_logical_name} ${EXTRA_LINK_LIBRARIES})
SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES PREFIX "" OUTPUT_NAME ${_child_module_name})
INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_INSTALL_DIR}/${_parent_module_path}")
ENDMACRO(ADD_SIP_PYTHON_MODULE)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/tests/framestest.py | # Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Version: 1.0
# Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# URL: http://www.orocos.org/kdl
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
from PyKDL import *
from math import *
class FramesTestFunctions(unittest.TestCase):
def testVector2(self,v):
self.assertEqual(2*v-v,v)
self.assertEqual(v*2-v,v)
self.assertEqual(v+v+v-2*v,v)
v2=Vector(v)
self.assertEqual(v,v2)
v2+=v
self.assertEqual(2*v,v2)
v2-=v
self.assertEqual(v,v2)
v2.ReverseSign()
self.assertEqual(v,-v2)
def testVector(self):
v=Vector(3,4,5)
self.testVector2(v)
v=Vector.Zero()
self.testVector2(v)
def testTwist2(self,t):
self.assertEqual(2*t-t,t)
self.assertEqual(t*2-t,t)
self.assertEqual(t+t+t-2*t,t)
t2=Twist(t)
self.assertEqual(t,t2)
t2+=t
self.assertEqual(2*t,t2)
t2-=t
self.assertEqual(t,t2)
t.ReverseSign()
self.assertEqual(t,-t2)
def testTwist(self):
t=Twist(Vector(6,3,5),Vector(4,-2,7))
self.testTwist2(t)
t=Twist.Zero()
self.testTwist2(t)
t=Twist(Vector(0,-9,-3),Vector(1,-2,-4))
def testWrench2(self,w):
self.assertEqual(2*w-w,w)
self.assertEqual(w*2-w,w)
self.assertEqual(w+w+w-2*w,w)
w2=Wrench(w)
self.assertEqual(w,w2)
w2+=w
self.assertEqual(2*w,w2)
w2-=w
self.assertEqual(w,w2)
w.ReverseSign()
self.assertEqual(w,-w2)
def testWrench(self):
w=Wrench(Vector(7,-1,3),Vector(2,-3,3))
self.testWrench2(w)
w=Wrench.Zero()
self.testWrench2(w)
w=Wrench(Vector(2,1,4),Vector(5,3,1))
self.testWrench2(w)
def testRotation2(self,v,a,b,c):
w=Wrench(Vector(7,-1,3),Vector(2,-3,3))
t=Twist(Vector(6,3,5),Vector(4,-2,7))
R=Rotation.RPY(a,b,c)
self.assertAlmostEqual(dot(R.UnitX(),R.UnitX()),1.0,15)
self.assertEqual(dot(R.UnitY(),R.UnitY()),1.0)
self.assertEqual(dot(R.UnitZ(),R.UnitZ()),1.0)
self.assertAlmostEqual(dot(R.UnitX(),R.UnitY()),0.0,15)
self.assertAlmostEqual(dot(R.UnitX(),R.UnitZ()),0.0,15)
self.assertEqual(dot(R.UnitY(),R.UnitZ()),0.0)
R2=Rotation(R)
self.assertEqual(R,R2)
self.assertAlmostEqual((R*v).Norm(),v.Norm(),14)
self.assertEqual(R.Inverse(R*v),v)
self.assertEqual(R.Inverse(R*t),t)
self.assertEqual(R.Inverse(R*w),w)
self.assertEqual(R*R.Inverse(v),v)
self.assertEqual(R*Rotation.Identity(),R)
self.assertEqual(Rotation.Identity()*R,R)
self.assertEqual(R*(R*(R*v)),(R*R*R)*v)
self.assertEqual(R*(R*(R*t)),(R*R*R)*t)
self.assertEqual(R*(R*(R*w)),(R*R*R)*w)
self.assertEqual(R*R.Inverse(),Rotation.Identity())
self.assertEqual(R.Inverse()*R,Rotation.Identity())
self.assertEqual(R.Inverse()*v,R.Inverse(v))
(ra,rb,rc)=R.GetRPY()
self.assertEqual(ra,a)
self.assertEqual(rb,b)
self.assertEqual(rc,c)
R = Rotation.EulerZYX(a,b,c)
(ra,rb,rc)=R.GetEulerZYX()
self.assertEqual(ra,a)
self.assertEqual(rb,b)
self.assertEqual(rc,c)
R = Rotation.EulerZYZ(a,b,c)
(ra,rb,rc)=R.GetEulerZYZ()
self.assertEqual(ra,a)
self.assertEqual(rb,b)
self.assertAlmostEqual(rc,c,15)
(angle,v2)= R.GetRotAngle()
R2=Rotation.Rot(v2,angle)
self.assertEqual(R2,R)
R2=Rotation.Rot(v2*1E20,angle)
self.assertEqual(R,R2)
v2=Vector(6,2,4)
self.assertAlmostEqual(v2.Norm(),sqrt(dot(v2,v2)),14)
def testRotation(self):
self.testRotation2(Vector(3,4,5),radians(10),radians(20),radians(30))
def testFrame(self):
v=Vector(3,4,5)
w=Wrench(Vector(7,-1,3),Vector(2,-3,3))
t=Twist(Vector(6,3,5),Vector(4,-2,7))
F = Frame(Rotation.EulerZYX(radians(10),radians(20),radians(-10)),Vector(4,-2,1))
F2=Frame(F)
self.assertEqual(F,F2)
self.assertEqual(F.Inverse(F*v),v)
self.assertEqual(F.Inverse(F*t),t)
self.assertEqual(F.Inverse(F*w),w)
self.assertEqual(F*F.Inverse(v),v)
self.assertEqual(F*F.Inverse(t),t)
self.assertEqual(F*F.Inverse(w),w)
self.assertEqual(F*Frame.Identity(),F)
self.assertEqual(Frame.Identity()*F,F)
self.assertEqual(F*(F*(F*v)),(F*F*F)*v)
self.assertEqual(F*(F*(F*t)),(F*F*F)*t)
self.assertEqual(F*(F*(F*w)),(F*F*F)*w)
self.assertEqual(F*F.Inverse(),Frame.Identity())
self.assertEqual(F.Inverse()*F,Frame.Identity())
self.assertEqual(F.Inverse()*v,F.Inverse(v))
def testPickle(self):
import pickle
data = {}
data['v'] = Vector(1,2,3)
data['rot'] = Rotation.RotX(1.3)
data['fr'] = Frame(data['rot'], data['v'])
data['tw'] = Twist(data['v'], Vector(4,5,6))
data['wr'] = Wrench(Vector(0.1,0.2,0.3), data['v'])
f = open('/tmp/pickle_test', 'w')
pickle.dump(data, f)
f.close()
f = open('/tmp/pickle_test', 'r')
data1 = pickle.load(f)
f.close()
self.assertEqual(data, data1)
def suite():
suite=unittest.TestSuite()
suite.addTest(FramesTestFunctions('testVector'))
suite.addTest(FramesTestFunctions('testTwist'))
suite.addTest(FramesTestFunctions('testWrench'))
suite.addTest(FramesTestFunctions('testRotation'))
suite.addTest(FramesTestFunctions('testFrame'))
suite.addTest(FramesTestFunctions('testPickle'))
return suite
#suite = suite()
#unittest.TextTestRunner(verbosity=3).run(suite)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/tests/frameveltest.py | import unittest
from PyKDL import *
from math import *
class FrameVelTestFunctions(unittest.TestCase):
def testVectorVel(self):
v=VectorVel(Vector(3,-4,5),Vector(6,3,-5))
vt = Vector(-4,-6,-8);
self.assert_(Equal( 2*v-v,v))
self.assert_(Equal( v*2-v,v))
self.assert_(Equal( v+v+v-2*v,v))
v2=VectorVel(v)
self.assert_(Equal( v,v2))
v2+=v
self.assert_(Equal( 2*v,v2))
v2-=v
self.assert_(Equal( v,v2))
v2.ReverseSign()
self.assert_(Equal( v,-v2))
self.assert_(Equal( v*vt,-vt*v))
v2 = VectorVel(Vector(-5,-6,-3),Vector(3,4,5))
self.assert_(Equal( v*v2,-v2*v))
def testRotationVel(self):
v=VectorVel(Vector(9,4,-2),Vector(-5,6,-2))
vt=Vector(2,3,4)
a= radians(-15)
b= radians(20)
c= radians(-80)
R = RotationVel(Rotation.RPY(a,b,c),Vector(2,4,1))
R2=RotationVel(R)
self.assert_(Equal(R,R2))
self.assert_(Equal((R*v).Norm(),(v.Norm())))
self.assert_(Equal(R.Inverse(R*v),v))
self.assert_(Equal(R*R.Inverse(v),v))
self.assert_(Equal(R*Rotation.Identity(),R))
self.assert_(Equal(Rotation.Identity()*R,R))
self.assert_(Equal(R*(R*(R*v)),(R*R*R)*v))
self.assert_(Equal(R*(R*(R*vt)),(R*R*R)*vt))
self.assert_(Equal(R*R.Inverse(),RotationVel.Identity()))
self.assert_(Equal(R.Inverse()*R,RotationVel.Identity()))
self.assert_(Equal(R.Inverse()*v,R.Inverse(v)))
#v2=v*v-2*v
#print dot(v2,v2)
#self.assert_(Equal((v2).Norm(),sqrt(dot(v2,v2))))
def testFrameVel(self):
v=VectorVel(Vector(3,4,5),Vector(-2,-4,-1))
vt=Vector(-1,0,-10)
F = FrameVel(Frame(Rotation.EulerZYX(radians(10),radians(20),radians(-10)),Vector(4,-2,1)),
Twist(Vector(2,-2,-2),Vector(-5,-3,-2)))
F2=FrameVel(F)
self.assert_(Equal( F,F2))
self.assert_(Equal( F.Inverse(F*v),v))
self.assert_(Equal( F.Inverse(F*vt), vt))
self.assert_(Equal( F*F.Inverse(v),v))
self.assert_(Equal( F*F.Inverse(vt),vt))
self.assert_(Equal( F*Frame.Identity(),F))
self.assert_(Equal( Frame.Identity()*F,F))
self.assert_(Equal( F*(F*(F*v)),(F*F*F)*v))
self.assert_(Equal( F*(F*(F*vt)),(F*F*F)*vt))
self.assert_(Equal( F*F.Inverse(),FrameVel.Identity()))
self.assert_(Equal( F.Inverse()*F,Frame.Identity()))
self.assert_(Equal( F.Inverse()*vt,F.Inverse(vt)))
def testPickle(self):
rot = Rotation.RotX(1.3)
import pickle
data = {}
data['vv'] = VectorVel(Vector(1,2,3), Vector(4,5,6))
data['rv'] = RotationVel(rot, Vector(4.1,5.1,6.1))
data['fv'] = FrameVel(data['rv'], data['vv'])
data['tv'] = TwistVel(data['vv'], data['vv'])
f = open('/tmp/pickle_test_kdl_framevel', 'w')
pickle.dump(data, f)
f.close()
f = open('/tmp/pickle_test_kdl_framevel', 'r')
data1 = pickle.load(f)
f.close()
self.assertEqual(data['vv'].p, data1['vv'].p)
self.assertEqual(data['vv'].v, data1['vv'].v)
self.assertEqual(data['rv'].R, data1['rv'].R)
self.assertEqual(data['rv'].w, data1['rv'].w)
self.assertEqual(data['fv'].M.R, data1['fv'].M.R)
self.assertEqual(data['fv'].M.w, data1['fv'].M.w)
self.assertEqual(data['fv'].p.p, data1['fv'].p.p)
self.assertEqual(data['fv'].p.v, data1['fv'].p.v)
self.assertEqual(data['tv'].vel.p, data1['tv'].vel.p)
self.assertEqual(data['tv'].vel.v, data1['tv'].vel.v)
self.assertEqual(data['tv'].rot.p, data1['tv'].rot.p)
self.assertEqual(data['tv'].rot.v, data1['tv'].rot.v)
#void TestTwistVel() {
# KDL_CTX;
# // Twist
# TwistVel t(VectorVel(
# Vector(6,3,5),
# Vector(1,4,2)
# ),VectorVel(
# Vector(4,-2,7),
# Vector(-1,-2,-3)
# )
# );
# TwistVel t2;
# RotationVel R(Rotation::RPY(10*deg2rad,20*deg2rad,-15*deg2rad),Vector(-1,5,3));
# FrameVel F = FrameVel(
# Frame(
# Rotation::EulerZYX(-17*deg2rad,13*deg2rad,-16*deg2rad),
# Vector(4,-2,1)
# ),
# Twist(
# Vector(2,-2,-2),
# Vector(-5,-3,-2)
# )
# );
#
# KDL_DIFF(2.0*t-t,t);
# KDL_DIFF(t*2.0-t,t);
# KDL_DIFF(t+t+t-2.0*t,t);
# t2=t;
# KDL_DIFF(t,t2);
# t2+=t;
# KDL_DIFF(2.0*t,t2);
# t2-=t;
# KDL_DIFF(t,t2);
# t.ReverseSign();
# KDL_DIFF(t,-t2);
# KDL_DIFF(R.Inverse(R*t),t);
# KDL_DIFF(R*t,R*R.Inverse(R*t));
# KDL_DIFF(F.Inverse(F*t),t);
# KDL_DIFF(F*t,F*F.Inverse(F*t));
# KDL_DIFF(doubleVel(3.14,2)*t,t*doubleVel(3.14,2));
# KDL_DIFF(t/doubleVel(3.14,2),t*(1.0/doubleVel(3.14,2)));
# KDL_DIFF(t/3.14,t*(1.0/3.14));
# KDL_DIFF(-t,-1.0*t);
# VectorVel p1(Vector(5,1,2),Vector(4,2,1)) ;
# VectorVel p2(Vector(2,0,5),Vector(-2,7,-1)) ;
# KDL_DIFF(t.RefPoint(p1+p2),t.RefPoint(p1).RefPoint(p2));
# KDL_DIFF(t,t.RefPoint(-p1).RefPoint(p1));
#}
#
#void TestTwistAcc() {
# KDL_CTX;
# // Twist
# TwistAcc t( VectorAcc(Vector(6,3,5),Vector(1,4,2),Vector(5,2,1)),
# VectorAcc(Vector(4,-2,7),Vector(-1,-2,-3),Vector(5,2,9) )
# );
# TwistAcc t2;
# RotationAcc R(Rotation::RPY(10*deg2rad,20*deg2rad,-15*deg2rad),
# Vector(-1,5,3),
# Vector(2,1,3)
# ) ;
# FrameAcc F = FrameAcc(
# Frame(Rotation::EulerZYX(-17*deg2rad,13*deg2rad,-16*deg2rad),Vector(4,-2,1)),
# Twist(Vector(2,-2,-2),Vector(-5,-3,-2)),
# Twist(Vector(5,4,-5),Vector(12,13,17))
# );
#
# KDL_DIFF(2.0*t-t,t);
# KDL_DIFF(t*2.0-t,t);
# KDL_DIFF(t+t+t-2.0*t,t);
# t2=t;
# KDL_DIFF(t,t2);
# t2+=t;
# KDL_DIFF(2.0*t,t2);
# t2-=t;
# KDL_DIFF(t,t2);
# t.ReverseSign();
# KDL_DIFF(t,-t2);
# KDL_DIFF(R.Inverse(R*t),t);
# KDL_DIFF(R*t,R*R.Inverse(R*t));
# KDL_DIFF(F.Inverse(F*t),t);
# KDL_DIFF(F*t,F*F.Inverse(F*t));
# KDL_DIFF(doubleAcc(3.14,2,3)*t,t*doubleAcc(3.14,2,3));
# KDL_DIFF(t/doubleAcc(3.14,2,7),t*(1.0/doubleAcc(3.14,2,7)));
# KDL_DIFF(t/3.14,t*(1.0/3.14));
# KDL_DIFF(-t,-1.0*t);
# VectorAcc p1(Vector(5,1,2),Vector(4,2,1),Vector(2,1,3));
# VectorAcc p2(Vector(2,0,5),Vector(-2,7,-1),Vector(-3,2,-1));
# KDL_DIFF(t.RefPoint(p1+p2),t.RefPoint(p1).RefPoint(p2));
# KDL_DIFF(t,t.RefPoint(-p1).RefPoint(p1));
#}
#
def suite():
suite=unittest.TestSuite()
suite.addTest(FrameVelTestFunctions('testVectorVel'))
suite.addTest(FrameVelTestFunctions('testRotationVel'))
suite.addTest(FrameVelTestFunctions('testFrameVel'))
suite.addTest(FrameVelTestFunctions('testPickle'))
return suite
#suite = suite()
#unittest.TextTestRunner(verbosity=5).run(suite)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/tests/PyKDLtest.py | #!/usr/bin/python
# Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Version: 1.0
# Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# URL: http://www.orocos.org/kdl
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
import kinfamtest
import framestest
import frameveltest
suite = unittest.TestSuite()
suite.addTest(framestest.suite())
suite.addTest(frameveltest.suite())
suite.addTest(kinfamtest.suite())
unittest.TextTestRunner(verbosity=3).run(suite)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/tests/kinfamtest.py | # Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Version: 1.0
# Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
# URL: http://www.orocos.org/kdl
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
from PyKDL import *
from math import *
import random
class KinfamTestFunctions(unittest.TestCase):
def setUp(self):
self.chain = Chain()
self.chain.addSegment(Segment(Joint(Joint.RotZ),
Frame(Vector(0.0,0.0,0.0))))
self.chain.addSegment(Segment(Joint(Joint.RotX),
Frame(Vector(0.0,0.0,0.9))))
self.chain.addSegment(Segment(Joint(Joint.None),
Frame(Vector(-0.4,0.0,0.0))))
self.chain.addSegment(Segment(Joint(Joint.RotY),
Frame(Vector(0.0,0.0,1.2))))
self.chain.addSegment(Segment(Joint(Joint.None),
Frame(Vector(0.4,0.0,0.0))))
self.chain.addSegment(Segment(Joint(Joint.TransZ),
Frame(Vector(0.0,0.0,1.4))))
self.chain.addSegment(Segment(Joint(Joint.TransX),
Frame(Vector(0.0,0.0,0.0))))
self.chain.addSegment(Segment(Joint(Joint.TransY),
Frame(Vector(0.0,0.0,0.4))))
self.chain.addSegment(Segment(Joint(Joint.None),
Frame(Vector(0.0,0.0,0.0))))
self.jacsolver = ChainJntToJacSolver(self.chain)
self.fksolverpos = ChainFkSolverPos_recursive(self.chain)
self.fksolvervel = ChainFkSolverVel_recursive(self.chain)
self.iksolvervel = ChainIkSolverVel_pinv(self.chain)
self.iksolverpos = ChainIkSolverPos_NR(self.chain,self.fksolverpos,self.iksolvervel)
def testFkPosAndJac(self):
deltaq = 1E-4
epsJ = 1E-4
F1=Frame()
F2=Frame()
q=JntArray(self.chain.getNrOfJoints())
jac=Jacobian(self.chain.getNrOfJoints())
for i in range(q.rows()):
q[i]=random.uniform(-3.14,3.14)
self.jacsolver.JntToJac(q,jac)
for i in range(q.rows()):
oldqi=q[i];
q[i]=oldqi+deltaq
self.assert_(0==self.fksolverpos.JntToCart(q,F2))
q[i]=oldqi-deltaq
self.assert_(0==self.fksolverpos.JntToCart(q,F1))
q[i]=oldqi
Jcol1 = diff(F1,F2,2*deltaq)
Jcol2 = Twist(Vector(jac[0,i],jac[1,i],jac[2,i]),
Vector(jac[3,i],jac[4,i],jac[5,i]))
self.assertEqual(Jcol1,Jcol2);
def testFkVelAndJac(self):
deltaq = 1E-4
epsJ = 1E-4
q=JntArray(self.chain.getNrOfJoints())
qdot=JntArray(self.chain.getNrOfJoints())
for i in range(q.rows()):
q[i]=random.uniform(-3.14,3.14)
qdot[i]=random.uniform(-3.14,3.14)
qvel=JntArrayVel(q,qdot);
jac=Jacobian(self.chain.getNrOfJoints())
cart = FrameVel.Identity();
t = Twist.Zero();
self.jacsolver.JntToJac(qvel.q,jac)
self.assert_(self.fksolvervel.JntToCart(qvel,cart)==0)
MultiplyJacobian(jac,qvel.qdot,t)
self.assertEqual(cart.deriv(),t)
def testFkVelAndIkVel(self):
epsJ = 1E-7
q=JntArray(self.chain.getNrOfJoints())
qdot=JntArray(self.chain.getNrOfJoints())
for i in range(q.rows()):
q[i]=random.uniform(-3.14,3.14)
qdot[i]=random.uniform(-3.14,3.14)
qvel=JntArrayVel(q,qdot)
qdot_solved=JntArray(self.chain.getNrOfJoints())
cart = FrameVel()
self.assert_(0==self.fksolvervel.JntToCart(qvel,cart))
self.assert_(0==self.iksolvervel.CartToJnt(qvel.q,cart.deriv(),qdot_solved))
self.assertEqual(qvel.qdot,qdot_solved);
def testFkPosAndIkPos(self):
q=JntArray(self.chain.getNrOfJoints())
for i in range(q.rows()):
q[i]=random.uniform(-3.14,3.14)
q_init=JntArray(self.chain.getNrOfJoints())
for i in range(q_init.rows()):
q_init[i]=q[i]+0.1*random.random()
q_solved=JntArray(q.rows())
F1=Frame.Identity()
F2=Frame.Identity()
self.assert_(0==self.fksolverpos.JntToCart(q,F1))
self.assert_(0==self.iksolverpos.CartToJnt(q_init,F1,q_solved))
self.assert_(0==self.fksolverpos.JntToCart(q_solved,F2))
self.assertEqual(F1,F2)
self.assertEqual(q,q_solved)
def suite():
suite = unittest.TestSuite()
suite.addTest(KinfamTestFunctions('testFkPosAndJac'))
suite.addTest(KinfamTestFunctions('testFkVelAndJac'))
suite.addTest(KinfamTestFunctions('testFkVelAndIkVel'))
suite.addTest(KinfamTestFunctions('testFkPosAndIkPos'))
return suite
#suite = suite()
#unittest.TextTestRunner(verbosity=3).run(suite)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/doc/index.rst | .. Orocos KDL python bindings documentation master file, created by
sphinx-quickstart on Tue Mar 20 11:46:06 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Orocos KDL python bindings's documentation!
======================================================
Overview of all available classes and functions for the Orocos KDL
python bindings. This documentation is autogenerated and only shows
the API of all functions. Please refer to
http:://www.orocos.org/kdl/user-manual or
http://people.mech.kuleuven.be/~rsmits/kdl/api/html/ for more documentation.
.. toctree::
:maxdepth: 0
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. automodule:: PyKDL
:members:
:undoc-members:
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/python_orocos_kdl/doc/conf.py | # -*- coding: utf-8 -*-
#
# Orocos KDL python bindings documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 20 11:46:06 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import roslib
roslib.load_manifest('python_orocos_kdl')
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Orocos KDL python bindings'
copyright = u'2012, Ruben Smits'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.2.3'
# The full version, including alpha/beta/rc tags.
release = '0.2.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
#exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'OrocosKDLpythonbindingsdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'OrocosKDLpythonbindings.tex', u'Orocos KDL python bindings Documentation',
u'Ruben Smits', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'orocoskdlpythonbindings', u'Orocos KDL python bindings Documentation',
[u'Ruben Smits'], 1)
]
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/INSTALL | 1. create a new build-directory
(it is always better not to build in the
src)
mkdir <builddir>
2. cd <builddir>
3. ccmake ..
4. adapt CMAKE_INSTALL_PREFIX to desired installation directory
5. If you want to build the tests: enable BUILD_TESTS
6. If you want to build the python bindings: enable PYTHON_BINDING, you need sip 4.5 for this to work
7 Generate (press g)
8. make
9. To execute the tests: make check
10. To create to API-documentation: make docs (in <builddir>)
11. To install: make install [DESTDIR=...]
12.To uninstall: make uninstall
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/KDLConfigVersion.cmake.in | set(PACKAGE_VERSION "@KDL_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif() | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/CMakeLists.txt | #
# Test CMake version
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#MARK_AS_ADVANCED( FORCE CMAKE_BACKWARDS_COMPATIBILITY )
###################################################
# #
# Start project customization section #
# #
###################################################
PROJECT(orocos_kdl)
SET( KDL_VERSION 1.3.0)
STRING( REGEX MATCHALL "[0-9]+" KDL_VERSIONS ${KDL_VERSION} )
LIST( GET KDL_VERSIONS 0 KDL_VERSION_MAJOR)
LIST( GET KDL_VERSIONS 1 KDL_VERSION_MINOR)
LIST( GET KDL_VERSIONS 2 KDL_VERSION_PATCH)
MESSAGE( "Orocos KDL version ${VERSION} (${KDL_VERSION_MAJOR}.${KDL_VERSION_MINOR}.${KDL_VERSION_PATCH})" )
SET( PROJ_SOURCE_DIR ${orocos_kdl_SOURCE_DIR} )
SET( PROJ_BINARY_DIR ${orocos_kdl_BINARY_DIR} )
IF(NOT CMAKE_INSTALL_PREFIX)
SET( CMAKE_INSTALL_PREFIX /usr/local/ CACHE PATH "Installation directory" FORCE)
MESSAGE( STATUS "Setting installation directory to ${CMAKE_INSTALL_PREFIX}" )
ENDIF(NOT CMAKE_INSTALL_PREFIX)
SET(CMAKE_VERSION "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
IF ( NOT CMAKE_BUILD_TYPE )
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
MESSAGE( "Setting build type to '${CMAKE_BUILD_TYPE}'" )
ELSE ( NOT CMAKE_BUILD_TYPE )
MESSAGE( "Build type set to '${CMAKE_BUILD_TYPE}' by user." )
ENDIF ( NOT CMAKE_BUILD_TYPE )
SET( KDL_CFLAGS "")
find_package(Eigen 3 QUIET)
if(NOT Eigen_FOUND)
include(${PROJ_SOURCE_DIR}/config/FindEigen3.cmake)
set(Eigen_INCLUDE_DIR ${EIGEN3_INCLUDE_DIR})
endif()
include_directories(${Eigen_INCLUDE_DIR})
SET(KDL_CFLAGS "${KDL_CFLAGS} -I${Eigen_INCLUDE_DIR}")
# Check the platform STL containers capabilities
include(config/CheckSTLContainers.cmake)
CHECK_STL_CONTAINERS()
# Set the default option appropriately
if(HAVE_STL_CONTAINER_INCOMPLETE_TYPES)
set(KDL_USE_NEW_TREE_INTERFACE_DEFAULT Off)
else(HAVE_STL_CONTAINER_INCOMPLETE_TYPES)
set(KDL_USE_NEW_TREE_INTERFACE_DEFAULT On)
endif(HAVE_STL_CONTAINER_INCOMPLETE_TYPES)
# Allow the user to select the Tree API version to use
set(KDL_USE_NEW_TREE_INTERFACE ${KDL_USE_NEW_TREE_INTERFACE_DEFAULT} CACHE BOOL "Use the new KDL Tree interface")
# The new interface requires the use of shared pointers
if(KDL_USE_NEW_TREE_INTERFACE)
# We need shared_ptr from boost since not all compilers are c++11 capable
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
set(KDL_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
endif(KDL_USE_NEW_TREE_INTERFACE)
INCLUDE (${PROJ_SOURCE_DIR}/config/DependentOption.cmake)
OPTION(ENABLE_TESTS OFF "Enable building of tests")
IF( ENABLE_TESTS )
# If not in standard paths, set CMAKE_xxx_PATH's in environment, eg.
# export CMAKE_INCLUDE_PATH=/opt/local/include
# export CMAKE_LIBRARY_PATH=/opt/local/lib
FIND_LIBRARY(CPPUNIT cppunit)
SET(CPPUNIT ${CPPUNIT} "dl")
FIND_PATH(CPPUNIT_HEADERS cppunit/TestRunner.h)
IF ( CPPUNIT AND CPPUNIT_HEADERS)
MESSAGE("-- Looking for Cppunit - found")
ELSE ( CPPUNIT AND CPPUNIT_HEADERS )
MESSAGE( FATAL_ERROR "-- Looking for Cppunit - not found")
ENDIF ( CPPUNIT AND CPPUNIT_HEADERS )
ENDIF(ENABLE_TESTS )
OPTION(ENABLE_EXAMPLES OFF "Enable building of examples")
ADD_SUBDIRECTORY( doc )
ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( tests )
ADD_SUBDIRECTORY( models )
ADD_SUBDIRECTORY( examples )
export(TARGETS orocos-kdl
FILE "${PROJECT_BINARY_DIR}/OrocosKDLTargets.cmake")
export(PACKAGE orocos_kdl)
set(KDL_INCLUDE_DIRS ${KDL_INCLUDE_DIRS} ${Eigen_INCLUDE_DIR})
CONFIGURE_FILE(KDLConfig.cmake.in
${PROJECT_BINARY_DIR}/orocos_kdl-config.cmake @ONLY)
CONFIGURE_FILE(KDLConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/orocos_kdl-config-version.cmake @ONLY)
INSTALL(FILES ${PROJECT_BINARY_DIR}/orocos_kdl-config.cmake DESTINATION share/orocos_kdl)
INSTALL(FILES ${PROJECT_BINARY_DIR}/orocos_kdl-config-version.cmake DESTINATION share/orocos_kdl)
INSTALL(EXPORT OrocosKDLTargets DESTINATION share/orocos_kdl)
INSTALL(FILES package.xml DESTINATION share/orocos_kdl)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/package.xml | <package>
<name>orocos_kdl</name>
<version>1.3.1</version>
<description>
This package contains a recent version of the Kinematics and Dynamics
Library (KDL), distributed by the Orocos Project.
</description>
<maintainer email="ruben@intermodalics.eu">Ruben Smits</maintainer>
<url>http://wiki.ros.org/orocos_kdl</url>
<license>LGPL</license>
<buildtool_depend>cmake</buildtool_depend>
<build_depend>eigen</build_depend>
<run_depend>catkin</run_depend>
<run_depend>eigen</run_depend>
<run_depend>pkg-config</run_depend>
<test_depend>cppunit</test_depend>
<export>
<build_type>cmake</build_type>
</export>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/cmake_uninstall.cmake.in | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"${file}\"")
IF(EXISTS "${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF("${rm_retval}" STREQUAL 0)
ELSE("${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
ENDIF("${rm_retval}" STREQUAL 0)
ELSE(EXISTS "${file}")
MESSAGE(STATUS "File \"${file}\" does not exist.")
ENDIF(EXISTS "${file}")
ENDFOREACH(file) | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/manifest.xml | <package>
<description brief="The Kinematics and Dynamics Library (latest)">
This package contains a recent version of the Kinematics and Dynamics
Library (KDL), distributed by the Orocos Project.
</description>
<author>Ruben Smits, Erwin Aertbelien, Orocos Developers</author>
<license>LGPL</license>
<review status="reviewed" notes=""/>
<url>http://www.orocos.org/kdl</url>
<export>
<cpp cflags="-I${prefix}/install_dir/include `pkg-config --cflags eigen3`" lflags="-Wl,-rpath,${prefix}/install_dir/lib -L${prefix}/install_dir/lib -lorocos-kdl"/>
<doxymaker external="http://www.orocos.org/kdl" />
</export>
<rosdep name="cppunit"/>
<rosdep name="pkg-config"/>
<rosdep name="eigen"/>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/README | Kinematics and Dynamics Library:
Orocos project to supply RealTime usable kinematics and dynamics code,
it contains code for rigid body kinematics calculations and
representations for kinematic structures and their inverse and forward
kinematic solvers.
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/COPYING | GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/KDLConfig.cmake.in | # - Config file for the orocos-kdl package
# It defines the following variables
# orocos_kdl_INCLUDE_DIRS - include directories for Orocos KDL
# orocos_kdl_LIBRARIES - libraries to link against for Orocos KDL
# orocos_kdl_PKGCONFIG_DIR - directory containing the .pc pkgconfig files
# Compute paths
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(orocos_kdl_INCLUDE_DIRS "@KDL_INCLUDE_DIRS@;@CMAKE_INSTALL_PREFIX@/include")
if(NOT TARGET orocos-kdl)
include("${SELF_DIR}/OrocosKDLTargets.cmake")
endif()
set(orocos_kdl_LIBRARIES orocos-kdl)
# where the .pc pkgconfig files are installed
set(orocos_kdl_PKGCONFIG_DIR "@CMAKE_INSTALL_PREFIX@/lib/pkgconfig")
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/.tar | {!!python/unicode 'url': 'https://github.com/smits/orocos-kdl-release/archive/release/indigo/orocos_kdl/1.3.1-0.tar.gz',
!!python/unicode 'version': orocos-kdl-release-release-indigo-orocos_kdl-1.3.1-0}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/kdl.doc-base.EX | Document: kdl
Title: Debian kdl Manual
Author: <insert document author here>
Abstract: This manual describes what kdl is
and how it can be used to
manage online manuals on Debian systems.
Section: unknown
Format: debiandoc-sgml
Files: /usr/share/doc/kdl/kdl.sgml.gz
Format: postscript
Files: /usr/share/doc/kdl/kdl.ps.gz
Format: text
Files: /usr/share/doc/kdl/kdl.text.gz
Format: HTML
Index: /usr/share/doc/kdl/html/index.html
Files: /usr/share/doc/kdl/html/*.html
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/liborocos-kdl-dev.install | usr/include/kdl/*.hpp
usr/include/kdl/*.inl
usr/include/kdl/utilities/*.hpp
usr/include/kdl/utilities/*.h
usr/lib/liborocos-kdl.so
usr/lib/pkgconfig/orocos-kdl.pc
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/compat | 5
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/changelog | orocos-kdl (1.0.0) UNRELEASED; urgency=low
* First major number release
-- Ruben Smits <ruben.smits@mech.kuleuven.be> Mon, 29 Sep 2008 12:23:37 +0200
orocos-kdl (0.99.0) UNRELEASED; urgency=low
* Initial release.
-- Ruben Smits <ruben.smits@mech.kuleuven.be> Wed, 07 May 2008 13:49:51 +0200
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/substvars | shlibs:Depends=libc6 (>= 2.3.5-1), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/docs | CMakeLists.txt
README
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/README | The Debian Package kdl
----------------------------
Comments regarding the Package
-- Leopold Palomo Avellaneda <lepalom@wol.es> Wed, 24 Oct 2007 13:20:52 +0200
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/python-orocos-kdl.install | usr/lib/python/site-packages/PyKDL.so
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/README.Debian | kdl for Debian
--------------
<possible notes regarding this package - if none, delete this file>
-- Leopold Palomo Avellaneda <lepalom@wol.es> Wed, 24 Oct 2007 13:20:52 +0200
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/rules | #!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
# allow parallel build using recommended approach from
# http://www.de.debian.org/doc/debian-policy/ch-source.html@s-debianrules-options
#
# For Bash type:
#
# export DEB_BUILD_OPTIONS="parallel=2"
# svn-buildpackage ...
#
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKE_FLAGS += -j$(NUMJOBS)
endif
# shared library versions, option 1
#version=2.0.5
#major=2
version=`grep orocos-kdl debian/changelog | head -1 | awk '{print substr($$2,2,length($$2)-2)}'`
major=`grep orocos-kdl debian/changelog | head -1 | awk '{print substr($$2,2,3)}'`
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
configure: configure-stamp
configure-stamp:
mkdir -p dbuild
cd dbuild;\
cmake .. \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPYTHON_BINDINGS=ON \
-DBUILD_MODELS=ON \
-DCMAKE_BUILD_TYPE="Release"\
-DPYTHON_SITE_PACKAGES_DIR=lib/python/site-packages
dh_testdir
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
cd dbuild;$(MAKE)
dh_testdir
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp*
rm -f configure-stamp*
# Add here commands to clean up after the build process.
-rm -rf build* install*
dh_clean
install: build
cd dbuild;$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
dh_testdir
dh_testroot
dh_installdirs
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install --sourcedir=debian/tmp --list-missing
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
dh_pysupport
# dh_pycentral
# dh_python
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/copyright | This is kdl, written and maintained by the orocos development team <orocos-dev@lists.mech.kuleuven.be>
on Wed, 24 Oct 2007 13:20:52 +0200.
The original source can always be found at:
http://www.orocos.org/kdl
Copyright Holder: Orocos Dev Team
License:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL'.
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/liborocos-kdl.install | usr/lib/liborocos-kdl.so.*
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/manpage.1.ex | .\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH KDL SECTION "octubre 24, 2007"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
kdl \- program to do something
.SH SYNOPSIS
.B kdl
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B kdl
and
.B bar
commands.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBkdl\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
kdl was written by <upstream author>.
.PP
This manual page was written by Leopold Palomo Avellaneda <lepalom@wol.es>,
for the Debian project (but may be used by others).
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/debian/control | Source: orocos-kdl
Priority: extra
Maintainer: Ruben Smits <ruben.smits@mech.kuleuven.be>
Build-Depends: debhelper (>= 5), cmake (>=2.6.0), pkg-config, python-all-dev(>=2.3.5-11), python-sip4-dev (>=4.4.5), python-sip4, python-support, sip4, libeigen2-dev
Standards-Version: 3.7.2
Section: libs
Package: liborocos-kdl-dev
Section: libdevel
Architecture: any
Depends: liborocos-kdl (= ${Source-Version})
Description: Kinematics and Dynamics Library development files
Orocos project to supply RealTime usable kinematics and dynamics code,
it contains code for rigid body kinematics calculations and
representations for kinematic structures and their inverse and forward
kinematic solvers.
Package: liborocos-kdl
Section: libs
Architecture: any
Depends: ${shlibs:Depends}
Description: Kinematics and Dynamics Library runtime
Orocos project to supply RealTime usable kinematics and dynamics code,
it contains code for rigid body kinematics calculations and
representations for kinematic structures and their inverse and forward
kinematic solvers.
Package: python-orocos-kdl
Section: libs
Architecture: any
Depends: ${python:Depends}, python, liborocos-kdl
XS-Python-Version: current
XB-Python-Version:${python:Versions}
Description: Kinematics and Dynamics Library python binding
Orocos project to supply RealTime usable kinematics and dynamics code,
it contains code for rigid body kinematics calculations and
representations for kinematic structures and their inverse and forward
kinematic solvers.
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/config/FindEigen3.cmake | # - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
#
# This module reads hints about search locations from
# the following enviroment variables:
#
# EIGEN3_ROOT
# EIGEN3_ROOT_DIR
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
else (EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
HINTS
ENV EIGEN3_ROOT
ENV EIGEN3_ROOT_DIR
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif(EIGEN3_INCLUDE_DIR)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/config/CheckSTLContainers.cmake | # - Macro to check whether the STL containers support incomplete types
# The issue at stake is discussed here in depth:
# http://www.drdobbs.com/the-standard-librarian-containers-of-inc/184403814
#
# Empirically libstdc++ and MSVC++ support containers of incomplete types
# whereas libc++ does not.
#
# The result is returned in HAVE_STL_CONTAINER_INCOMPLETE_TYPES
#
# Copyright 2014 Brian Jensen <Jensen dot J dot Brian at gmail dot com>
# Author: Brian Jensen <Jensen dot J dot Brian at gmail dot com>
#
macro(CHECK_STL_CONTAINERS)
INCLUDE(CheckCXXSourceCompiles)
SET(CMAKE_REQUIRED_FLAGS)
CHECK_CXX_SOURCE_COMPILES("
#include <string>
#include <map>
#include <vector>
class TreeElement;
typedef std::map<std::string, TreeElement> SegmentMap;
class TreeElement
{
TreeElement(const std::string& name): number(0) {}
public:
int number;
SegmentMap::const_iterator parent;
std::vector<SegmentMap::const_iterator> children;
static TreeElement Root(std::string& name)
{
return TreeElement(name);
}
};
int main()
{
return 0;
}
"
HAVE_STL_CONTAINER_INCOMPLETE_TYPES)
endmacro(CHECK_STL_CONTAINERS)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/config/DependentOption.cmake | # - Macro to provide an option dependent on other options.
# This macro presents an option to the user only if a set of other
# conditions are true. When the option is not presented a default
# value is used, but any value set by the user is preserved for when
# the option is presented again.
# Example invocation:
# DEPENDENT_OPTION(USE_FOO "Use Foo" ON
# "USE_BAR;NOT USE_ZOT" OFF)
# If USE_BAR is true and USE_ZOT is false, this provides an option called
# USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to OFF. If
# the status of USE_BAR or USE_ZOT ever changes, any value for the
# USE_FOO option is saved so that when the option is re-enabled it
# retains its old value.
MACRO(DEPENDENT_OPTION option doc default depends force)
IF(${option}_ISSET MATCHES "^${option}_ISSET$")
SET(${option}_AVAILABLE 1)
FOREACH(d ${depends})
STRING(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}")
IF(${CMAKE_DEPENDENT_OPTION_DEP})
ELSE(${CMAKE_DEPENDENT_OPTION_DEP})
SET(${option}_AVAILABLE 0)
ENDIF(${CMAKE_DEPENDENT_OPTION_DEP})
ENDFOREACH(d)
IF(${option}_AVAILABLE)
OPTION(${option} "${doc}" "${default}")
SET(${option} "${${option}}" CACHE BOOL "${doc}" FORCE)
ELSE(${option}_AVAILABLE)
IF(${option} MATCHES "^${option}$")
ELSE(${option} MATCHES "^${option}$")
SET(${option} "${${option}}" CACHE INTERNAL "${doc}")
ENDIF(${option} MATCHES "^${option}$")
SET(${option} ${force})
ENDIF(${option}_AVAILABLE)
ELSE(${option}_ISSET MATCHES "^${option}_ISSET$")
SET(${option} "${${option}_ISSET}")
ENDIF(${option}_ISSET MATCHES "^${option}_ISSET$")
ENDMACRO(DEPENDENT_OPTION)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/config/FindPkgConfig.cmake | ## FindPkgConfig.cmake
## by Albert Strasheim <http://students . ee . sun . ac . za/~albert/>
## and Alex Brooks (a.brooks at acfr . usyd . edu . au)
##
## This module finds packages using pkg-config, which retrieves
## information about packages from special metadata files.
##
## See http://www . freedesktop . org/Software/pkgconfig/
##
## -------------------------------------------------------------------
##
## Usage:
##
## INCLUDE( ${CMAKE_ROOT}/Modules/FindPkgConfig.cmake)
##
## IF ( CMAKE_PKGCONFIG_EXECUTABLE )
##
## # Find all the librtk stuff with pkg-config
## PKGCONFIG( "librtk >= 2.0" HAVE_RTK RTK_INCLUDE_DIRS RTK_DEFINES RTK_LINK_DIRS RTK_LIBS )
##
## ELSE ( CMAKE_PKGCONFIG_EXECUTABLE )
##
## # Can't find pkg-config -- have to find librtk somehow else
##
## ENDIF ( CMAKE_PKGCONFIG_EXECUTABLE )
##
##
## Notes:
##
## You can set the PKG_CONFIG_PATH environment variable to tell
## pkg-config where to search for .pc files. See pkg-config(1) for
## more information.
##
#
# FIXME: IF(WIN32) pkg-config --msvc-syntax ENDIF(WIN32) ???
#
# FIXME: Parsing of pkg-config output is specific to gnu-style flags
#
FIND_PROGRAM(CMAKE_PKGCONFIG_EXECUTABLE pkg-config)
MARK_AS_ADVANCED(CMAKE_PKGCONFIG_EXECUTABLE)
########################################
MACRO(PKGCONFIG_PARSE_FLAGS FLAGS INCLUDES DEFINES)
#MESSAGE("DEBUG: FLAGS: ${FLAGS}")
STRING(REGEX MATCHALL " -I[^ ]*" ${INCLUDES} "${FLAGS}")
STRING(REGEX REPLACE " -I" "" ${INCLUDES} "${${INCLUDES}}")
#MESSAGE("DEBUG: INCLUDES: ${${INCLUDES}}")
STRING(REGEX REPLACE " -I[^ ]*" "" ${DEFINES} "${FLAGS}")
#MESSAGE("DEBUG: DEFINES: ${${DEFINES}}")
ENDMACRO(PKGCONFIG_PARSE_FLAGS)
########################################
MACRO(PKGCONFIG_PARSE_LIBS LIBS LINKDIRS LINKLIBS)
#MESSAGE("DEBUG: LIBS: ${LIBS}")
STRING(REGEX MATCHALL " -L[^ ]*" ${LINKDIRS} "${LIBS}")
STRING(REGEX REPLACE " -L" "" ${LINKDIRS} "${${LINKDIRS}}")
#MESSAGE("DEBUG: LINKDIRS: ${${LINKDIRS}}")
STRING(REGEX MATCHALL " -l[^ ]*" ${LINKLIBS} "${LIBS}")
STRING(REGEX REPLACE " -l" "" ${LINKLIBS} "${${LINKLIBS}}")
#MESSAGE("DEBUG: LINKLIBS: ${${LINKLIBS}}")
ENDMACRO(PKGCONFIG_PARSE_LIBS)
########################################
MACRO(PKGCONFIG LIBRARY FOUND INCLUDE_DIRS DEFINES LINKDIRS LINKLIBS)
SET(${FOUND} 0)
# alexm: why print it twice? once here, and once when it's found/not found
# MESSAGE("-- Looking for ${LIBRARY}")
IF(CMAKE_PKGCONFIG_EXECUTABLE)
# MESSAGE("DEBUG: pkg-config executable found")
EXEC_PROGRAM(${CMAKE_PKGCONFIG_EXECUTABLE}
ARGS "'${LIBRARY}'"
OUTPUT_VARIABLE PKGCONFIG_OUTPUT
RETURN_VALUE PKGCONFIG_RETURN)
IF(NOT PKGCONFIG_RETURN)
# set C_FLAGS and CXX_FLAGS
EXEC_PROGRAM(${CMAKE_PKGCONFIG_EXECUTABLE}
ARGS "--cflags '${LIBRARY}'"
OUTPUT_VARIABLE CMAKE_PKGCONFIG_C_FLAGS)
#SET(CMAKE_PKGCONFIG_CXX_FLAGS "${CMAKE_PKGCONFIG_C_FLAGS}")
PKGCONFIG_PARSE_FLAGS(" ${CMAKE_PKGCONFIG_C_FLAGS}" ${INCLUDE_DIRS} ${DEFINES} )
# set LIBRARIES
EXEC_PROGRAM(${CMAKE_PKGCONFIG_EXECUTABLE}
ARGS "--libs '${LIBRARY}'"
OUTPUT_VARIABLE CMAKE_PKGCONFIG_LIBRARIES)
PKGCONFIG_PARSE_LIBS (" ${CMAKE_PKGCONFIG_LIBRARIES}" ${LINKDIRS} ${LINKLIBS} )
SET(${FOUND} 1)
MESSAGE("-- Looking for ${LIBRARY} -- found")
ELSE(NOT PKGCONFIG_RETURN)
MESSAGE("-- Looking for ${LIBRARY} -- not found")
SET(CMAKE_PKGCONFIG_C_FLAGS "")
SET(CMAKE_PKGCONFIG_CXX_FLAGS "")
SET(CMAKE_PKGCONFIG_LIBRARIES "")
SET(${INCLUDE_DIRS} "")
SET(${DEFINES} "")
SET(${LINKDIRS} "")
SET(${LINKLIBS} "")
ENDIF(NOT PKGCONFIG_RETURN)
ELSE(CMAKE_PKGCONFIG_EXECUTABLE)
MESSAGE("-- pkg-config executable NOT FOUND")
ENDIF(CMAKE_PKGCONFIG_EXECUTABLE)
#MESSAGE("Have ${LIBRARY} : ${${FOUND}}")
#MESSAGE("${LIBRARY} include dirs: ${${INCLUDE_DIRS}}")
#MESSAGE("${LIBRARY} defines : ${${DEFINES}}")
#MESSAGE("${LIBRARY} link dirs : ${${LINKDIRS}}")
#MESSAGE("${LIBRARY} link libs : ${${LINKLIBS}}")
ENDMACRO(PKGCONFIG)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/test-runner.cpp | // Copyright (C) 2007 Klaas Gadeyne <first dot last at gmail dot com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
/* Modified from orocos cppunit test code, also published under GPLV2
begin : Mon January 10 2005
copyright : (C) 2005 Peter Soetens
email : peter.soetens@mech.kuleuven.ac.be
*/
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <iostream>
#include <fstream>
int main(int argc, char** argv)
{
// Get the top level suite from the registry
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
// Adds the test to the list of test to run
CppUnit::TextUi::TestRunner runner;
runner.addTest( suite );
#ifndef TESTNAME
std::ofstream outputFile(std::string(suite->getName()+"-result.xml").c_str());
#else
std::ofstream outputFile((std::string(TESTNAME)+std::string("-result.xml")).c_str());
#endif
// Change the default outputter to a compiler error format outputter
runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(),outputFile ) );
// Run the tests.
bool wasSucessful = runner.run();
outputFile.close();
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/iotest.cpp | #include <iostream>
#include <kdl/error_stack.h>
#include <kdl/error.h>
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <kdl/kinfam/joint.hpp>
#include <kdl/kinfam/serialchain.hpp>
#include <kdl/kinfam/kinematicfamily_io.hpp>
#include <kdl/kinfam/crs450.hpp>
#include <kdl/kinfam/jnt2cartpos.hpp>
#include <memory>
using namespace std;
using namespace KDL;
void test_io(KinematicFamily* kf) {
// write a kf to the file tst.dat
ofstream os("tst.dat");
os << kf << endl;
cout << kf << endl;
os.close();
// read a serial chain from the file tst.dat
ifstream is ("tst.dat");
KinematicFamily* kf2;
try {
kf2 = readKinematicFamily(is);
cout << kf2 << endl;
} catch (Error& err) {
IOTraceOutput(cerr);
cout << "ERROR : " << err.Description() << endl;
exit(-1);
}
std::vector<double> q(6);
for (int i=0;i<q.size();++i) q[i] = i*0.2;
Frame F1,F2;
Jnt2CartPos* jnt2cartpos = kf->createJnt2CartPos();
Jnt2CartPos* jnt2cartpos2 = kf2->createJnt2CartPos();
jnt2cartpos->evaluate(q);jnt2cartpos->getFrame(F1);
jnt2cartpos2->evaluate(q);jnt2cartpos2->getFrame(F2);
cout << F1 << endl;
cout << F2 << endl;
if (!Equal(F1,F2)) {
cerr << "Results are not equal" << endl;
exit(-1);
}
delete jnt2cartpos;
delete jnt2cartpos2;
delete kf2;
delete kf;
}
int main(int argc,char* argv[]) {
test_io(new CRS450());
test_io(new CRS450Feath());
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobianframetests.cpp | #include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <kdl/framevel.hpp>
#include <kdl/framevel_io.hpp>
#include <kdl/jacobianexpr.hpp>
#include <kdl/jacobianframe.hpp>
#include <kdl/jacobianframevel.hpp>
#include "jacobianframetests.hpp"
namespace KDL {
void checkDiffs() {
KDL_CTX;
double adouble,bdouble;
Vector avector,bvector;
Twist atwist,btwist;
Rotation arot,brot;
Frame aframe,bframe;
// large deviations :
random(adouble);random(bdouble);
random(avector);random(bvector);
random(atwist);random(btwist);
random(arot);random(brot);
random(aframe);random(bframe);
double dt=0.1;
double eps = 1E-10;
checkEqual(bdouble,addDelta(adouble,diff(adouble,bdouble,dt),dt),eps);
checkEqual(bvector,addDelta(avector,diff(avector,bvector,dt),dt),eps);
checkEqual(btwist,addDelta(atwist,diff(atwist,btwist,dt),dt),eps);
checkEqual(brot,addDelta(arot,diff(arot,brot,dt),dt),eps);
checkEqual(bframe,addDelta(aframe,diff(aframe,bframe,dt),dt),eps);
// small deviations
dt = 0.00001;
double ddouble;
Vector dvector;
Twist dtwist;
Vector drot; // there is no error in the naming ...
Twist dframe;
random(ddouble);random(dvector);random(dtwist);random(drot);random(dframe);
checkEqual(ddouble,diff(adouble,addDelta(adouble,ddouble,dt),dt),eps);
checkEqual(dvector,diff(avector,addDelta(avector,dvector,dt),dt),eps);
checkEqual(dtwist,diff(atwist,addDelta(atwist,dtwist,dt),dt),eps);
checkEqual(drot,diff(arot,addDelta(arot,drot,dt),dt),eps);
checkEqual(dframe,diff(aframe,addDelta(aframe,dframe,dt),dt),eps);
}
void checkEulerZYX() {
// Take care of the order of the arguments :
KDL_CTX;
int nrofcol=3;
Jacobian<Rotation> R(nrofcol);
Jacobian<Rotation> R2(nrofcol);
Jacobian<double> alpha(nrofcol);
random(alpha);
Jacobian<double> beta(nrofcol);
random(beta);
Jacobian<double> gamma(nrofcol);
random(gamma);
SetEulerZYX(gamma,beta,alpha,R);
// now we have a random frame R.
int result=GetEulerZYX(R,gamma,beta,alpha);
assert( result == 0);
SetEulerZYX(gamma,beta,alpha,R2);
checkEqual(R.value(),R2.value(),0.0001);
for (int i=0;i<nrofcol;i++) {
checkEqual(R.deriv(i),R2.deriv(i),0.0001);
}
double dt= 1E-8;
double eps = 1E-4;
std::cout << "Tests with numerical derivatives for EulerZYX " << std::endl;
for (int i=0;i<nrofcol;i++) {
Rotation R2 = Rotation::EulerZYX(alpha.value(),beta.value(),gamma.value());
checkEqual( R.deriv(i),
diff(
R.value(),
Rotation::EulerZYX(
alpha.value()+ alpha.deriv(i)*dt,
beta.value() + beta.deriv(i)*dt,
gamma.value()+ gamma.deriv(i)*dt),
dt),
eps);
}
}
void checkFrameOps() {
KDL_CTX;
checkDiffs();
checkUnary<OpInverse,Frame>::check();
checkUnary<OpNegate,Vector>::check();
checkUnary<OpNorm,Vector>::check();
checkUnary<OpRotX,double>::check();
checkUnary<OpRotY,double>::check();
checkUnary<OpRotZ,double>::check();
checkUnary<OpUnitX,Rotation>::check();
checkUnary<OpUnitY,Rotation>::check();
checkUnary<OpUnitZ,Rotation>::check();
checkUnary<OpInverse,Rotation>::check();
checkUnary<OpNegate,Twist>::check();
checkBinary<OpMult,Frame,Frame>::check();
checkBinary<OpMult,Frame,Vector>::check();
checkBinary<OpDot,Vector,Vector>::check();
checkBinary<OpMult,Vector,Vector>::check();
checkBinary<OpAdd,Vector,Vector>::check();
checkBinary<OpSub,Vector,Vector>::check();
checkBinary<OpMult,Rotation,Rotation>::check();
checkBinary<OpMult,Rotation,Vector>::check();
checkBinary<OpMult,Rotation,Twist>::check();
checkBinary<OpAdd,Twist,Twist>::check();
checkBinary<OpSub,Twist,Twist>::check();
checkBinary<OpMult,Twist,double>::check();
checkBinary<OpMult,double,Twist>::check();
checkBinary<OpRefPoint,Twist,Vector>::check();
checkBinary<OpAdd,Wrench,Wrench>::check();
checkBinary<OpSub,Wrench,Wrench>::check();
checkBinary<OpMult,Wrench,double>::check();
checkBinary<OpMult,double,Wrench>::check();
checkBinary<OpRefPoint,Wrench,Vector>::check();
checkBinary<OpDiff,Vector,Vector>::check();
//checkBinary_displ<OpDiff,Rotation,Rotation>::check();
checkEulerZYX();
}
void checkFrameVelOps() {
KDL_CTX;
checkDiffs();
checkUnaryVel<OpNegate,VectorVel>::check();
checkUnaryVel<OpNorm,VectorVel>::check();
checkUnaryVel<OpInverse,FrameVel>::check();
checkUnaryVel<OpRotation,FrameVel>::check();
checkUnaryVel<OpOrigin,FrameVel>::check();
checkUnaryVel<OpUnitX,RotationVel>::check();
checkUnaryVel<OpUnitY,RotationVel>::check();
checkUnaryVel<OpUnitZ,RotationVel>::check();
checkUnaryVel<OpCoordX,VectorVel>::check();
checkUnaryVel<OpCoordY,VectorVel>::check();
checkUnaryVel<OpCoordZ,VectorVel>::check();
checkUnaryVel<OpRotation,FrameVel>::check();
//checkUnary<OpRotX,double>::check();
//checkUnary<OpRotY,double>::check();
//checkUnary<OpRotZ,double>::check();
checkUnaryVel<OpInverse,RotationVel>::check();
checkUnaryVel<OpNegate,TwistVel>::check();
checkBinaryVel<OpMult,FrameVel,FrameVel>::check();
checkBinaryVel<OpMult,FrameVel,VectorVel>::check();
checkBinaryVel<OpDot,VectorVel,VectorVel>::check();
checkBinaryVel<OpMult,VectorVel,VectorVel>::check();
checkBinaryVel<OpAdd,VectorVel,VectorVel>::check();
checkBinaryVel<OpSub,VectorVel,VectorVel>::check();
checkBinaryVel<OpMult,doubleVel,VectorVel>::check();
checkBinaryVel<OpMult,VectorVel,doubleVel>::check();
checkBinaryVel<OpMult,RotationVel,RotationVel>::check();
checkBinaryVel<OpMult,RotationVel,VectorVel>::check();
checkBinaryVel<OpMult,RotationVel,TwistVel>::check();
checkBinaryVel<OpAdd,TwistVel,TwistVel>::check();
checkBinaryVel<OpSub,TwistVel,TwistVel>::check();
checkBinaryVel<OpMult,TwistVel,doubleVel>::check();
checkBinaryVel<OpMult,doubleVel,TwistVel>::check();
checkBinaryVel<OpRefPoint,TwistVel,VectorVel>::check();
/*
checkBinary<OpAdd,Wrench,Wrench>::check();
checkBinary<OpSub,Wrench,Wrench>::check();
checkBinary<OpMult,Wrench,double>::check();
checkBinary<OpMult,double,Wrench>::check();
checkBinary<OpRefPoint,Wrench,Vector>::check(); */
checkBinaryVel<OpDiff,VectorVel,VectorVel>::check();
//checkBinaryVel<OpDiff,RotationVel,RotationVel>::check(); WHY ?
//checkBinaryVel<OpDiff,FrameVel,FrameVel>::check(); WHY ?
//checkEulerZYX();
}
} // namespace ORO_Geometry
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/kinfamtest.cpp | #include "kinfamtest.hpp"
#include <frames_io.hpp>
#include <kinfam_io.hpp>
#include <chainfksolverpos_recursive.hpp>
CPPUNIT_TEST_SUITE_REGISTRATION( KinFamTest );
#ifdef __APPLE__
typedef unsigned int uint;
#endif
using namespace KDL;
using namespace std;
void KinFamTest::setUp()
{
}
void KinFamTest::tearDown()
{
}
void KinFamTest::JointTest()
{
double q;
Joint j;
j=Joint("Joint 1", Joint::None);
CPPUNIT_ASSERT_EQUAL(Joint::None,j.getType());
random(q);
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame::Identity());
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist::Zero());
random(q);
j=Joint("Joint 2", Joint::RotX);
CPPUNIT_ASSERT_EQUAL(Joint::RotX,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Rotation::RotX(q)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector::Zero(),Vector(q,0,0)));
random(q);
j=Joint("Joint 3", Joint::RotY);
CPPUNIT_ASSERT_EQUAL(Joint::RotY,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Rotation::RotY(q)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector::Zero(),Vector(0,q,0)));
random(q);
j=Joint("Joint 4", Joint::RotZ);
CPPUNIT_ASSERT_EQUAL(Joint::RotZ,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Rotation::RotZ(q)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector::Zero(),Vector(0,0,q)));
random(q);
j=Joint("Joint 5", Joint::TransX);
CPPUNIT_ASSERT_EQUAL(Joint::TransX,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Vector(q,0,0)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector(q,0,0),Vector::Zero()));
random(q);
j=Joint("Joint 6", Joint::TransY);
CPPUNIT_ASSERT_EQUAL(Joint::TransY,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Vector(0,q,0)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector(0,q,0),Vector::Zero()));
random(q);
j=Joint("Joint 7", Joint::TransZ);
CPPUNIT_ASSERT_EQUAL(Joint::TransZ,j.getType());
CPPUNIT_ASSERT_EQUAL(j.pose(q),Frame(Vector(0,0,q)));
random(q);
CPPUNIT_ASSERT_EQUAL(j.twist(q),Twist(Vector(0,0,q),Vector::Zero()));
}
void KinFamTest::SegmentTest()
{
Segment s;
double q,qdot;
Frame f,f1;
random(f);
s = Segment("Segment 0", Joint("Joint 0", Joint::None),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 1", Joint("Joint 1", Joint::RotX),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 3", Joint("Joint 3", Joint::RotY),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 4", Joint("Joint 4", Joint::RotZ),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 5", Joint("Joint 5", Joint::TransX),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 6", Joint("Joint 6", Joint::TransY),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
random(f);
s = Segment("Segment 7", Joint("Joint 7", Joint::TransZ),f);
random(q);
random(qdot);
f1=s.getJoint().pose(q)*f;
CPPUNIT_ASSERT_EQUAL(f1,s.pose(q));
CPPUNIT_ASSERT_EQUAL(s.getJoint().twist(qdot).RefPoint(f1.p),s.twist(q,qdot));
}
void KinFamTest::ChainTest()
{
Chain chain1;
chain1.addSegment(Segment("Segment 0", Joint("Joint 0", Joint::RotZ),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 1", Joint("Joint 1", Joint::RotX),
Frame(Vector(0.0,0.0,0.9))));
chain1.addSegment(Segment("Segment 2", Joint("Joint 2", Joint::RotX),
Frame(Vector(0.0,0.0,1.2))));
chain1.addSegment(Segment("Segment 3", Joint("Joint 3", Joint::RotZ),
Frame(Vector(0.0,0.0,1.5))));
chain1.addSegment(Segment("Segment 4", Joint("Joint 4", Joint::RotX),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 5", Joint("Joint 5", Joint::RotZ),
Frame(Vector(0.0,0.0,0.4))));
CPPUNIT_ASSERT_EQUAL(chain1.getNrOfJoints(),(uint)6);
CPPUNIT_ASSERT_EQUAL(chain1.getNrOfSegments(),(uint)6);
chain1.addSegment(Segment("Segment 6", Joint("Joint 6", Joint::None),Frame(Vector(0.0,0.1,0.0))));
CPPUNIT_ASSERT_EQUAL(chain1.getNrOfJoints(),(uint)6);
CPPUNIT_ASSERT_EQUAL(chain1.getNrOfSegments(),(uint)7);
Chain chain2 = chain1;
CPPUNIT_ASSERT_EQUAL(chain2.getNrOfJoints(),chain1.getNrOfJoints());
CPPUNIT_ASSERT_EQUAL(chain2.getNrOfSegments(),chain1.getNrOfSegments());
chain2.addChain(chain1);
CPPUNIT_ASSERT_EQUAL(chain2.getNrOfJoints(),chain1.getNrOfJoints()*(uint)2);
CPPUNIT_ASSERT_EQUAL(chain2.getNrOfSegments(),chain1.getNrOfSegments()*(uint)2);
}
void KinFamTest::TreeTest()
{
Tree tree1;
Segment segment1("Segment 1", Joint("Joint 1", Joint::None));
Segment segment2("Segment 2", Joint("Joint 2", Joint::RotX),Frame(Vector(0.1,0.2,0.3)));
Segment segment3("Segment 3", Joint("Joint 3", Joint::TransZ),Frame(Rotation::RotX(1.57)));
Segment segment4("Segment 4", Joint("Joint 4", Joint::RotX),Frame(Vector(0.1,0.2,0.3)));
Segment segment5("Segment 5", Joint("Joint 5", Joint::RotX),Frame(Vector(0.1,0.2,0.3)));
Segment segment6("Segment 6", Joint("Joint 6", Joint::RotX),Frame(Vector(0.1,0.2,0.3)));
Segment segment7("Segment 7", Joint("Joint 7", Joint::RotX),Frame(Vector(0.1,0.2,0.3)));
cout<<tree1<<endl;
CPPUNIT_ASSERT(tree1.addSegment(segment1,"root"));
CPPUNIT_ASSERT(tree1.addSegment(segment2,"root"));
CPPUNIT_ASSERT(tree1.addSegment(segment3,"Segment 1"));
CPPUNIT_ASSERT(tree1.addSegment(segment4,"Segment 3"));
CPPUNIT_ASSERT(!tree1.addSegment(segment1,"Segment 6"));
CPPUNIT_ASSERT(!tree1.addSegment(segment1,"Segment 4"));
cout<<tree1<<endl;
Tree tree2;
CPPUNIT_ASSERT(tree2.addSegment(segment5,"root"));
CPPUNIT_ASSERT(tree2.addSegment(segment6,"root"));
CPPUNIT_ASSERT(tree2.addSegment(segment7,"Segment 6"));
cout<<tree2<<endl;
Chain chain1;
chain1.addSegment(Segment("Segment 8", Joint("Joint 8", Joint::RotZ),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 9", Joint("Joint 9", Joint::RotX),
Frame(Vector(0.0,0.0,0.9))));
chain1.addSegment(Segment("Segment 10", Joint("Joint 10", Joint::RotX),
Frame(Vector(0.0,0.0,1.2))));
chain1.addSegment(Segment("Segment 11", Joint("Joint 11", Joint::RotZ),
Frame(Vector(0.0,0.0,1.5))));
chain1.addSegment(Segment("Segment 12", Joint("Joint 12", Joint::RotX),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 13", Joint("Joint 13", Joint::RotZ),
Frame(Vector(0.0,0.0,0.4))));
CPPUNIT_ASSERT(tree2.addChain(chain1, "Segment 6"));
cout<<tree2<<endl;
CPPUNIT_ASSERT(tree1.addTree(tree2, "Segment 2"));
cout<<tree1<<endl;
Chain extract_chain1;
CPPUNIT_ASSERT(tree1.getChain("Segment 2", "Segment 4", extract_chain1));
Chain extract_chain2;
CPPUNIT_ASSERT(tree1.getChain("Segment 4", "Segment 2", extract_chain2));
CPPUNIT_ASSERT(tree1.getChain("Segment 4", "Segment 2", extract_chain2));
CPPUNIT_ASSERT(extract_chain1.getNrOfJoints()==extract_chain2.getNrOfJoints());
CPPUNIT_ASSERT(extract_chain1.getNrOfSegments()==extract_chain2.getNrOfSegments());
ChainFkSolverPos_recursive solver1(extract_chain1);
ChainFkSolverPos_recursive solver2(extract_chain2);
Frame f1, f2;
JntArray jnt1(extract_chain2.getNrOfJoints());
JntArray jnt2(extract_chain2.getNrOfJoints());
for (int i=0; i<(int)extract_chain2.getNrOfJoints(); i++){
jnt1(i) = (i+1)*2;
jnt2((int)extract_chain2.getNrOfJoints()-i-1) = jnt1(i);
}
solver1.JntToCart(jnt1, f1);
solver2.JntToCart(jnt2, f2);
CPPUNIT_ASSERT(f1 == f2.Inverse());
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/framestest.cpp | #include <math.h>
#include "framestest.hpp"
#include <frames_io.hpp>
CPPUNIT_TEST_SUITE_REGISTRATION( FramesTest );
using namespace KDL;
void FramesTest::setUp()
{
}
void FramesTest::tearDown()
{
}
void FramesTest::TestVector2(Vector& v) {
Vector v2;
CPPUNIT_ASSERT_EQUAL(2*v-v,v);
CPPUNIT_ASSERT_EQUAL(v*2-v,v);
CPPUNIT_ASSERT_EQUAL(v+v+v-2*v,v);
v2=v;
CPPUNIT_ASSERT_EQUAL(v,v2);
v2+=v;
CPPUNIT_ASSERT_EQUAL(2*v,v2);
v2-=v;
CPPUNIT_ASSERT_EQUAL(v,v2);
v2.ReverseSign();
CPPUNIT_ASSERT_EQUAL(v,-v2);
}
void FramesTest::TestVector() {
Vector v(3,4,5);
TestVector2(v);
Vector v2(0,0,0);
TestVector2(v2);
Vector nu(0,0,0);
CPPUNIT_ASSERT_EQUAL(nu.Norm(),0.0);
Vector nu2(10,0,0);
CPPUNIT_ASSERT_EQUAL(nu2.Norm(),10.0);
}
void FramesTest::TestTwist2(Twist& t) {
Twist t2(Vector(16,-3,5),Vector(-4,2,1));
CPPUNIT_ASSERT_EQUAL(2*t-t,t);
CPPUNIT_ASSERT_EQUAL(t*2-t,t);
CPPUNIT_ASSERT_EQUAL(t+t+t-2*t,t);
t2=t;
CPPUNIT_ASSERT_EQUAL(t,t2);
t2+=t;
CPPUNIT_ASSERT_EQUAL(2*t,t2);
t2-=t;
CPPUNIT_ASSERT_EQUAL(t,t2);
t.ReverseSign();
CPPUNIT_ASSERT_EQUAL(t,-t2);
}
void FramesTest::TestTwist() {
Twist t(Vector(6,3,5),Vector(4,-2,7));
TestTwist2(t);
Twist t2(Vector(0,0,0),Vector(0,0,0));
TestTwist2(t2);
Twist t3(Vector(0,-9,-3),Vector(1,-2,-4));
TestTwist2(t3);
}
void FramesTest::TestWrench2(Wrench& w) {
// Wrench
Wrench w2;
CPPUNIT_ASSERT_EQUAL(2*w-w,w);
CPPUNIT_ASSERT_EQUAL(w*2-w,w);
CPPUNIT_ASSERT_EQUAL(w+w+w-2*w,w);
w2=w;
CPPUNIT_ASSERT_EQUAL(w,w2);
w2+=w;
CPPUNIT_ASSERT_EQUAL(2*w,w2);
w2-=w;
CPPUNIT_ASSERT_EQUAL(w,w2);
w.ReverseSign();
CPPUNIT_ASSERT_EQUAL(w,-w2);
}
void FramesTest::TestWrench() {
Wrench w(Vector(7,-1,3),Vector(2,-3,3));
TestWrench2(w);
Wrench w2(Vector(0,0,0),Vector(0,0,0));
TestWrench2(w2);
Wrench w3(Vector(2,1,4),Vector(5,3,1));
TestWrench2(w3);
}
void FramesTest::TestRotation2(const Vector& v,double a,double b,double c) {
Vector v2;
// Wrench
Wrench w(Vector(7,-1,3),Vector(2,-3,3));
Twist t(Vector(6,3,5),Vector(4,-2,7));
// Rotation
Rotation R;
Rotation R2;
double ra;
double rb;
double rc;
R = Rotation::RPY(a,b,c);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitX(),R.UnitX()),1.0,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitY(),R.UnitY()),1.0,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitZ(),R.UnitZ()),1.0,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitX(),R.UnitY()),0.0,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitX(),R.UnitZ()),0.0,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(R.UnitY(),R.UnitZ()),0.0,epsilon);
R2=R;
CPPUNIT_ASSERT_EQUAL(R,R2);
CPPUNIT_ASSERT_DOUBLES_EQUAL((R*v).Norm(),v.Norm(),epsilon);
CPPUNIT_ASSERT_EQUAL(R.Inverse(R*v),v);
CPPUNIT_ASSERT_EQUAL(R.Inverse(R*t),t);
CPPUNIT_ASSERT_EQUAL(R.Inverse(R*w),w);
CPPUNIT_ASSERT_EQUAL(R*R.Inverse(v),v);
CPPUNIT_ASSERT_EQUAL(R*Rotation::Identity(),R);
CPPUNIT_ASSERT_EQUAL(Rotation::Identity()*R,R);
CPPUNIT_ASSERT_EQUAL(R*(R*(R*v)),(R*R*R)*v);
CPPUNIT_ASSERT_EQUAL(R*(R*(R*t)),(R*R*R)*t);
CPPUNIT_ASSERT_EQUAL(R*(R*(R*w)),(R*R*R)*w);
CPPUNIT_ASSERT_EQUAL(R*R.Inverse(),Rotation::Identity());
CPPUNIT_ASSERT_EQUAL(R.Inverse()*R,Rotation::Identity());
CPPUNIT_ASSERT_EQUAL(R.Inverse()*v,R.Inverse(v));
R.GetRPY(ra,rb,rc);
CPPUNIT_ASSERT_DOUBLES_EQUAL(ra,a,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rb,b,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rc,c,epsilon);
R = Rotation::EulerZYX(a,b,c);
R.GetEulerZYX(ra,rb,rc);
CPPUNIT_ASSERT_DOUBLES_EQUAL(ra,a,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rb,b,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rc,c,epsilon);
R = Rotation::EulerZYZ(a,b,c);
R.GetEulerZYZ(ra,rb,rc);
CPPUNIT_ASSERT_DOUBLES_EQUAL(ra,a,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rb,b,epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(rc,c,epsilon);
double angle= R.GetRotAngle(v2);
R2=Rotation::Rot2(v2,angle);
CPPUNIT_ASSERT_EQUAL(R2,R);
R2=Rotation::Rot(v2*1E20,angle);
CPPUNIT_ASSERT_EQUAL(R,R2);
v2=Vector(6,2,4);
CPPUNIT_ASSERT_DOUBLES_EQUAL((v2).Norm(),::sqrt(dot(v2,v2)),epsilon);
}
// compare a rotation R with the expected angle and axis
void FramesTest::TestOneRotation(const std::string& msg,
const KDL::Rotation& R,
const double expectedAngle,
const KDL::Vector& expectedAxis)
{
double angle =0;
Vector axis;
angle = R.GetRotAngle(axis);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msg, expectedAngle, angle, epsilon);
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, expectedAxis, axis);
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, expectedAngle * expectedAxis, R.GetRot());
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, Rotation::Rot(axis, angle), R);
(void)axis.Normalize();
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, Rotation::Rot2(axis, angle), R);
}
void FramesTest::TestArbitraryRotation(const std::string& msg,
const KDL::Vector& v,
const double angle,
const double expectedAngle,
const KDL::Vector& expectedVector)
{
std::stringstream ss;
ss << "rot(" << msg << "],(" << angle << ")";
TestOneRotation(ss.str(), Rotation::Rot(v,angle*deg2rad), expectedAngle*deg2rad, expectedVector);
}
#define TESTEULERZYX(a,b,g) \
{\
double eps=1E-14;\
Rotation R = Rotation::EulerZYX((a),(b),(g));\
double alpha,beta,gamma;\
R.GetEulerZYX(alpha,beta,gamma);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((a),alpha,eps);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((b),beta,eps);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((g),gamma,eps);\
}
#define TESTEULERZYZ(a,b,g) \
{\
double eps=1E-14;\
Rotation R = Rotation::EulerZYZ((a),(b),(g));\
double alpha,beta,gamma;\
R.GetEulerZYZ(alpha,beta,gamma);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((a),alpha,eps);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((b),beta,eps);\
CPPUNIT_ASSERT_DOUBLES_EQUAL((g),gamma,eps);\
}
#define TESTEULERZYX_INVARIANT(a,b,g,a2,b2,g2)\
{\
double eps=1E-14;\
Rotation R1=Rotation::EulerZYX(a,b,g);\
Rotation R2=Rotation::EulerZYX(a2,b2,g2);\
CPPUNIT_ASSERT_DOUBLES_EQUAL(0,diff(R2,R1).Norm(),eps);\
}
#define TESTEULERZYZ_INVARIANT(a,b,g,a2,b2,g2)\
{\
double eps=1E-14;\
Rotation R1=Rotation::EulerZYZ(a,b,g);\
Rotation R2=Rotation::EulerZYZ(a2,b2,g2);\
CPPUNIT_ASSERT_DOUBLES_EQUAL(0,diff(R2,R1).Norm(),eps);\
}
void FramesTest::TestEuler() {
using namespace KDL;
TESTEULERZYX(0.1,0.2,0.3)
TESTEULERZYX(-0.1,0.2,0.3)
TESTEULERZYX(0.1,-0.2,0.3)
TESTEULERZYX(0.1,0.2,-0.3)
TESTEULERZYX(0,0.2,0.3)
TESTEULERZYX(0.1,0.2,0)
TESTEULERZYX(0.1,0,0.3)
TESTEULERZYX(0.1,0,0)
TESTEULERZYX(0,0,0.3)
TESTEULERZYX(0,0,0)
TESTEULERZYX(0.3,0.999*M_PI/2,0.1)
// if beta== +/- M_PI/2 => multiple solutions available, gamma will be choosen to be zero !
// so we test with gamma==0 !
TESTEULERZYX(0.3,0.9999999999*M_PI/2,0)
TESTEULERZYX(0.3,0.99999999*M_PI/2,0)
TESTEULERZYX(0.3,0.999999*M_PI/2,0)
TESTEULERZYX(0.3,0.9999*M_PI/2,0)
TESTEULERZYX(0.3,0.99*M_PI/2,0)
//TESTEULERZYX(0.1,-M_PI/2,0.3)
TESTEULERZYX(0,M_PI/2,0)
TESTEULERZYX(0.3,-M_PI/2,0)
TESTEULERZYX(0.3,-0.9999999999*M_PI/2,0)
TESTEULERZYX(0.3,-0.99999999*M_PI/2,0)
TESTEULERZYX(0.3,-0.999999*M_PI/2,0)
TESTEULERZYX(0.3,-0.9999*M_PI/2,0)
TESTEULERZYX(0.3,-0.99*M_PI/2,0)
TESTEULERZYX(0,-M_PI/2,0)
// extremes of the range:
TESTEULERZYX(M_PI,-M_PI/2,0)
TESTEULERZYX(-M_PI,-M_PI/2,0)
TESTEULERZYX(M_PI,1,0)
TESTEULERZYX(-M_PI,1,0)
//TESTEULERZYX(0,-M_PI/2,M_PI) gamma will be chosen zero
//TESTEULERZYX(0,M_PI/2,-M_PI) gamma will be chosen zero
TESTEULERZYX(0,1,M_PI)
TESTEULERZYZ(0.1,0.2,0.3)
TESTEULERZYZ(-0.1,0.2,0.3)
TESTEULERZYZ(0.1,0.9*M_PI,0.3)
TESTEULERZYZ(0.1,0.2,-0.3)
TESTEULERZYZ(0,0,0)
TESTEULERZYZ(0,0,0)
TESTEULERZYZ(0,0,0)
TESTEULERZYZ(PI,0,0)
TESTEULERZYZ(0,0.2,PI)
TESTEULERZYZ(0.4,PI,0)
TESTEULERZYZ(0,PI,0)
TESTEULERZYZ(PI,PI,0)
TESTEULERZYX(0.3,M_PI/2,0)
TESTEULERZYZ(0.3,0.9999999999*M_PI/2,0)
TESTEULERZYZ(0.3,0.99999999*M_PI/2,0)
TESTEULERZYZ(0.3,0.999999*M_PI/2,0)
TESTEULERZYZ(0.3,0.9999*M_PI/2,0)
TESTEULERZYZ(0.3,0.99*M_PI/2,0)
TESTEULERZYX_INVARIANT(0.1,0.2,0.3, 0.1+M_PI, M_PI-0.2, 0.3+M_PI);
TESTEULERZYX_INVARIANT(0.1,0.2,0.3, 0.1-M_PI, M_PI-0.2, 0.3-M_PI);
TESTEULERZYX_INVARIANT(0.1,0.2,0.3, 0.1-M_PI, M_PI-0.2, 0.3+M_PI);
TESTEULERZYX_INVARIANT(0.1,0.2,0.3, 0.1+M_PI, M_PI-0.2, 0.3-M_PI);
TESTEULERZYZ_INVARIANT(0.1,0.2,0.3, 0.1+M_PI, -0.2, 0.3+M_PI);
TESTEULERZYZ_INVARIANT(0.1,0.2,0.3, 0.1-M_PI, -0.2, 0.3+M_PI);
TESTEULERZYZ_INVARIANT(0.1,0.2,0.3, 0.1+M_PI, -0.2, 0.3-M_PI);
TESTEULERZYZ_INVARIANT(0.1,0.2,0.3, 0.1-M_PI, -0.2, 0.3-M_PI);
}
void FramesTest::TestRangeArbitraryRotation(const std::string& msg,
const KDL::Vector& v,
const KDL::Vector& expectedVector)
{
TestArbitraryRotation(msg, v, 0, 0, Vector(0,0,1)); // no rotation
TestArbitraryRotation(msg, v, 45, 45, expectedVector);
TestArbitraryRotation(msg, v, 90, 90, expectedVector);
TestArbitraryRotation(msg, v, 179, 179, expectedVector);
// TestArbitraryRotation(msg, v, 180, 180, expectedVector); // sign VARIES by case because 180 degrees not
// full determined: it can return +/- the axis
// depending on what the original axis was.
// BOTH RESULTS ARE CORRECT.
TestArbitraryRotation(msg, v, 181, 179, -expectedVector); // >+180 rotation => <+180 + negative axis
TestArbitraryRotation(msg, v, 270, 90, -expectedVector);
TestArbitraryRotation(msg, v, 359, 1, -expectedVector);
TestArbitraryRotation(msg, v, 360, 0, Vector(0,0,1)); // no rotation
TestArbitraryRotation(msg, v, 361, 1, expectedVector);
TestArbitraryRotation(msg, v, 450, 90, expectedVector);
TestArbitraryRotation(msg, v, 539, 179, expectedVector);
// TestArbitraryRotation(msg, v, 540, 180, expectedVector); // see above
TestArbitraryRotation(msg, v, 541, 179, -expectedVector); // like 181
TestArbitraryRotation(msg, v, 630, 90, -expectedVector); // like 270
TestArbitraryRotation(msg, v, 719, 1, -expectedVector); // like 259
TestArbitraryRotation(msg, v, 720, 0, Vector(0,0,1)); // no rotation
TestArbitraryRotation(msg, v, -45, 45, -expectedVector);
TestArbitraryRotation(msg, v, -90, 90, -expectedVector);
TestArbitraryRotation(msg, v, -179, 179, -expectedVector);
// TestArbitraryRotation(msg, v, -180, 180, expectedVector); // see above
TestArbitraryRotation(msg, v, -181, 179, expectedVector);
TestArbitraryRotation(msg, v, -270, 90, expectedVector);
TestArbitraryRotation(msg, v, -359, 1, expectedVector);
TestArbitraryRotation(msg, v, -360, 0, Vector(0,0,1)); // no rotation
TestArbitraryRotation(msg, v, -361, 1, -expectedVector);
TestArbitraryRotation(msg, v, -450, 90, -expectedVector);
TestArbitraryRotation(msg, v, -539, 179, -expectedVector);
// TestArbitraryRotation(msg, v, -540, 180, -expectedVector); // see above
TestArbitraryRotation(msg, v, -541, 179, expectedVector);
TestArbitraryRotation(msg, v, -630, 90, expectedVector);
TestArbitraryRotation(msg, v, -719, 1, expectedVector);
TestArbitraryRotation(msg, v, -720, 0, Vector(0,0,1)); // no rotation
}
void FramesTest::TestRotation() {
TestRotation2(Vector(3,4,5),10*deg2rad,20*deg2rad,30*deg2rad);
// X axis
TestRangeArbitraryRotation("[1,0,0]", Vector(1,0,0), Vector(1,0,0));
TestRangeArbitraryRotation("[-1,0,0]", Vector(-1,0,0), Vector(-1,0,0));
// Y axis
TestRangeArbitraryRotation("[0,1,0]", Vector(0,1,0), Vector(0,1,0));
TestRangeArbitraryRotation("[0,-1,0]", Vector(0,-1,0), Vector(0,-1,0));
// Z axis
TestRangeArbitraryRotation("[0,0,1]", Vector(0,0,1), Vector(0,0,1));
TestRangeArbitraryRotation("[0,0,-1]", Vector(0,0,-1), Vector(0,0,-1));
// X,Y axes
TestRangeArbitraryRotation("[1,1,0]", Vector(1,1,0), Vector(1,1,0)/sqrt(2.0));
TestRangeArbitraryRotation("[-1,-1,0]", Vector(-1,-1,0), Vector(-1,-1,0)/sqrt(2.0));
// X,Z axes
TestRangeArbitraryRotation("[1,0,1]", Vector(1,0,1), Vector(1,0,1)/sqrt(2.0));
TestRangeArbitraryRotation("[-1,0,-1]", Vector(-1,0,-1), Vector(-1,0,-1)/sqrt(2.0));
// Y,Z axes
TestRangeArbitraryRotation("[0,1,1]", Vector(0,1,1), Vector(0,1,1)/sqrt(2.0));
TestRangeArbitraryRotation("[0,-1,-1]", Vector(0,-1,-1), Vector(0,-1,-1)/sqrt(2.0));
// X,Y,Z axes
TestRangeArbitraryRotation("[1,1,1]", Vector(1,1,1), Vector(1,1,1)/sqrt(3.0));
TestRangeArbitraryRotation("[-1,-1,-1]", Vector(-1,-1,-1), Vector(-1,-1,-1)/sqrt(3.0));
// these change ... some of the -180 are the same as the +180, and some
// results are the opposite sign.
TestOneRotation("rot([1,0,0],180)", KDL::Rotation::Rot(KDL::Vector(1,0,0),180*deg2rad), 180*deg2rad, Vector(1,0,0));
// same as +180
TestOneRotation("rot([-1,0,0],180)", KDL::Rotation::Rot(KDL::Vector(-1,0,0),180*deg2rad), 180*deg2rad, Vector(1,0,0));
TestOneRotation("rot([0,1,0],180)", KDL::Rotation::Rot(KDL::Vector(0,1,0),180*deg2rad), 180*deg2rad, Vector(0,1,0));
// same as +180
TestOneRotation("rot([0,-1,0],180)", KDL::Rotation::Rot(KDL::Vector(0,-1,0),180*deg2rad), 180*deg2rad, Vector(0,1,0));
TestOneRotation("rot([0,0,1],180)", KDL::Rotation::Rot(KDL::Vector(0,0,1),180*deg2rad), 180*deg2rad, Vector(0,0,1));
// same as +180
TestOneRotation("rot([0,0,-1],180)", KDL::Rotation::Rot(KDL::Vector(0,0,-1),180*deg2rad), 180*deg2rad, Vector(0,0,1));
TestOneRotation("rot([1,0,1],180)", KDL::Rotation::Rot(KDL::Vector(1,0,1),180*deg2rad), 180*deg2rad, Vector(1,0,1)/sqrt(2.0));
// same as +180
TestOneRotation("rot([1,0,1],-180)", KDL::Rotation::Rot(KDL::Vector(1,0,1),-180*deg2rad), 180*deg2rad, Vector(1,0,1)/sqrt(2.0));
TestOneRotation("rot([-1,0,-1],180)", KDL::Rotation::Rot(KDL::Vector(-1,0,-1),180*deg2rad), 180*deg2rad, Vector(1,0,1)/sqrt(2.0));
// same as +180
TestOneRotation("rot([-1,0,-1],-180)", KDL::Rotation::Rot(KDL::Vector(-1,0,-1),-180*deg2rad), 180*deg2rad, Vector(1,0,1)/sqrt(2.0));
TestOneRotation("rot([1,1,0],180)", KDL::Rotation::Rot(KDL::Vector(1,1,0),180*deg2rad), 180*deg2rad, Vector(1,1,0)/sqrt(2.0));
// opposite of +180
TestOneRotation("rot([1,1,0],-180)", KDL::Rotation::Rot(KDL::Vector(1,1,0),-180*deg2rad), 180*deg2rad, -Vector(1,1,0)/sqrt(2.0));
TestOneRotation("rot([-1,-1,0],180)", KDL::Rotation::Rot(KDL::Vector(-1,-1,0),180*deg2rad), 180*deg2rad, -Vector(1,1,0)/sqrt(2.0));
// opposite of +180
TestOneRotation("rot([-1,-1,0],-180)", KDL::Rotation::Rot(KDL::Vector(-1,-1,0),-180*deg2rad), 180*deg2rad, Vector(1,1,0)/sqrt(2.0));
TestOneRotation("rot([0,1,1],180)", KDL::Rotation::Rot(KDL::Vector(0,1,1),180*deg2rad), 180*deg2rad, Vector(0,1,1)/sqrt(2.0));
// same as +180
TestOneRotation("rot([0,1,1],-180)", KDL::Rotation::Rot(KDL::Vector(0,1,1),-180*deg2rad), 180*deg2rad, Vector(0,1,1)/sqrt(2.0));
TestOneRotation("rot([0,-1,-1],180)", KDL::Rotation::Rot(KDL::Vector(0,-1,-1),180*deg2rad), 180*deg2rad, Vector(0,1,1)/sqrt(2.0));
// same as +180
TestOneRotation("rot([0,-1,-1],-180)", KDL::Rotation::Rot(KDL::Vector(0,-1,-1),-180*deg2rad), 180*deg2rad, Vector(0,1,1)/sqrt(2.0));
TestOneRotation("rot([1,1,1],180)", KDL::Rotation::Rot(KDL::Vector(1,1,1),180*deg2rad), 180*deg2rad, Vector(1,1,1)/sqrt(3.0));
// same as +180
TestOneRotation("rot([1,1,1],-180)", KDL::Rotation::Rot(KDL::Vector(1,1,1),-180*deg2rad), 180*deg2rad, Vector(1,1,1)/sqrt(3.0));
TestOneRotation("rot([-1,-1,-1],180)", KDL::Rotation::Rot(KDL::Vector(-1,-1,-1),180*deg2rad), 180*deg2rad, Vector(1,1,1)/sqrt(3.0));
// same as +180
TestOneRotation("rot([-1,-1,-1],-180)", KDL::Rotation::Rot(KDL::Vector(-1,-1,-1),-180*deg2rad), 180*deg2rad, Vector(1,1,1)/sqrt(3.0));
}
void FramesTest::TestQuaternion() {
Rotation R;
Rotation R2;
double x,y,z,w;
double x2,y2,z2,w2;
// identity R -> quat -> R2
R.GetQuaternion(x,y,z,w);
R2.Quaternion(x,y,z,w);
CPPUNIT_ASSERT_EQUAL(R,R2);
// 45 deg rotation in X
R = Rotation::EulerZYX(0,0,45*deg2rad);
R.GetQuaternion(x,y,z,w);
CPPUNIT_ASSERT_DOUBLES_EQUAL(x, sin((45*deg2rad)/2), epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, 0, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(z, 0, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(w, cos((45*deg2rad)/2), epsilon);
R2 = Rotation::Quaternion(x,y,z,w);
CPPUNIT_ASSERT_EQUAL(R,R2);
// direct 45 deg rotation in X
R2 = Rotation::Quaternion(sin((45*deg2rad)/2), 0, 0, cos((45*deg2rad)/2));
CPPUNIT_ASSERT_EQUAL(R,R2);
R2.GetQuaternion(x2,y2,z2,w2);
CPPUNIT_ASSERT_DOUBLES_EQUAL(x, x2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, y2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(z, z2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(w, w2, epsilon);
// 45 deg rotation in X and in Z
R = Rotation::EulerZYX(45*deg2rad,0,45*deg2rad);
R.GetQuaternion(x,y,z,w);
R2 = Rotation::Quaternion(x,y,z,w);
CPPUNIT_ASSERT_EQUAL(R,R2);
R2.GetQuaternion(x2,y2,z2,w2);
CPPUNIT_ASSERT_DOUBLES_EQUAL(x, x2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, y2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(z, z2, epsilon);
CPPUNIT_ASSERT_DOUBLES_EQUAL(w, w2, epsilon);
}
void FramesTest::TestRotationDiff() {
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(90*deg2rad)), Vector(M_PI/2,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(180*deg2rad)), Vector(M_PI,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(270*deg2rad)), Vector(-M_PI/2,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(-360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(-270*deg2rad)), Vector(M_PI/2,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(-180*deg2rad)), Vector(M_PI,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(-90*deg2rad)), Vector(-M_PI/2,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotX(-0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(90*deg2rad)), Vector(0,M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(180*deg2rad)), Vector(0,M_PI,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(270*deg2rad)), Vector(0,-M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(-360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(-270*deg2rad)), Vector(0,M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(-180*deg2rad)), Vector(0,M_PI,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(-90*deg2rad)), Vector(0,-M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotY(-0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(90*deg2rad)), Vector(0,0,M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(180*deg2rad)), Vector(0,0,M_PI));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(270*deg2rad)), Vector(0,0,-M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(-360*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(-270*deg2rad)), Vector(0,0,M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(-180*deg2rad)), Vector(0,0,M_PI));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(-90*deg2rad)), Vector(0,0,-M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotZ(0*deg2rad), Rotation::RotZ(-0*deg2rad)), Vector(0,0,0)); // no rotation
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotZ(90*deg2rad)), Vector(0,0,M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotX(0*deg2rad), Rotation::RotY(90*deg2rad)), Vector(0,M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RotY(0*deg2rad), Rotation::RotZ(90*deg2rad)), Vector(0,0,M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::Identity(), Rotation::RotX(90*deg2rad)), Vector(M_PI/2,0,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::Identity(), Rotation::RotY(90*deg2rad)), Vector(0,M_PI/2,0));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::Identity(), Rotation::RotZ(90*deg2rad)), Vector(0,0,M_PI/2));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RPY(+0*deg2rad,0,-90*deg2rad),
Rotation::RPY(-0*deg2rad,0,+90*deg2rad)),
Vector(0,0,M_PI));
CPPUNIT_ASSERT_EQUAL(KDL::diff(Rotation::RPY(+5*deg2rad,0,-0*deg2rad),
Rotation::RPY(-5*deg2rad,0,+0*deg2rad)),
Vector(-10*deg2rad,0,0));
KDL::Rotation R1 = Rotation::RPY(+5*deg2rad,0,-90*deg2rad);
CPPUNIT_ASSERT_EQUAL(KDL::diff(R1, Rotation::RPY(-5*deg2rad,0,+90*deg2rad)),
R1*Vector(0, 0, 180*deg2rad));
}
void FramesTest::TestFrame() {
Vector v(3,4,5);
Wrench w(Vector(7,-1,3),Vector(2,-3,3)) ;
Twist t(Vector(6,3,5),Vector(4,-2,7)) ;
Rotation R ;
Frame F;
Frame F2 ;
F = Frame(Rotation::EulerZYX(10*deg2rad,20*deg2rad,-10*deg2rad),Vector(4,-2,1));
F2=F ;
CPPUNIT_ASSERT_EQUAL(F,F2);
CPPUNIT_ASSERT_EQUAL(F.Inverse(F*v),v);
CPPUNIT_ASSERT_EQUAL(F.Inverse(F*t),t);
CPPUNIT_ASSERT_EQUAL(F.Inverse(F*w),w);
CPPUNIT_ASSERT_EQUAL(F*F.Inverse(v),v);
CPPUNIT_ASSERT_EQUAL(F*F.Inverse(t),t);
CPPUNIT_ASSERT_EQUAL(F*F.Inverse(w),w);
CPPUNIT_ASSERT_EQUAL(F*Frame::Identity(),F);
CPPUNIT_ASSERT_EQUAL(Frame::Identity()*F,F);
CPPUNIT_ASSERT_EQUAL(F*(F*(F*v)),(F*F*F)*v);
CPPUNIT_ASSERT_EQUAL(F*(F*(F*t)),(F*F*F)*t);
CPPUNIT_ASSERT_EQUAL(F*(F*(F*w)),(F*F*F)*w);
CPPUNIT_ASSERT_EQUAL(F*F.Inverse(),Frame::Identity());
CPPUNIT_ASSERT_EQUAL(F.Inverse()*F,Frame::Identity());
CPPUNIT_ASSERT_EQUAL(F.Inverse()*v,F.Inverse(v));
}
void FramesTest::TestJntArray()
{
JntArray a1(4);
random(a1(0));
random(a1(1));
random(a1(2));
random(a1(3));
JntArray a2(a1);
CPPUNIT_ASSERT(Equal(a2,a1));
SetToZero(a2);
CPPUNIT_ASSERT(!Equal(a1,a2));
JntArray a3(4);
CPPUNIT_ASSERT(Equal(a2,a3));
a1=a2;
CPPUNIT_ASSERT(Equal(a1,a3));
random(a1(0));
random(a1(1));
random(a1(2));
random(a1(3));
Add(a1,a2,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
random(a2(0));
random(a2(1));
random(a2(2));
random(a2(3));
Add(a1,a2,a3);
Subtract(a3,a2,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
Multiply(a1,2,a3);
Add(a1,a1,a2);
CPPUNIT_ASSERT(Equal(a2,a3));
double a;
random(a);
Multiply(a1,a,a3);
Divide(a3,a,a2);
CPPUNIT_ASSERT(Equal(a2,a1));
}
void FramesTest::TestJntArrayWhenEmpty()
{
JntArray a1;
JntArray a2;
JntArray a3(a2);
// won't assert()
CPPUNIT_ASSERT_EQUAL((unsigned int)0,a1.rows());
CPPUNIT_ASSERT(Equal(a2,a1));
a2 = a1;
CPPUNIT_ASSERT(Equal(a2,a1));
SetToZero(a2);
CPPUNIT_ASSERT(Equal(a2,a1));
Add(a1,a2,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
Subtract(a1,a2,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
Multiply(a1,3.1,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
Divide(a1,3.1,a3);
CPPUNIT_ASSERT(Equal(a1,a3));
// MultiplyJacobian() - not tested here
/* will assert() - not tested here
double j1 = a1(0);
*/
// and now resize, and do just a few tests
a1.resize(3);
a2.resize(3);
CPPUNIT_ASSERT_EQUAL((unsigned int)3,a1.rows());
CPPUNIT_ASSERT(Equal(a2,a1));
random(a1(0));
random(a1(1));
random(a1(2));
a1 = a2;
CPPUNIT_ASSERT(Equal(a1,a2));
CPPUNIT_ASSERT_EQUAL(a1(1),a2(1));
a3.resize(3);
Subtract(a1,a2,a3); // a3 = a2 - a1 = {0}
SetToZero(a1);
CPPUNIT_ASSERT(Equal(a1,a3));
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/CMakeLists.txt | IF(ENABLE_TESTS)
ENABLE_TESTING()
INCLUDE_DIRECTORIES(${PROJ_SOURCE_DIR}/src ${CPPUNIT_HEADERS} ${PROJECT_BINARY_DIR}/src)
ADD_EXECUTABLE(framestest framestest.cpp test-runner.cpp)
TARGET_LINK_LIBRARIES(framestest orocos-kdl ${CPPUNIT})
SET(TESTNAME "framestest")
SET_TARGET_PROPERTIES( framestest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS} -DTESTNAME=\"\\\"${TESTNAME}\\\"\" ")
ADD_TEST(framestest framestest)
ADD_EXECUTABLE(kinfamtest kinfamtest.cpp test-runner.cpp)
TARGET_LINK_LIBRARIES(kinfamtest orocos-kdl ${CPPUNIT})
SET(TESTNAME "kinfamtest")
SET_TARGET_PROPERTIES( kinfamtest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS}")
ADD_TEST(kinfamtest kinfamtest)
ADD_EXECUTABLE(solvertest solvertest.cpp test-runner.cpp)
TARGET_LINK_LIBRARIES(solvertest orocos-kdl ${CPPUNIT})
SET(TESTNAME "solvertest")
SET_TARGET_PROPERTIES( solvertest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS} -DTESTNAME=\"\\\"${TESTNAME}\\\"\" ")
ADD_TEST(solvertest solvertest)
ADD_EXECUTABLE(inertiatest inertiatest.cpp test-runner.cpp)
TARGET_LINK_LIBRARIES(inertiatest orocos-kdl ${CPPUNIT})
SET(TESTNAME "inertiatest")
SET_TARGET_PROPERTIES( inertiatest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS} -DTESTNAME=\"\\\"${TESTNAME}\\\"\" ")
ADD_TEST(inertiatest inertiatest)
ADD_EXECUTABLE(jacobiantest jacobiantest.cpp test-runner.cpp)
SET(TESTNAME "jacobiantest")
TARGET_LINK_LIBRARIES(jacobiantest orocos-kdl ${CPPUNIT})
SET_TARGET_PROPERTIES( jacobiantest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS} -DTESTNAME=\"\\\"${TESTNAME}\\\"\" ")
ADD_TEST(jacobiantest jacobiantest)
ADD_EXECUTABLE(velocityprofiletest velocityprofiletest.cpp test-runner.cpp)
SET(TESTNAME "velocityprofiletest")
TARGET_LINK_LIBRARIES(velocityprofiletest orocos-kdl ${CPPUNIT})
SET_TARGET_PROPERTIES( velocityprofiletest PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS} -DTESTNAME=\"\\\"${TESTNAME}\\\"\" ")
ADD_TEST(velocityprofiletest velocityprofiletest)
# ADD_EXECUTABLE(rframestest rframestest.cpp)
# TARGET_LINK_LIBRARIES(rframestest orocos-kdl)
# ADD_TEST(rframestest rframestest)
#
# ADD_EXECUTABLE(rallnumbertest rallnumbertest.cpp)
# TARGET_LINK_LIBRARIES(rallnumbertest orocos-kdl)
# ADD_TEST(rallnumbertest rallnumbertest)
#
#
# IF(OROCOS_PLUGIN)
# ADD_EXECUTABLE(toolkittest toolkittest.cpp)
# LINK_DIRECTORIES(${OROCOS_RTT_LINK_DIRS})
# TARGET_LINK_LIBRARIES(toolkittest orocos-kdltk orocos-kdl ${OROCOS_RTT_LIBS})
# ADD_TEST(toolkittest toolkittest)
# ENDIF(OROCOS_PLUGIN)
#
# IF(PYTHON_BINDINGS)
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/framestest.py
# ${CMAKE_CURRENT_BINARY_DIR}/framestest.py COPY_ONLY)
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/kinfamtest.py
# ${CMAKE_CURRENT_BINARY_DIR}/kinfamtest.py COPY_ONLY)
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/frameveltest.py
# ${CMAKE_CURRENT_BINARY_DIR}/frameveltest.py COPY_ONLY)
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/PyKDLtest.py
# ${CMAKE_CURRENT_BINARY_DIR}/PyKDLtest.py COPY_ONLY)
# ADD_TEST(PyKDLtest PyKDLtest.py)
#
#
# ENDIF(PYTHON_BINDINGS)
ADD_CUSTOM_TARGET(check ctest -V WORKING_DIRECTORY ${PROJ_BINARY_DIR}/tests)
ENDIF(ENABLE_TESTS)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/rallnumbertest.cpp | /** \file
* To test Rall1d.h , Rall2d.h and FVector... and demonstrate
* some combinations of the datastructures.
* TURN OPTIMIZE OFF (it's a bit to complicated for the optimizer).
* \author Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
* \version
* KDL V2
*
* \par History
*
*/
#include <kdl/rall1d.h>
#include <kdl/rall1d_io.h>
#include <kdl/rall2d.h>
#include <kdl/rall2d_io.h>
#include <kdl/fvector.h>
#include <kdl/fvector_io.h>
#include <kdl/fvector2.h>
#include <kdl/fvector2_io.h>
#include <kdl/test_macros.h>
//#include <fstream>
using namespace KDL;
using namespace std;
// Again something a little bit more complicated : autodiff to 2nd derivative with N variables
template <class T,int N>
class Rall2dN :
public Rall1d<Rall1d<T, FVector<T,N> >, FVector2<Rall1d<T,FVector<T,N> >,N,T>,T>
{
public:
Rall2dN() {}
// dd is an array of an array of doubles
// dd[i][j] is the derivative towards ith and jth variable
Rall2dN(T val,T d[N],T dd[N][N]) {
this->t.t = val;
this->t.grad= FVector<T,N>(d);
for (int i=0;i<N;i++) {
this->grad[i].t = d[i];
this->grad[i].grad = FVector<T,N>(dd[i]);
}
}
};
// Again something a little bit more complicated : the Nth derivative can be defined in a recursive way
template <int N>
class RallNd :
public Rall1d< RallNd<N-1>, RallNd<N-1>, double >
{
public:
RallNd() {}
RallNd(const Rall1d< RallNd<N-1>, RallNd<N-1>,double>& arg) :
Rall1d< RallNd<N-1>, RallNd<N-1>,double>(arg) {}
RallNd(double value,double d[]) {
this->t = RallNd<N-1>(value,d);
this->grad = RallNd<N-1>(d[0],&d[1]);
}
};
template <>
class RallNd<1> : public Rall1d<double> {
public:
RallNd() {}
RallNd(const Rall1d<double>& arg) :
Rall1d<double,double,double>(arg) {}
RallNd(double value,double d[]) {
t = value;
grad = d[0];
}
};
template <class T>
void TstArithm(T& a) {
KDL_CTX;
KDL_DISP(a);
T b(a);
T c;
c = a;
KDL_DIFF(b,a);
KDL_DIFF(c,a);
KDL_DIFF( (a*a)*a, a*(a*a) );
KDL_DIFF( (-a)+a,T::Zero() );
KDL_DIFF( 2.0*a, a+a );
KDL_DIFF( a*2.0, a+a );
KDL_DIFF( a+2.0*a, 3.0*a );
KDL_DIFF( (a+2.0)*a, a*a +2.0*a );
KDL_DIFF( ((a+a)+a),(a+(a+a)) );
KDL_DIFF( asin(sin(a)), a );
KDL_DIFF( atan(tan(a)), a );
KDL_DIFF( acos(cos(a)), a );
KDL_DIFF( tan(a), sin(a)/cos(a) );
KDL_DIFF( exp(log(a)), a );
KDL_DIFF( exp(log(a)*2.0),sqr(a) );
KDL_DIFF( exp(log(a)*3.5),pow(a,3.5) );
KDL_DIFF( sqr(sqrt(a)), a );
KDL_DIFF( 2.0*sin(a)*cos(a), sin(2.0*a) );
KDL_DIFF( (a*a)/a, a );
KDL_DIFF( (a*a*a)/(a*a), a );
KDL_DIFF( sqr(sin(a))+sqr(cos(a)),T::Identity() );
KDL_DIFF( sqr(cosh(a))-sqr(sinh(a)),T::Identity() );
KDL_DIFF( pow(pow(a,3.0),1.0/3) , a );
KDL_DIFF( hypot(3.0*a,4.0*a), 5.0*a);
KDL_DIFF( atan2(5.0*sin(a),5.0*cos(a)) , a );
KDL_DIFF( tanh(a) , sinh(a)/cosh(a) );
}
int main() {
KDL_CTX;
//DisplContext::display=true;
Rall1d<double> a(0.12345,1);
TstArithm(a);
const double pb[4] = { 1.0, 2.0, 3.0, 4.0 };
Rall1d<double,FVector<double,4> > b(0.12345,FVector<double,4>(pb));
TstArithm(b);
Rall2d<double> d(0.12345,-1,0.9);
TstArithm(d);
Rall1d<Rall1d<double>,Rall1d<double>,double> f(Rall1d<double>(1,2),Rall1d<double>(2,3));
TstArithm(f);
Rall2d<Rall1d<double>,Rall1d<double>,double> g(Rall1d<double>(1,2),Rall1d<double>(2,3),Rall1d<double>(3,4));
TstArithm(g);
// something more complicated without helper classes :
Rall1d<Rall1d<double, FVector<double,2> >, FVector2<Rall1d<double,FVector<double,2> >,2,double>,double> h(
Rall1d<double, FVector<double,2> >(
1.3,
FVector<double,2>(2,3)
),
FVector2<Rall1d<double,FVector<double,2> >,2,double> (
Rall1d<double,FVector<double,2> >(
2,
FVector<double,2>(5,6)
),
Rall1d<double,FVector<double,2> >(
3,
FVector<double,2>(6,9)
)
)
);
TstArithm(h);
// with a helper-class and 3 variables
double pj[] = {2.0,3.0,4.0};
double ppj[][3] = {{5.0,6.0,7.0},{6.0,8.0,9.0},{7.0,9.0,10.0}};
Rall2dN<double,3> j(1.3,pj,ppj);
TstArithm(j);
// to calculate the Nth derivative :
double pk[] = {2.0,3.0,4.0,5.0};
RallNd<4> k(1.3,pk);
TstArithm(k);
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiantest.hpp | #ifndef JACOBIAN_TEST_HPP
#define JACOBIAN_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <jacobian.hpp>
using namespace KDL;
class JacobianTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( JacobianTest);
CPPUNIT_TEST(TestChangeRefPoint);
CPPUNIT_TEST(TestChangeRefFrame);
CPPUNIT_TEST(TestChangeBase);
CPPUNIT_TEST(TestConstructor);
CPPUNIT_TEST(TestGetSetColumn);
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void TestChangeRefPoint();
void TestChangeRefFrame();
void TestChangeBase();
void TestConstructor();
void TestGetSetColumn();
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/velocityprofiletest.hpp | #ifndef VELOCITYPROFILETEST_HPP
#define VELOCITYPROFILETEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <velocityprofile_trap.hpp>
#include <velocityprofile_traphalf.hpp>
class VelocityProfileTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(VelocityProfileTest);
CPPUNIT_TEST(TestTrap_MaxVelocity1);
CPPUNIT_TEST(TestTrap_MaxVelocity2);
CPPUNIT_TEST(TestTrap_MaxVelocity3);
CPPUNIT_TEST(TestTrap_SetDuration1);
CPPUNIT_TEST(TestTrapHalf_SetProfile_Start);
CPPUNIT_TEST(TestTrapHalf_SetProfile_End);
CPPUNIT_TEST(TestTrapHalf_SetDuration_Start);
CPPUNIT_TEST(TestTrapHalf_SetDuration_End);
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void TestTrap_MaxVelocity1();
void TestTrap_MaxVelocity2();
void TestTrap_MaxVelocity3();
void TestTrap_SetDuration1();
void TestTrapHalf_SetProfile_Start();
void TestTrapHalf_SetProfile_End();
void TestTrapHalf_SetDuration_Start();
void TestTrapHalf_SetDuration_End();
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/solvertest.cpp | #include "solvertest.hpp"
#include <frames_io.hpp>
#include <framevel_io.hpp>
#include <kinfam_io.hpp>
#include <time.h>
CPPUNIT_TEST_SUITE_REGISTRATION( SolverTest );
using namespace KDL;
void SolverTest::setUp()
{
srand( (unsigned)time( NULL ));
chain1.addSegment(Segment("Segment 1", Joint("Joint 1", Joint::RotZ),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 2", Joint("Joint 2", Joint::RotX),
Frame(Vector(0.0,0.0,0.9))));
chain1.addSegment(Segment("Segment 3", Joint("Joint 3", Joint::None),
Frame(Vector(-0.4,0.0,0.0))));
chain1.addSegment(Segment("Segment 4", Joint("Joint 4", Joint::RotX),
Frame(Vector(0.0,0.0,1.2))));
chain1.addSegment(Segment("Segment 5", Joint("Joint 5", Joint::None),
Frame(Vector(0.4,0.0,0.0))));
chain1.addSegment(Segment("Segment 6", Joint("Joint 6", Joint::RotZ),
Frame(Vector(0.0,0.0,1.4))));
chain1.addSegment(Segment("Segment 7", Joint("Joint 7", Joint::RotX),
Frame(Vector(0.0,0.0,0.0))));
chain1.addSegment(Segment("Segment 8", Joint("Joint 8", Joint::RotZ),
Frame(Vector(0.0,0.0,0.4))));
chain1.addSegment(Segment("Segment 9", Joint("Joint 9", Joint::None),
Frame(Vector(0.0,0.0,0.0))));
chain2.addSegment(Segment("Segment 1", Joint("Joint 1", Joint::RotZ),
Frame(Vector(0.0,0.0,0.5))));
chain2.addSegment(Segment("Segment 2", Joint("Joint 2", Joint::RotX),
Frame(Vector(0.0,0.0,0.4))));
chain2.addSegment(Segment("Segment 3", Joint("Joint 3", Joint::RotX),
Frame(Vector(0.0,0.0,0.3))));
chain2.addSegment(Segment("Segment 4", Joint("Joint 4", Joint::RotX),
Frame(Vector(0.0,0.0,0.2))));
chain2.addSegment(Segment("Segment 5", Joint("Joint 5", Joint::RotZ),
Frame(Vector(0.0,0.0,0.1))));
chain3.addSegment(Segment("Segment 1", Joint("Joint 1", Joint::RotZ),
Frame(Vector(0.0,0.0,0.0))));
chain3.addSegment(Segment("Segment 2", Joint("Joint 2", Joint::RotX),
Frame(Vector(0.0,0.0,0.9))));
chain3.addSegment(Segment("Segment 3", Joint("Joint 3", Joint::RotZ),
Frame(Vector(-0.4,0.0,0.0))));
chain3.addSegment(Segment("Segment 4", Joint("Joint 4", Joint::RotX),
Frame(Vector(0.0,0.0,1.2))));
chain3.addSegment(Segment("Segment 5", Joint("Joint 5", Joint::None),
Frame(Vector(0.4,0.0,0.0))));
chain3.addSegment(Segment("Segment 6", Joint("Joint 6", Joint::RotZ),
Frame(Vector(0.0,0.0,1.4))));
chain3.addSegment(Segment("Segment 7", Joint("Joint 7", Joint::RotX),
Frame(Vector(0.0,0.0,0.0))));
chain3.addSegment(Segment("Segment 8", Joint("Joint 8", Joint::RotZ),
Frame(Vector(0.0,0.0,0.4))));
chain3.addSegment(Segment("Segment 9", Joint("Joint 9", Joint::RotY),
Frame(Vector(0.0,0.0,0.0))));
chain4.addSegment(Segment("Segment 1", Joint("Joint 1", Vector(10,0,0), Vector(1,0,1),Joint::RotAxis),
Frame(Vector(0.0,0.0,0.5))));
chain4.addSegment(Segment("Segment 2", Joint("Joint 2", Vector(0,5,0), Vector(1,0,0),Joint::RotAxis),
Frame(Vector(0.0,0.0,0.4))));
chain4.addSegment(Segment("Segment 3", Joint("Joint 3", Vector(0,0,5), Vector(1,0,4),Joint::RotAxis),
Frame(Vector(0.0,0.0,0.3))));
chain4.addSegment(Segment("Segment 4", Joint("Joint 4", Vector(0,0,0), Vector(1,0,0),Joint::RotAxis),
Frame(Vector(0.0,0.0,0.2))));
chain4.addSegment(Segment("Segment 5", Joint("Joint 5", Vector(0,0,0), Vector(0,0,1),Joint::RotAxis),
Frame(Vector(0.0,0.0,0.1))));
//chain definition for vereshchagin's dynamic solver
Joint rotJoint0 = Joint(Joint::RotZ, 1, 0, 0.01);
Joint rotJoint1 = Joint(Joint::RotZ, 1, 0, 0.01);
Frame refFrame(Rotation::RPY(0.0, 0.0, 0.0), Vector(0.0, 0.0, 0.0));
Frame frame1(Rotation::RPY(0.0, 0.0, 0.0), Vector(0.0, -0.4, 0.0));
Frame frame2(Rotation::RPY(0.0, 0.0, 0.0), Vector(0.0, -0.4, 0.0));
//chain segments
Segment segment1 = Segment(rotJoint0, frame1);
Segment segment2 = Segment(rotJoint1, frame2);
//rotational inertia around symmetry axis of rotation
RotationalInertia rotInerSeg1(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
//spatial inertia
RigidBodyInertia inerSegment1(0.3, Vector(0.0, -0.4, 0.0), rotInerSeg1);
RigidBodyInertia inerSegment2(0.3, Vector(0.0, -0.4, 0.0), rotInerSeg1);
segment1.setInertia(inerSegment1);
segment2.setInertia(inerSegment2);
//chain
chaindyn.addSegment(segment1);
chaindyn.addSegment(segment2);
// Motoman SIA10 Chain (for IK singular value tests)
motomansia10.addSegment(Segment(Joint(Joint::None),
Frame::DH_Craig1989(0.0, 0.0, 0.36, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, M_PI_2, 0.0, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -M_PI_2, 0.36, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, M_PI_2, 0.0, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -M_PI_2, 0.36, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, M_PI_2, 0.0, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -M_PI_2, 0.0, 0.0)));
motomansia10.addSegment(Segment(Joint(Joint::RotZ),
Frame(Rotation::Identity(),Vector(0.0,0.0,0.155))));
}
void SolverTest::tearDown()
{
// delete fksolverpos;
// delete jacsolver;
// delete fksolvervel;
// delete iksolvervel;
// delete iksolverpos;
}
void SolverTest::FkPosAndJacTest()
{
ChainFkSolverPos_recursive fksolver1(chain1);
ChainJntToJacSolver jacsolver1(chain1);
FkPosAndJacLocal(chain1,fksolver1,jacsolver1);
ChainFkSolverPos_recursive fksolver2(chain2);
ChainJntToJacSolver jacsolver2(chain2);
FkPosAndJacLocal(chain2,fksolver2,jacsolver2);
ChainFkSolverPos_recursive fksolver3(chain3);
ChainJntToJacSolver jacsolver3(chain3);
FkPosAndJacLocal(chain3,fksolver3,jacsolver3);
ChainFkSolverPos_recursive fksolver4(chain4);
ChainJntToJacSolver jacsolver4(chain4);
FkPosAndJacLocal(chain4,fksolver4,jacsolver4);
}
void SolverTest::FkVelAndJacTest()
{
ChainFkSolverVel_recursive fksolver1(chain1);
ChainJntToJacSolver jacsolver1(chain1);
FkVelAndJacLocal(chain1,fksolver1,jacsolver1);
ChainFkSolverVel_recursive fksolver2(chain2);
ChainJntToJacSolver jacsolver2(chain2);
FkVelAndJacLocal(chain2,fksolver2,jacsolver2);
ChainFkSolverVel_recursive fksolver3(chain3);
ChainJntToJacSolver jacsolver3(chain3);
FkVelAndJacLocal(chain3,fksolver3,jacsolver3);
ChainFkSolverVel_recursive fksolver4(chain4);
ChainJntToJacSolver jacsolver4(chain4);
FkVelAndJacLocal(chain4,fksolver4,jacsolver4);
}
void SolverTest::FkVelAndIkVelTest()
{
//Chain1
std::cout<<"square problem"<<std::endl;
ChainFkSolverVel_recursive fksolver1(chain1);
ChainIkSolverVel_pinv iksolver1(chain1);
ChainIkSolverVel_pinv_givens iksolver_pinv_givens1(chain1);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkVelAndIkVelLocal(chain1,fksolver1,iksolver1);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkVelAndIkVelLocal(chain1,fksolver1,iksolver_pinv_givens1);
//Chain2
std::cout<<"underdetermined problem"<<std::endl;
ChainFkSolverVel_recursive fksolver2(chain2);
ChainIkSolverVel_pinv iksolver2(chain2);
ChainIkSolverVel_pinv_givens iksolver_pinv_givens2(chain2);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkVelAndIkVelLocal(chain2,fksolver2,iksolver2);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkVelAndIkVelLocal(chain2,fksolver2,iksolver_pinv_givens2);
//Chain3
std::cout<<"overdetermined problem"<<std::endl;
ChainFkSolverVel_recursive fksolver3(chain3);
ChainIkSolverVel_pinv iksolver3(chain3);
ChainIkSolverVel_pinv_givens iksolver_pinv_givens3(chain3);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkVelAndIkVelLocal(chain3,fksolver3,iksolver3);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkVelAndIkVelLocal(chain3,fksolver3,iksolver_pinv_givens3);
//Chain4
std::cout<<"overdetermined problem"<<std::endl;
ChainFkSolverVel_recursive fksolver4(chain4);
ChainIkSolverVel_pinv iksolver4(chain4);
ChainIkSolverVel_pinv_givens iksolver_pinv_givens4(chain4);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkVelAndIkVelLocal(chain4,fksolver4,iksolver4);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkVelAndIkVelLocal(chain4,fksolver4,iksolver_pinv_givens4);
}
void SolverTest::FkPosAndIkPosTest()
{
std::cout<<"square problem"<<std::endl;
ChainFkSolverPos_recursive fksolver1(chain1);
ChainIkSolverVel_pinv iksolver1v(chain1);
ChainIkSolverVel_pinv_givens iksolverv_pinv_givens1(chain1);
ChainIkSolverPos_NR iksolver1(chain1,fksolver1,iksolver1v);
ChainIkSolverPos_NR iksolver1_givens(chain1,fksolver1,iksolverv_pinv_givens1,1000);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkPosAndIkPosLocal(chain1,fksolver1,iksolver1);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkPosAndIkPosLocal(chain1,fksolver1,iksolver1_givens);
std::cout<<"underdetermined problem"<<std::endl;
ChainFkSolverPos_recursive fksolver2(chain2);
ChainIkSolverVel_pinv iksolverv2(chain2);
ChainIkSolverVel_pinv_givens iksolverv_pinv_givens2(chain2);
ChainIkSolverPos_NR iksolver2(chain2,fksolver2,iksolverv2);
ChainIkSolverPos_NR iksolver2_givens(chain2,fksolver2,iksolverv_pinv_givens2,1000);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkPosAndIkPosLocal(chain2,fksolver2,iksolver2);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkPosAndIkPosLocal(chain2,fksolver2,iksolver2_givens);
std::cout<<"overdetermined problem"<<std::endl;
ChainFkSolverPos_recursive fksolver3(chain3);
ChainIkSolverVel_pinv iksolverv3(chain3);
ChainIkSolverVel_pinv_givens iksolverv_pinv_givens3(chain3);
ChainIkSolverPos_NR iksolver3(chain3,fksolver3,iksolverv3);
ChainIkSolverPos_NR iksolver3_givens(chain3,fksolver3,iksolverv_pinv_givens3,1000);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkPosAndIkPosLocal(chain3,fksolver3,iksolver3);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkPosAndIkPosLocal(chain3,fksolver3,iksolver3_givens);
std::cout<<"underdetermined problem with WGs segment constructor"<<std::endl;
ChainFkSolverPos_recursive fksolver4(chain4);
ChainIkSolverVel_pinv iksolverv4(chain4);
ChainIkSolverVel_pinv_givens iksolverv_pinv_givens4(chain4);
ChainIkSolverPos_NR iksolver4(chain4,fksolver4,iksolverv4,1000);
ChainIkSolverPos_NR iksolver4_givens(chain4,fksolver4,iksolverv_pinv_givens4,1000);
std::cout<<"KDL-SVD-HouseHolder"<<std::endl;
FkPosAndIkPosLocal(chain4,fksolver4,iksolver4);
std::cout<<"KDL-SVD-Givens"<<std::endl;
FkPosAndIkPosLocal(chain4,fksolver4,iksolver4_givens);
}
void SolverTest::IkSingularValueTest()
{
unsigned int maxiter = 30;
double eps = 1e-6 ;
int maxiter_vel = 30;
double eps_vel = 0.1 ;
Frame F, dF, F_des,F_solved;
KDL::Twist F_error ;
std::cout<<"KDL-IK Solver Tests for Near Zero SVs"<<std::endl;
ChainFkSolverPos_recursive fksolver(motomansia10);
ChainIkSolverVel_pinv ikvelsolver1(motomansia10,eps_vel,maxiter_vel);
ChainIkSolverPos_NR iksolver1(motomansia10,fksolver,ikvelsolver1,maxiter,eps);
unsigned int nj = motomansia10.getNrOfJoints();
JntArray q(nj), q_solved(nj) ;
std::cout<<"norminal case: convergence"<<std::endl;
q(0) = 0. ;
q(1) = 0.5 ;
q(2) = 0.4 ;
q(3) = -M_PI_2 ;
q(4) = 0. ;
q(5) = 0. ;
q(6) = 0. ;
dF.M = KDL::Rotation::RPY(0.1, 0.1, 0.1) ;
dF.p = KDL::Vector(0.01,0.01,0.01) ;
CPPUNIT_ASSERT_EQUAL(0, fksolver.JntToCart(q,F));
F_des = F * dF ;
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NOERROR,
iksolver1.CartToJnt(q, F_des, q_solved)); // converges
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NOERROR,
ikvelsolver1.getError());
CPPUNIT_ASSERT_EQUAL((unsigned int)1,
ikvelsolver1.getNrZeroSigmas()) ; // 1 singular value
CPPUNIT_ASSERT_EQUAL(0, fksolver.JntToCart(q_solved,F_solved));
F_error = KDL::diff(F_solved,F_des);
CPPUNIT_ASSERT_EQUAL(F_des,F_solved);
std::cout<<"nonconvergence: pseudoinverse singular"<<std::endl;
q(0) = 0. ;
q(1) = 0.2 ;
q(2) = 0.4 ;
q(3) = -M_PI_2 ;
q(4) = 0. ;
q(5) = 0. ;
q(6) = 0. ;
dF.M = KDL::Rotation::RPY(0.1, 0.1, 0.1) ;
dF.p = KDL::Vector(0.01,0.01,0.01) ;
CPPUNIT_ASSERT_EQUAL(0, fksolver.JntToCart(q,F));
F_des = F * dF ;
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NO_CONVERGE,
iksolver1.CartToJnt(q,F_des,q_solved)); // no converge
CPPUNIT_ASSERT_EQUAL((int)ChainIkSolverVel_pinv::E_CONVERGE_PINV_SINGULAR,
ikvelsolver1.getError()); // truncated SV solution
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
ikvelsolver1.getNrZeroSigmas()) ; // 2 singular values (jac pseudoinverse singular)
std::cout<<"nonconvergence: large displacement, low iterations"<<std::endl;
q(0) = 0. ;
q(1) = 0.5 ;
q(2) = 0.4 ;
q(3) = -M_PI_2 ;
q(4) = 0. ;
q(5) = 0. ;
q(6) = 0. ;
// big displacement
dF.M = KDL::Rotation::RPY(0.2, 0.2, 0.2) ;
dF.p = KDL::Vector(-0.2,-0.2, -0.2) ;
// low iterations
maxiter = 5 ;
ChainIkSolverPos_NR iksolver2(motomansia10,fksolver,ikvelsolver1,maxiter,eps);
CPPUNIT_ASSERT_EQUAL(0, fksolver.JntToCart(q,F));
F_des = F * dF ;
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NO_CONVERGE,
iksolver2.CartToJnt(q,F_des,q_solved)); // does not converge
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NOERROR,
ikvelsolver1.getError());
CPPUNIT_ASSERT_EQUAL((unsigned int)1,
ikvelsolver1.getNrZeroSigmas()) ; // 1 singular value (jac pseudoinverse exists)
std::cout<<"nonconvergence: fully singular"<<std::endl;
q(0) = 0. ;
q(1) = 0. ;
q(2) = 0. ;
q(3) = 0. ;
q(4) = 0. ;
q(5) = 0. ;
q(6) = 0. ;
dF.M = KDL::Rotation::RPY(0.1, 0.1, 0.1) ;
dF.p = KDL::Vector(0.01,0.01,0.01) ;
CPPUNIT_ASSERT_EQUAL(0, fksolver.JntToCart(q,F));
F_des = F * dF ;
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NO_CONVERGE,
iksolver1.CartToJnt(q,F_des,q_solved)); // no converge
CPPUNIT_ASSERT_EQUAL((int)ChainIkSolverVel_pinv::E_CONVERGE_PINV_SINGULAR,
ikvelsolver1.getError()); // truncated SV solution
CPPUNIT_ASSERT_EQUAL((unsigned int)3,
ikvelsolver1.getNrZeroSigmas());
}
void SolverTest::IkVelSolverWDLSTest()
{
int maxiter = 30;
double eps = 0.1 ;
double lambda = 0.1 ;
std::cout<<"KDL-IK WDLS Vel Solver Tests for Near Zero SVs"<<std::endl;
KDL::ChainIkSolverVel_wdls ikvelsolver(motomansia10,eps,maxiter) ;
ikvelsolver.setLambda(lambda) ;
unsigned int nj = motomansia10.getNrOfJoints();
JntArray q(nj), dq(nj) ;
KDL::Vector v05(0.05,0.05,0.05) ;
KDL::Twist dx(v05,v05) ;
std::cout<<"smallest singular value is above threshold (no WDLS)"<<std::endl;
q(0) = 0. ;
q(1) = 0.5 ;
q(2) = 0.4 ;
q(3) = -M_PI_2 ;
q(4) = 0. ;
q(5) = 0. ;
q(6) = 0. ;
CPPUNIT_ASSERT_EQUAL((int)SolverI::E_NOERROR,
ikvelsolver.CartToJnt(q, dx, dq)) ; // wdls mode
CPPUNIT_ASSERT(1==ikvelsolver.getNrZeroSigmas()) ; // 1 singular value
std::cout<<"smallest singular value is below threshold (lambda is scaled)"<<std::endl;
q(1) = 0.2 ;
CPPUNIT_ASSERT_EQUAL((int)ChainIkSolverVel_wdls::E_CONVERGE_PINV_SINGULAR,
ikvelsolver.CartToJnt(q, dx, dq)) ; // wdls mode
CPPUNIT_ASSERT_EQUAL((unsigned int)2,ikvelsolver.getNrZeroSigmas()) ; // 2 singular values
CPPUNIT_ASSERT_EQUAL(ikvelsolver.getLambdaScaled(),
sqrt(1.0-(ikvelsolver.getSigmaMin()/eps)*(ikvelsolver.getSigmaMin()/eps))*lambda) ;
std::cout<<"smallest singular value is zero (lambda_scaled=lambda)"<<std::endl;
q(1) = 0.0 ;
CPPUNIT_ASSERT_EQUAL((int)ChainIkSolverVel_wdls::E_CONVERGE_PINV_SINGULAR,
ikvelsolver.CartToJnt(q, dx, dq)) ; // wdls mode
CPPUNIT_ASSERT_EQUAL((unsigned int)2,ikvelsolver.getNrZeroSigmas()) ; // 2 singular values
CPPUNIT_ASSERT_EQUAL(ikvelsolver.getLambdaScaled(),lambda) ; // full value
// fully singular
q(2) = 0.0 ;
q(3) = 0.0 ;
CPPUNIT_ASSERT_EQUAL((int)ChainIkSolverVel_wdls::E_CONVERGE_PINV_SINGULAR,
ikvelsolver.CartToJnt(q, dx, dq)) ; // wdls mode
CPPUNIT_ASSERT_EQUAL(4,(int)ikvelsolver.getNrZeroSigmas()) ;
CPPUNIT_ASSERT_EQUAL(ikvelsolver.getLambdaScaled(),lambda) ; // full value
}
void SolverTest::FkPosAndJacLocal(Chain& chain,ChainFkSolverPos& fksolverpos,ChainJntToJacSolver& jacsolver)
{
double deltaq = 1E-4;
Frame F1,F2;
JntArray q(chain.getNrOfJoints());
Jacobian jac(chain.getNrOfJoints());
for(unsigned int i=0; i<chain.getNrOfJoints(); i++)
{
random(q(i));
}
jacsolver.JntToJac(q,jac);
for (unsigned int i=0; i< q.rows() ; i++)
{
// test the derivative of J towards qi
double oldqi = q(i);
q(i) = oldqi+deltaq;
CPPUNIT_ASSERT(0==fksolverpos.JntToCart(q,F2));
q(i) = oldqi-deltaq;
CPPUNIT_ASSERT(0==fksolverpos.JntToCart(q,F1));
q(i) = oldqi;
// check Jacobian :
Twist Jcol1 = diff(F1,F2,2*deltaq);
Twist Jcol2(Vector(jac(0,i),jac(1,i),jac(2,i)),
Vector(jac(3,i),jac(4,i),jac(5,i)));
//CPPUNIT_ASSERT_EQUAL(true,Equal(Jcol1,Jcol2,epsJ));
CPPUNIT_ASSERT_EQUAL(Jcol1,Jcol2);
}
}
void SolverTest::FkVelAndJacLocal(Chain& chain, ChainFkSolverVel& fksolvervel, ChainJntToJacSolver& jacsolver)
{
JntArray q(chain.getNrOfJoints());
JntArray qdot(chain.getNrOfJoints());
for(unsigned int i=0; i<chain.getNrOfJoints(); i++)
{
random(q(i));
random(qdot(i));
}
JntArrayVel qvel(q,qdot);
Jacobian jac(chain.getNrOfJoints());
FrameVel cart;
Twist t;
jacsolver.JntToJac(qvel.q,jac);
CPPUNIT_ASSERT(fksolvervel.JntToCart(qvel,cart)==0);
MultiplyJacobian(jac,qvel.qdot,t);
CPPUNIT_ASSERT_EQUAL(cart.deriv(),t);
}
void SolverTest::FkVelAndIkVelLocal(Chain& chain, ChainFkSolverVel& fksolvervel, ChainIkSolverVel& iksolvervel)
{
JntArray q(chain.getNrOfJoints());
JntArray qdot(chain.getNrOfJoints());
for(unsigned int i=0; i<chain.getNrOfJoints(); i++)
{
random(q(i));
random(qdot(i));
}
JntArrayVel qvel(q,qdot);
JntArray qdot_solved(chain.getNrOfJoints());
FrameVel cart;
CPPUNIT_ASSERT(0==fksolvervel.JntToCart(qvel,cart));
int ret = iksolvervel.CartToJnt(qvel.q,cart.deriv(),qdot_solved);
CPPUNIT_ASSERT(0<=ret);
qvel.deriv()=qdot_solved;
if(chain.getNrOfJoints()<=6)
CPPUNIT_ASSERT(Equal(qvel.qdot,qdot_solved,1e-5));
else
{
FrameVel cart_solved;
CPPUNIT_ASSERT(0==fksolvervel.JntToCart(qvel,cart_solved));
CPPUNIT_ASSERT(Equal(cart.deriv(),cart_solved.deriv(),1e-5));
}
}
void SolverTest::FkPosAndIkPosLocal(Chain& chain,ChainFkSolverPos& fksolverpos, ChainIkSolverPos& iksolverpos)
{
JntArray q(chain.getNrOfJoints());
for(unsigned int i=0; i<chain.getNrOfJoints(); i++)
{
random(q(i));
}
JntArray q_init(chain.getNrOfJoints());
double tmp;
for(unsigned int i=0; i<chain.getNrOfJoints(); i++)
{
random(tmp);
q_init(i)=q(i)+0.1*tmp;
}
JntArray q_solved(q);
Frame F1,F2;
CPPUNIT_ASSERT(0==fksolverpos.JntToCart(q,F1));
CPPUNIT_ASSERT(0 <= iksolverpos.CartToJnt(q_init,F1,q_solved));
CPPUNIT_ASSERT(0==fksolverpos.JntToCart(q_solved,F2));
CPPUNIT_ASSERT_EQUAL(F1,F2);
//CPPUNIT_ASSERT_EQUAL(q,q_solved);
}
void SolverTest::VereshchaginTest()
{
Vector constrainXLinear(1.0, 0.0, 0.0);
Vector constrainXAngular(0.0, 0.0, 0.0);
Vector constrainYLinear(0.0, 0.0, 0.0);
Vector constrainYAngular(0.0, 0.0, 0.0);
// Vector constrainZLinear(0.0, 0.0, 0.0);
//Vector constrainZAngular(0.0, 0.0, 0.0);
Twist constraintForcesX(constrainXLinear, constrainXAngular);
Twist constraintForcesY(constrainYLinear, constrainYAngular);
//Twist constraintForcesZ(constrainZLinear, constrainZAngular);
Jacobian alpha(1);
//alpha.setColumn(0, constraintForcesX);
alpha.setColumn(0, constraintForcesX);
//alpha.setColumn(0, constraintForcesZ);
//Acceleration energy at the end-effector
JntArray betha(1); //set to zero
betha(0) = 0.0;
//betha(1) = 0.0;
//betha(2) = 0.0;
//arm root acceleration
Vector linearAcc(0.0, 10, 0.0); //gravitational acceleration along Y
Vector angularAcc(0.0, 0.0, 0.0);
Twist twist1(linearAcc, angularAcc);
//external forces on the arm
Vector externalForce1(0.0, 0.0, 0.0);
Vector externalTorque1(0.0, 0.0, 0.0);
Vector externalForce2(0.0, 0.0, 0.0);
Vector externalTorque2(0.0, 0.0, 0.0);
Wrench externalNetForce1(externalForce1, externalTorque1);
Wrench externalNetForce2(externalForce2, externalTorque2);
Wrenches externalNetForce;
externalNetForce.push_back(externalNetForce1);
externalNetForce.push_back(externalNetForce2);
//~Definition of constraints and external disturbances
//-------------------------------------------------------------------------------------//
//Definition of solver and initial configuration
//-------------------------------------------------------------------------------------//
int numberOfConstraints = 1;
ChainIdSolver_Vereshchagin constraintSolver(chaindyn, twist1, numberOfConstraints);
//These arrays of joint values contain actual and desired values
//actual is generated by a solver and integrator
//desired is given by an interpolator
//error is the difference between desired-actual
//in this test only the actual values are printed.
const int k = 1;
JntArray jointPoses[k];
JntArray jointRates[k];
JntArray jointAccelerations[k];
JntArray jointTorques[k];
for (int i = 0; i < k; i++)
{
JntArray jointValues(chaindyn.getNrOfJoints());
jointPoses[i] = jointValues;
jointRates[i] = jointValues;
jointAccelerations[i] = jointValues;
jointTorques[i] = jointValues;
}
// Initial arm position configuration/constraint
JntArray jointInitialPose(chaindyn.getNrOfJoints());
jointInitialPose(0) = 0.0; // initial joint0 pose
jointInitialPose(1) = M_PI/6.0; //initial joint1 pose, negative in clockwise
//j0=0.0, j1=pi/6.0 correspond to x = 0.2, y = -0.7464
//j0=2*pi/3.0, j1=pi/4.0 correspond to x = 0.44992, y = 0.58636
//actual
jointPoses[0](0) = jointInitialPose(0);
jointPoses[0](1) = jointInitialPose(1);
//~Definition of solver and initial configuration
//-------------------------------------------------------------------------------------//
//Definition of process main loop
//-------------------------------------------------------------------------------------//
//Time required to complete the task move(frameinitialPose, framefinalPose)
double taskTimeConstant = 0.1;
double simulationTime = 1*taskTimeConstant;
double timeDelta = 0.01;
int status;
const std::string msg = "Assertion failed, check matrix and array sizes";
for (double t = 0.0; t <=simulationTime; t = t + timeDelta)
{
status = constraintSolver.CartToJnt(jointPoses[0], jointRates[0], jointAccelerations[0], alpha, betha, externalNetForce, jointTorques[0]);
CPPUNIT_ASSERT((status == 0));
if (status != 0)
{
std::cout << "Check matrix and array sizes. Something does not match " << std::endl;
exit(1);
}
else
{
//Integration(robot joint values for rates and poses; actual) at the given "instanteneous" interval for joint position and velocity.
jointRates[0](0) = jointRates[0](0) + jointAccelerations[0](0) * timeDelta; //Euler Forward
jointPoses[0](0) = jointPoses[0](0) + (jointRates[0](0) - jointAccelerations[0](0) * timeDelta / 2.0) * timeDelta; //Trapezoidal rule
jointRates[0](1) = jointRates[0](1) + jointAccelerations[0](1) * timeDelta; //Euler Forward
jointPoses[0](1) = jointPoses[0](1) + (jointRates[0](1) - jointAccelerations[0](1) * timeDelta / 2.0) * timeDelta;
//printf("time, j0_pose, j1_pose, j0_rate, j1_rate, j0_acc, j1_acc, j0_constraintTau, j1_constraintTau \n");
printf("%f %f %f %f %f %f %f %f %f\n", t, jointPoses[0](0), jointPoses[0](1), jointRates[0](0), jointRates[0](1), jointAccelerations[0](0), jointAccelerations[0](1), jointTorques[0](0), jointTorques[0](1));
}
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiandoubletests.hpp | #ifndef PVDOUBLETESTS_H
#define PVDOUBLETESTS_H
#include <kdl/jacobianexpr.hpp>
#include <kdl/jacobiandouble.hpp>
#include "jacobiantests.hpp"
namespace KDL {
void checkDoubleOps();
}
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/inertiatest.cpp | #include <math.h>
#include "inertiatest.hpp"
#include <frames_io.hpp>
#include <rotationalinertia.hpp>
#include <rigidbodyinertia.hpp>
#include <articulatedbodyinertia.hpp>
#include <Eigen/Core>
CPPUNIT_TEST_SUITE_REGISTRATION( InertiaTest );
using namespace KDL;
using namespace Eigen;
void InertiaTest::setUp()
{
}
void InertiaTest::tearDown()
{
}
void InertiaTest::TestRotationalInertia() {
//Check if construction works fine
RotationalInertia I0=RotationalInertia::Zero();
CPPUNIT_ASSERT(Map<Matrix3d>(I0.data).isZero());
RotationalInertia I1;
CPPUNIT_ASSERT(Map<Matrix3d>(I1.data).isZero());
CPPUNIT_ASSERT(Map<Matrix3d>(I0.data).isApprox(Map<Matrix3d>(I1.data)));
RotationalInertia I2(1,2,3,4,5,6);
//Check if copying works fine
RotationalInertia I3=I2;
CPPUNIT_ASSERT(Map<Matrix3d>(I3.data).isApprox(Map<Matrix3d>(I2.data)));
I2.data[0]=0.0;
CPPUNIT_ASSERT(!Map<Matrix3d>(I3.data).isApprox(Map<Matrix3d>(I2.data)));
//Check if addition and multiplication works fine
Map<Matrix3d>(I0.data).setRandom();
I1=-2*I0;
CPPUNIT_ASSERT(!Map<Matrix3d>(I1.data).isZero());
I1=I1+I0+I0;
CPPUNIT_ASSERT(Map<Matrix3d>(I1.data).isZero());
//Check if matrix is symmetric
CPPUNIT_ASSERT(Map<Matrix3d>(I2.data).isApprox(Map<Matrix3d>(I2.data).transpose()));
//Check if angular momentum is correctly calculated:
Vector omega;
random(omega);
Vector momentum=I2*omega;
CPPUNIT_ASSERT(Map<Vector3d>(momentum.data).isApprox(Map<Matrix3d>(I2.data)*Map<Vector3d>(omega.data)));
}
void InertiaTest::TestRigidBodyInertia() {
RigidBodyInertia I1(0.0);
double mass;
Vector c;
RotationalInertia Ic;
random(mass);
random(c);
Matrix3d Ic_eig = Matrix3d::Random();
//make it symmetric:
Map<Matrix3d>(Ic.data)=Ic_eig+Ic_eig.transpose();
RigidBodyInertia I2(mass,c,Ic);
//Check if construction works fine
CPPUNIT_ASSERT_EQUAL(I2.getMass(),mass);
CPPUNIT_ASSERT(!Map<Matrix3d>(I2.getRotationalInertia().data).isZero());
CPPUNIT_ASSERT_EQUAL(I2.getCOG(),c);
CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(Ic.data)-mass*(Map<Vector3d>(c.data)*Map<Vector3d>(c.data).transpose()-(Map<Vector3d>(c.data).dot(Map<Vector3d>(c.data))*Matrix3d::Identity()))));
RigidBodyInertia I3=I2;
//check if copying works fine
CPPUNIT_ASSERT_EQUAL(I2.getMass(),I3.getMass());
CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I3.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I3.getRotationalInertia().data)));
//Check if multiplication and addition works fine
RigidBodyInertia I4=-2*I2 +I3+I3;
CPPUNIT_ASSERT_EQUAL(I4.getMass(),0.0);
CPPUNIT_ASSERT_EQUAL(I4.getCOG(),Vector::Zero());
CPPUNIT_ASSERT(Map<Matrix3d>(I4.getRotationalInertia().data).isZero());
//Check if transformations work fine
//Check only rotation transformation
//back and forward
Rotation R;
random(R);
I3 = R*I2;
I4 = R.Inverse()*I3;
CPPUNIT_ASSERT_EQUAL(I2.getMass(),I4.getMass());
CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
//rotation and total with p=0
Frame T(R);
I4 = T*I2;
CPPUNIT_ASSERT_EQUAL(I3.getMass(),I4.getMass());
CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I3.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
//Check only transformation
Vector p;
random(p);
I3 = I2.RefPoint(p);
I4 = I3.RefPoint(-p);
CPPUNIT_ASSERT_EQUAL(I2.getMass(),I4.getMass());
CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
T=Frame(-p);
I4 = T*I2;
CPPUNIT_ASSERT_EQUAL(I3.getMass(),I4.getMass());
CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I3.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
random(T);
I3=T*I2;
I4=T.Inverse()*I3;
Twist a;
random(a);
Wrench f=I2*a;
CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
random(T);
I3 = T*I2;
I4 = T.Inverse()*I3;
CPPUNIT_ASSERT_EQUAL(I2.getMass(),I4.getMass());
CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
}
void InertiaTest::TestArticulatedBodyInertia() {
double mass;
Vector c;
RotationalInertia Ic;
random(mass);
random(c);
Matrix3d::Map(Ic.data).triangularView<Lower>()= Matrix3d::Random().triangularView<Lower>();
RigidBodyInertia RBI2(mass,c,Ic);
ArticulatedBodyInertia I2(RBI2);
ArticulatedBodyInertia I1(mass,c,Ic);
//Check if construction works fine
CPPUNIT_ASSERT_EQUAL(I2.M,I1.M);
CPPUNIT_ASSERT_EQUAL(I2.H,I1.H);
CPPUNIT_ASSERT_EQUAL(I2.I,I1.I);
I1 = ArticulatedBodyInertia(I2);
CPPUNIT_ASSERT_EQUAL(I2.M,I1.M);
CPPUNIT_ASSERT_EQUAL(I2.H,I1.H);
CPPUNIT_ASSERT_EQUAL(I2.I,I1.I);
CPPUNIT_ASSERT_EQUAL(I2.M,(Matrix3d::Identity()*mass).eval());
CPPUNIT_ASSERT(!I2.I.isZero());
//CPPUNIT_ASSERT(I2.I.isApprox(Map<Matrix3d>(Ic.data)-mass*(Map<Vector3d>(c.data)*Map<Vector3d>(c.data).transpose()-(Map<Vector3d>(c.data).dot(Map<Vector3d>(c.data))*Matrix3d::Identity()))));
//CPPUNIT_ASSERT(I2.H.isApprox(Map<Vector3d>(c.data)*Map<Vector3d>(c.data).transpose()-(Map<Vector3d>(c.data).dot(Map<Vector3d>(c.data))*Matrix3d::Identity())));
ArticulatedBodyInertia I3=I2;
//check if copying works fine
CPPUNIT_ASSERT_EQUAL(I2.M,I3.M);
CPPUNIT_ASSERT_EQUAL(I2.H,I3.H);
CPPUNIT_ASSERT_EQUAL(I2.I,I3.I);
//Check if multiplication and addition works fine
ArticulatedBodyInertia I4=-2*I2 +I3+I3;
CPPUNIT_ASSERT_EQUAL(I4.M,Matrix3d::Zero().eval());
CPPUNIT_ASSERT_EQUAL(I4.H,Matrix3d::Zero().eval());
CPPUNIT_ASSERT_EQUAL(I4.I,Matrix3d::Zero().eval());
//Check if transformations work fine
//Check only rotation transformation
//back and forward
Rotation R;
random(R);
I3 = R*I2;
Map<Matrix3d> E(R.data);
Matrix3d tmp = E.transpose()*I2.M*E;
CPPUNIT_ASSERT(I3.M.isApprox(tmp));
tmp = E.transpose()*I2.H*E;
CPPUNIT_ASSERT_EQUAL(I3.H,tmp);
tmp = E.transpose()*I2.I*E;
CPPUNIT_ASSERT(I3.I.isApprox(tmp));
I4 = R.Inverse()*I3;
CPPUNIT_ASSERT(I2.M.isApprox(I4.M));
CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
//rotation and total with p=0
Frame T(R);
I4 = T*I2;
CPPUNIT_ASSERT_EQUAL(I3.M,I4.M);
CPPUNIT_ASSERT_EQUAL(I3.H,I4.H);
CPPUNIT_ASSERT_EQUAL(I3.I,I4.I);
//Check only transformation
Vector p;
random(p);
I3 = I2.RefPoint(p);
I4 = I3.RefPoint(-p);
CPPUNIT_ASSERT_EQUAL(I2.M,I4.M);
CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
T=Frame(-p);
I4 = T*I2;
CPPUNIT_ASSERT_EQUAL(I3.M,I4.M);
CPPUNIT_ASSERT_EQUAL(I3.H,I4.H);
CPPUNIT_ASSERT_EQUAL(I3.I,I4.I);
random(T);
I3=T*I2;
I4=T.Inverse()*I3;
Twist a;
random(a);
Wrench f=I2*a;
CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
random(T);
I3 = T*I2;
I4 = T.Inverse()*I3;
CPPUNIT_ASSERT(I2.M.isApprox(I4.M));
CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiantests.cpp | #include "jacobiantests.hpp"
#include "jacobiandoubletests.hpp"
#include "jacobianframetests.hpp"
int main(int argc,char** argv) {
KDL::checkDoubleOps();
KDL::checkFrameOps();
KDL::checkFrameVelOps();
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/rframestest.cpp | #include <kdl/framevel.hpp>
#include <kdl/frameacc.hpp>
#include <kdl/framevel_io.hpp>
#include <kdl/frameacc_io.hpp>
#include <kdl/test_macros.h>
using namespace KDL;
void TestVector() {
KDL_CTX;
Vector v(3,4,5);
Vector v2;
Vector vt(-5,-6,-3);
KDL_DIFF( 2*v-v, v );
KDL_DIFF( v*2-v, v );
KDL_DIFF( v+v+v-2*v, v );
v2=v;
KDL_DIFF( v, v2 );
v2+=v;
KDL_DIFF( 2*v, v2 );
v2-=v;
KDL_DIFF( v,v2);
v2.ReverseSign();
KDL_DIFF( v,-v2);
KDL_DIFF( v*vt,-vt*v);
v2 = Vector(-5,-6,-3);
KDL_DIFF( v*v2,-v2*v);
}
void TestVectorVel() {
KDL_CTX;
VectorVel v(Vector(3,-4,5),Vector(6,3,-5));
VectorVel v2;
Vector vt(-4,-6,-8);
KDL_DIFF( 2*v-v, v );
KDL_DIFF( v*2-v, v );
KDL_DIFF( v+v+v-2*v, v );
v2=v;
KDL_DIFF( v, v2 );
v2+=v;
KDL_DIFF( 2*v, v2 );
v2-=v;
KDL_DIFF( v,v2);
v2.ReverseSign();
KDL_DIFF( v,-v2);
KDL_DIFF( v*vt,-vt*v);
v2 = VectorVel(Vector(-5,-6,-3),Vector(3,4,5));
KDL_DIFF( v*v2,-v2*v);
}
void TestVectorAcc() {
KDL_CTX;
VectorAcc v(Vector(3,-4,5),Vector(6,3,-5),Vector(-4,-3,-6));
VectorAcc v2;
Vector vt(-4,-6,-8);
KDL_DIFF( 2*v-v, v );
KDL_DIFF( v*2-v, v );
KDL_DIFF( v+v+v-2*v, v );
v2=v;
KDL_DIFF( v, v2 );
v2+=v;
KDL_DIFF( 2*v, v2 );
v2-=v;
KDL_DIFF( v,v2);
v2.ReverseSign();
KDL_DIFF( v,-v2);
KDL_DIFF( v*vt,-vt*v);
v2 = VectorAcc(Vector(-5,-6,-3),Vector(-3,-4,-1),Vector(10,12,9));
KDL_DIFF( v*v2,-v2*v);
}
void TestRotation() {
KDL_CTX;
Vector v(Vector(9,4,-2));
Vector v2;
Vector vt(2,3,4);
Rotation R;
Rotation R2;
double a;
double b;
double c;
a= -15*deg2rad;
b= 20*deg2rad;
c= -80*deg2rad;
R = Rotation(Rotation::RPY(a,b,c));
R2=R;
KDL_DIFF( R,R2 );
KDL_DIFF( (R*v).Norm(), v.Norm() );
KDL_DIFF( R.Inverse(R*v), v );
KDL_DIFF( R*R.Inverse(v), v );
KDL_DIFF( R*Rotation::Identity(), R );
KDL_DIFF( Rotation::Identity()*R, R );
KDL_DIFF( R*(R*(R*v)), (R*R*R)*v );
KDL_DIFF( R*(R*(R*vt)), (R*R*R)*vt );
KDL_DIFF( R*R.Inverse(), Rotation::Identity() );
KDL_DIFF( R.Inverse()*R, Rotation::Identity() );
KDL_DIFF( R.Inverse()*v, R.Inverse(v) );
v2=v*v-2*v;
KDL_DIFF( (v2).Norm(), ::sqrt(dot(v2,v2)) );
}
void TestRotationVel() {
KDL_CTX;
VectorVel v(Vector(9,4,-2),Vector(-5,6,-2));
VectorVel v2;
Vector vt(2,3,4);
RotationVel R;
RotationVel R2;
double a;
double b;
double c;
a= -15*deg2rad;
b= 20*deg2rad;
c= -80*deg2rad;
R = RotationVel(Rotation::RPY(a,b,c),Vector(2,4,1));
R2=R;
KDL_DIFF( R,R2 );
KDL_DIFF( (R*v).Norm(), v.Norm() );
KDL_DIFF( R.Inverse(R*v), v );
KDL_DIFF( R*R.Inverse(v), v );
KDL_DIFF( R*Rotation::Identity(), R );
KDL_DIFF( Rotation::Identity()*R, R );
KDL_DIFF( R*(R*(R*v)), (R*R*R)*v );
KDL_DIFF( R*(R*(R*vt)), (R*R*R)*vt );
KDL_DIFF( R*R.Inverse(), RotationVel::Identity() );
KDL_DIFF( R.Inverse()*R, RotationVel::Identity() );
KDL_DIFF( R.Inverse()*v, R.Inverse(v) );
v2=v*v-2*v;
KDL_DIFF( (v2).Norm(), sqrt(dot(v2,v2)) );
}
void TestRotationAcc() {
KDL_CTX;
VectorAcc v(Vector(9,4,-2),Vector(-5,6,-2),Vector(2,-3,-3));
VectorAcc v2;
Vector vt(2,3,4);
RotationAcc R;
RotationAcc R2;
double a;
double b;
double c;
a= -15*deg2rad;
b= 20*deg2rad;
c= -80*deg2rad;
R = RotationAcc(Rotation::RPY(a,b,c),Vector(2,4,1),Vector(-3,-2,-1));
R2=R;
KDL_DIFF( R,R2 );
KDL_DIFF( (R*v).Norm(), v.Norm() );
KDL_DIFF( R.Inverse(R*v), v );
KDL_DIFF( R*R.Inverse(v), v );
KDL_DIFF( R*Rotation::Identity(), R );
KDL_DIFF( Rotation::Identity()*R, R );
KDL_DIFF( R*(R*(R*v)), (R*R*R)*v );
KDL_DIFF( R*(R*(R*vt)), (R*R*R)*vt );
KDL_DIFF( R*R.Inverse(), RotationAcc::Identity() );
KDL_DIFF( R.Inverse()*R, RotationAcc::Identity() );
KDL_DIFF( R.Inverse()*v, R.Inverse(v) );
v2=v*v-2*v;
KDL_DIFF( (v2).Norm(), sqrt(dot(v2,v2)) );
}
void TestFrame() {
KDL_CTX;
Vector v(3,4,5);
Vector vt(-1,0,-10);
Rotation R;
Frame F;
Frame F2;
F = Frame(Rotation::EulerZYX(10*deg2rad,20*deg2rad,-10*deg2rad),Vector(4,-2,1));
F2=F;
KDL_DIFF( F, F2 );
KDL_DIFF( F.Inverse(F*v), v );
KDL_DIFF( F.Inverse(F*vt), vt );
KDL_DIFF( F*F.Inverse(v), v );
KDL_DIFF( F*F.Inverse(vt), vt );
KDL_DIFF( F*Frame::Identity(), F );
KDL_DIFF( Frame::Identity()*F, F );
KDL_DIFF( F*(F*(F*v)), (F*F*F)*v );
KDL_DIFF( F*(F*(F*vt)), (F*F*F)*vt );
KDL_DIFF( F*F.Inverse(), Frame::Identity() );
KDL_DIFF( F.Inverse()*F, Frame::Identity() );
KDL_DIFF( F.Inverse()*vt, F.Inverse(vt) );
}
void TestFrameVel() {
KDL_CTX;
VectorVel v(Vector(3,4,5),Vector(-2,-4,-1));
Vector vt(-1,0,-10);
RotationVel R;
FrameVel F;
FrameVel F2; ;
F = FrameVel(
Frame(Rotation::EulerZYX(10*deg2rad,20*deg2rad,-10*deg2rad),Vector(4,-2,1)),
Twist(Vector(2,-2,-2),Vector(-5,-3,-2))
);
F2=F;
KDL_DIFF( F, F2 );
KDL_DIFF( F.Inverse(F*v), v );
KDL_DIFF( F.Inverse(F*vt), vt );
KDL_DIFF( F*F.Inverse(v), v );
KDL_DIFF( F*F.Inverse(vt), vt );
KDL_DIFF( F*Frame::Identity(), F );
KDL_DIFF( Frame::Identity()*F, F );
KDL_DIFF( F*(F*(F*v)), (F*F*F)*v );
KDL_DIFF( F*(F*(F*vt)), (F*F*F)*vt );
KDL_DIFF( F*F.Inverse(), FrameVel::Identity() );
KDL_DIFF( F.Inverse()*F, Frame::Identity() );
KDL_DIFF( F.Inverse()*vt, F.Inverse(vt) );
}
void TestFrameAcc() {
KDL_CTX;
VectorAcc v(Vector(3,4,5),Vector(-2,-4,-1),Vector(6,4,2));
Vector vt(-1,0,-10);
RotationAcc R;
FrameAcc F;
FrameAcc F2;
F = FrameAcc(
Frame(Rotation::EulerZYX(10*deg2rad,20*deg2rad,-10*deg2rad),Vector(4,-2,1)),
Twist(Vector(2,-2,-2),Vector(-5,-3,-2)),
Twist(Vector(5,6,2),Vector(-2,-3,1))
);
F2=F;
KDL_DIFF( F, F2 );
KDL_DIFF( F.Inverse(F*v), v );
KDL_DIFF( F.Inverse(F*vt), vt );
KDL_DIFF( F*F.Inverse(v), v );
KDL_DIFF( F*F.Inverse(vt), vt );
KDL_DIFF( F*Frame::Identity(), F );
KDL_DIFF( Frame::Identity()*F, F );
KDL_DIFF( F*(F*(F*v)), (F*F*F)*v );
KDL_DIFF( F*(F*(F*vt)), (F*F*F)*vt );
KDL_DIFF( F*F.Inverse(), FrameAcc::Identity() );
KDL_DIFF( F.Inverse()*F, Frame::Identity() );
KDL_DIFF( F.Inverse()*vt, F.Inverse(vt) );
}
void TestTwistVel() {
KDL_CTX;
// Twist
TwistVel t(VectorVel(
Vector(6,3,5),
Vector(1,4,2)
),VectorVel(
Vector(4,-2,7),
Vector(-1,-2,-3)
)
);
TwistVel t2;
RotationVel R(Rotation::RPY(10*deg2rad,20*deg2rad,-15*deg2rad),Vector(-1,5,3));
FrameVel F = FrameVel(
Frame(
Rotation::EulerZYX(-17*deg2rad,13*deg2rad,-16*deg2rad),
Vector(4,-2,1)
),
Twist(
Vector(2,-2,-2),
Vector(-5,-3,-2)
)
);
KDL_DIFF(2.0*t-t,t);
KDL_DIFF(t*2.0-t,t);
KDL_DIFF(t+t+t-2.0*t,t);
t2=t;
KDL_DIFF(t,t2);
t2+=t;
KDL_DIFF(2.0*t,t2);
t2-=t;
KDL_DIFF(t,t2);
t.ReverseSign();
KDL_DIFF(t,-t2);
KDL_DIFF(R.Inverse(R*t),t);
KDL_DIFF(R*t,R*R.Inverse(R*t));
KDL_DIFF(F.Inverse(F*t),t);
KDL_DIFF(F*t,F*F.Inverse(F*t));
KDL_DIFF(doubleVel(3.14,2)*t,t*doubleVel(3.14,2));
KDL_DIFF(t/doubleVel(3.14,2),t*(1.0/doubleVel(3.14,2)));
KDL_DIFF(t/3.14,t*(1.0/3.14));
KDL_DIFF(-t,-1.0*t);
VectorVel p1(Vector(5,1,2),Vector(4,2,1)) ;
VectorVel p2(Vector(2,0,5),Vector(-2,7,-1)) ;
KDL_DIFF(t.RefPoint(p1+p2),t.RefPoint(p1).RefPoint(p2));
KDL_DIFF(t,t.RefPoint(-p1).RefPoint(p1));
}
void TestTwistAcc() {
KDL_CTX;
// Twist
TwistAcc t( VectorAcc(Vector(6,3,5),Vector(1,4,2),Vector(5,2,1)),
VectorAcc(Vector(4,-2,7),Vector(-1,-2,-3),Vector(5,2,9) )
);
TwistAcc t2;
RotationAcc R(Rotation::RPY(10*deg2rad,20*deg2rad,-15*deg2rad),
Vector(-1,5,3),
Vector(2,1,3)
) ;
FrameAcc F = FrameAcc(
Frame(Rotation::EulerZYX(-17*deg2rad,13*deg2rad,-16*deg2rad),Vector(4,-2,1)),
Twist(Vector(2,-2,-2),Vector(-5,-3,-2)),
Twist(Vector(5,4,-5),Vector(12,13,17))
);
KDL_DIFF(2.0*t-t,t);
KDL_DIFF(t*2.0-t,t);
KDL_DIFF(t+t+t-2.0*t,t);
t2=t;
KDL_DIFF(t,t2);
t2+=t;
KDL_DIFF(2.0*t,t2);
t2-=t;
KDL_DIFF(t,t2);
t.ReverseSign();
KDL_DIFF(t,-t2);
KDL_DIFF(R.Inverse(R*t),t);
KDL_DIFF(R*t,R*R.Inverse(R*t));
KDL_DIFF(F.Inverse(F*t),t);
KDL_DIFF(F*t,F*F.Inverse(F*t));
KDL_DIFF(doubleAcc(3.14,2,3)*t,t*doubleAcc(3.14,2,3));
KDL_DIFF(t/doubleAcc(3.14,2,7),t*(1.0/doubleAcc(3.14,2,7)));
KDL_DIFF(t/3.14,t*(1.0/3.14));
KDL_DIFF(-t,-1.0*t);
VectorAcc p1(Vector(5,1,2),Vector(4,2,1),Vector(2,1,3));
VectorAcc p2(Vector(2,0,5),Vector(-2,7,-1),Vector(-3,2,-1));
KDL_DIFF(t.RefPoint(p1+p2),t.RefPoint(p1).RefPoint(p2));
KDL_DIFF(t,t.RefPoint(-p1).RefPoint(p1));
}
int main() {
KDL_CTX;
TestVector();
TestRotation();
TestFrame();
TestVectorVel();
TestRotationVel();
TestFrameVel();
TestVectorAcc();
TestRotationAcc();
TestFrameAcc();
TestTwistVel();
TestTwistAcc();
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiandoubletests.cpp | #include "jacobiandoubletests.hpp"
namespace KDL {
void checkDoubleOps() {
KDL_CTX;
checkUnary<OpTan,double>::check();
checkUnary<OpExp,double>::check();
checkUnary<OpSin,double>::check();
checkUnary<OpCos,double>::check();
checkUnary<OpLog,double>::check(&posrandom);
checkUnary<OpAtan,double>::check();
checkUnary<OpAsin,double>::check(&random,1E-8,1E-3);
checkUnary<OpAcos,double>::check(&random,1E-8,1E-3);
checkUnary<OpSqrt,double>::check(&posrandom);
checkBinary<OpMult,double,double>::check();
checkBinary<OpAtan2,double,double>::check(1E-8,1E-3);
}
/*
void checkDoubleCodeSize() {
PV<double> a(2);
PV<double> b(2);
PV<double> res(2);
random(a);
random(b);
checkDoubleCodeSizeMult(a,b,res);
}
** VISUAL C++ assembler code :
* Shows that there is little overhead from the framework
* There is some overhead because of the isConstant() tests, but this pays itself back
* if one deals with e.g. Frames or higher number of derivatives.
*
?checkDoubleCodeSizeMult@@YAXABV?$PV@N@@0AAV1@@Z PROC NEAR ; checkDoubleCodeSizeMult, COMDAT
; 60 : res = a*b;
mov ecx, DWORD PTR _b$[esp-4]
mov edx, DWORD PTR _res$[esp-4]
push esi
mov esi, DWORD PTR _a$[esp]
fld QWORD PTR [esi]
mov al, BYTE PTR [esi+16]
test al, al
fmul QWORD PTR [ecx]
push edi
fstp QWORD PTR [edx]
je SHORT $L13435
mov al, BYTE PTR [ecx+16]
test al, al
je SHORT $L13435
mov eax, 1
jmp SHORT $L13436
$L13435:
xor eax, eax
$L13436:
test al, al
mov BYTE PTR [edx+16], al
jne SHORT $L13419
mov edi, DWORD PTR [edx+12]
xor eax, eax
test edi, edi
jle SHORT $L13419
mov edx, DWORD PTR [edx+8]
push ebx
$L13417:
mov bl, BYTE PTR [esi+16]
test bl, bl
je SHORT $L13446
mov ebx, DWORD PTR [ecx+8]
fld QWORD PTR [ebx+eax*8]
fmul QWORD PTR [esi]
jmp SHORT $L13445
$L13446:
mov bl, BYTE PTR [ecx+16]
test bl, bl
je SHORT $L13447
mov ebx, DWORD PTR [esi+8]
fld QWORD PTR [ebx+eax*8]
fmul QWORD PTR [ecx]
jmp SHORT $L13445
$L13447:
mov ebx, DWORD PTR [ecx+8]
fld QWORD PTR [ebx+eax*8]
mov ebx, DWORD PTR [esi+8]
fmul QWORD PTR [esi]
fld QWORD PTR [ebx+eax*8]
fmul QWORD PTR [ecx]
faddp ST(1), ST(0)
$L13445:
fstp QWORD PTR [edx+eax*8]
inc eax
cmp eax, edi
jl SHORT $L13417
pop ebx
$L13419:
pop edi
pop esi
; 61 : }
*
void checkDoubleCodeSizeMult(const PV<double>& a,const PV<double>& b,PV<double>& res) {
res = a*b;
}*/
} // namespace
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/solvertest.hpp | #ifndef KDL_SOLVER_TEST_HPP
#define KDL_SOLVER_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <chain.hpp>
#include <chainfksolverpos_recursive.hpp>
#include <chainfksolvervel_recursive.hpp>
#include <chainiksolvervel_pinv.hpp>
#include <chainiksolvervel_pinv_givens.hpp>
#include <chainiksolvervel_wdls.hpp>
#include <chainiksolverpos_nr.hpp>
#include <chainjnttojacsolver.hpp>
#include <chainidsolver_vereshchagin.hpp>
using namespace KDL;
class SolverTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( SolverTest);
CPPUNIT_TEST(FkPosAndJacTest );
CPPUNIT_TEST(FkVelAndJacTest );
CPPUNIT_TEST(FkVelAndIkVelTest );
CPPUNIT_TEST(FkPosAndIkPosTest );
CPPUNIT_TEST(VereshchaginTest );
CPPUNIT_TEST(IkSingularValueTest );
CPPUNIT_TEST(IkVelSolverWDLSTest );
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void FkPosAndJacTest();
void FkVelAndJacTest();
void FkVelAndIkVelTest();
void FkPosAndIkPosTest();
void VereshchaginTest();
void IkSingularValueTest() ;
void IkVelSolverWDLSTest();
private:
Chain chain1,chain2,chain3,chain4, chaindyn,motomansia10;
void FkPosAndJacLocal(Chain& chain,ChainFkSolverPos& fksolverpos,ChainJntToJacSolver& jacsolver);
void FkVelAndJacLocal(Chain& chain, ChainFkSolverVel& fksolvervel, ChainJntToJacSolver& jacsolver);
void FkVelAndIkVelLocal(Chain& chain, ChainFkSolverVel& fksolvervel, ChainIkSolverVel& iksolvervel);
void FkPosAndIkPosLocal(Chain& chain,ChainFkSolverPos& fksolverpos, ChainIkSolverPos& iksolverpos);
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/inertiatest.hpp | #ifndef INERTIA_TEST_HPP
#define INERTIA_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
class InertiaTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( InertiaTest);
CPPUNIT_TEST(TestRotationalInertia);
CPPUNIT_TEST(TestRigidBodyInertia);
CPPUNIT_TEST(TestArticulatedBodyInertia);
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void TestRotationalInertia();
void TestRigidBodyInertia();
void TestArticulatedBodyInertia();
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiantests.hpp | #ifndef PVTESTS_H
#define PVTESTS_H
#include <kdl/jacobianexpr.hpp>
#include <kdl/test_macros.h>
#include <iostream>
#include <string>
#include <iomanip>
namespace KDL {
template <typename T>
void random(Jacobian<T>& rv) {
random(rv.value());
for (int i=0;i<rv.nrOfDeriv();++i) {
random(rv.deriv(i));
}
}
template <typename T>
void posrandom(Jacobian<T>& rv) {
posrandom(rv.value());
for (int i=0;i<rv.nrOfDeriv();++i) {
posrandom(rv.deriv(i));
}
}
template <typename T>
inline void checkEqual(const T& a,const T& b,double eps) {
KDL_CTX;
KDL_DIFF(a,b);
assert(Equal(a,b,eps));
}
template <typename OpID,typename A>
class checkUnary {
typedef UnaryOp<OpID,A> myOp;
public:
inline static void check(void (*rnd)(Jacobian<A>&) = &random,double dt=1E-8,double eps=1E-4,int size=1) {
KDL_CTX;
Jacobian<A> a(size);
rnd(a);
KDL_ARG1(a);
int i;
for (i=0;i<a.nrOfDeriv();++i) {
checkEqual(
myOp::deriv(a.value(),a.deriv(i)),
diff(
myOp::value(a.value()),
myOp::value(
addDelta(a.value(),a.deriv(i),dt)
),
dt),
eps
);
}
}
};
template <typename OpID,typename A>
class checkUnaryVel {
typedef UnaryOp<OpID,A> myOp;
public:
inline static void check(void (*rnd)(Jacobian<A>&) = &random,double dt=1E-8,double eps=1E-4,int size=1) {
KDL_CTX;
Jacobian<A> a(size);
rnd(a);
KDL_ARG1(a);
int i;
for (i=0;i<a.nrOfDeriv();++i) {
KDL_MSG("testing value() components of deriv ");
checkEqual(
myOp::deriv(a.value(),a.deriv(i)).value(),
diff(
myOp::value(a.value()),
myOp::value(
addDelta(a.value(),a.deriv(i).value(),dt)
),
dt),
eps
);
typename Traits<A>::derivType d1(
addDelta(a.deriv(i).value(), a.deriv(i).deriv(),dt));
typename Traits<A>::valueType a1(
addDelta(a.value(),a.deriv(i).value(),dt)
);
KDL_MSG("testing deriv() components of deriv ");
checkEqual(
myOp::deriv(a.value(),a.deriv(i)).deriv(),
diff(
myOp::deriv(a.value(),a.deriv(i)).value(),
myOp::deriv(a1, d1).value(),
dt),
eps
);
}
}
};
template <typename OpID,typename A,typename B>
class checkBinary {
typedef BinaryOp<OpID,A,B> myOp;
public:
inline static void check(double dt=1E-8,double eps=1E-4,int size=1) {
KDL_CTX;
Jacobian<A> a(size);
random(a);
Jacobian<B> b(size);
random(b);
KDL_ARG2(a,b);
int i;
for (i=0;i<a.nrOfDeriv();++i) {
checkEqual(
myOp::derivVV(a.value(),a.deriv(i),b.value(),b.deriv(i)),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i),dt),
addDelta(b.value(),b.deriv(i),dt)
),
dt),
eps
);
checkEqual(
myOp::derivVC(a.value(),a.deriv(i),b.value()),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i),dt),
b.value()
),
dt),
eps
);
checkEqual(
myOp::derivCV(a.value(),b.value(),b.deriv(i)),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
a.value(),
addDelta(b.value(),b.deriv(i),dt)
),
dt),
eps
);
}
}
};
template <typename OpID,typename A,typename B>
class checkBinary_displ {
typedef BinaryOp<OpID,A,B> myOp;
public:
inline static void check(double dt=1E-8,double eps=1E-4,int size=1) {
KDL_CTX;
Jacobian<A> a(size);
random(a);
Jacobian<B> b(size);
random(b);
KDL_ARG2(a,b);
int i;
for (i=0;i<a.nrOfDeriv();++i) {
checkEqual(
myOp::derivVV(a.value(),a.deriv(i),b.value(),b.deriv(i)),
diff_displ(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i),dt),
addDelta(b.value(),b.deriv(i),dt)
),
dt),
eps
);
checkEqual(
myOp::derivVC(a.value(),a.deriv(i),b.value()),
diff_displ(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i),dt),
b.value()
),
dt),
eps
);
checkEqual(
myOp::derivCV(a.value(),b.value(),b.deriv(i)),
diff_displ(
myOp::value(a.value(),b.value()),
myOp::value(
a.value(),
addDelta(b.value(),b.deriv(i),dt)
),
dt),
eps
);
}
}
};
template <typename OpID,typename A,typename B>
class checkBinaryVel {
typedef BinaryOp<OpID,A,B> myOp;
public:
inline static void check(double dt=1E-8,double eps=1E-4,int size=1) {
KDL_CTX;
Jacobian<A> a(size);
random(a);
Jacobian<B> b(size);
random(b);
KDL_ARG2(a,b);
int i;
for (i=0;i<a.nrOfDeriv();++i) {
//A Avalue = A(a.value(),a.deriv(i).value());
//B Bvalue = B(b.value(),b.deriv(i).value());
KDL_MSG("testing value() component of derivVV ");
checkEqual(
myOp::derivVV(a.value(),a.deriv(i),b.value(),b.deriv(i)).value(),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i).value(),dt),
addDelta(b.value(),b.deriv(i).value(),dt)
),
dt),
eps
);
typename Traits<A>::derivType da1(
addDelta(a.deriv(i).value(), a.deriv(i).deriv(),dt));
typename Traits<A>::valueType a1(
addDelta(a.value(),a.deriv(i).value(),dt)
);
typename Traits<B>::derivType db1(
addDelta(b.deriv(i).value(), b.deriv(i).deriv(),dt));
typename Traits<B>::valueType b1(
addDelta(b.value(),b.deriv(i).value(),dt)
);
KDL_MSG("testing deriv() components of derivVV ");
checkEqual(
myOp::derivVV(a.value(),a.deriv(i),b.value(),b.deriv(i)).deriv(),
diff(
myOp::derivVV(a.value(),a.deriv(i),b.value(),b.deriv(i)).value(),
myOp::derivVV(a1, da1,b1,db1).value(),
dt),
eps
);
KDL_MSG("testing deriv() components of derivVC ");
checkEqual(
myOp::derivVC(a.value(),a.deriv(i),b.value()).deriv(),
diff(
myOp::derivVC(a.value(),a.deriv(i),b.value()).value(),
myOp::derivVC(a1, da1,b.value()).value(),
dt),
eps
);
KDL_MSG("testing deriv() components of derivCV ");
checkEqual(
myOp::derivCV(a.value(),b.value(),b.deriv(i)).deriv(),
diff(
myOp::derivCV(a.value(),b.value(),b.deriv(i)).value(),
myOp::derivCV(a.value(),b1,db1).value(),
dt),
eps
);
KDL_MSG("testing value() components of derivVC ");
checkEqual(
myOp::derivVC(a.value(),a.deriv(i),b.value()).value(),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
addDelta(a.value(),a.deriv(i).value(),dt),
b.value()
),
dt),
eps
);
KDL_MSG("testing value() components of derivCV ");
checkEqual(
myOp::derivCV(a.value(),b.value(),b.deriv(i)).value(),
diff(
myOp::value(a.value(),b.value()),
myOp::value(
a.value(),
addDelta(b.value(),b.deriv(i).value(),dt)
),
dt),
eps
);
}
}
};
} // namespace
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobianframetests.hpp | #ifndef PVFramesTests_H
#define PVFramesTests_H
#include <kdl/jacobianexpr.hpp>
#include <kdl/jacobianframe.hpp>
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include "jacobiantests.hpp"
#include "jacobiandoubletests.hpp"
namespace KDL {
void checkDiffs();
void checkFrameOps();
void checkFrameVelOps();
}
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/kinfamtest.hpp | #ifndef KINFAM_TEST_HPP
#define KINFAM_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <frames.hpp>
#include <joint.hpp>
#include <segment.hpp>
#include <chain.hpp>
#include <tree.hpp>
using namespace KDL;
class KinFamTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( KinFamTest);
CPPUNIT_TEST( JointTest );
CPPUNIT_TEST( SegmentTest );
CPPUNIT_TEST( ChainTest );
CPPUNIT_TEST( TreeTest );
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void JointTest();
void SegmentTest();
void ChainTest();
void TreeTest();
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/framestest.hpp | #ifndef FRAMES_TEST_HPP
#define FRAMES_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <frames.hpp>
#include <jntarray.hpp>
using namespace KDL;
class FramesTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( FramesTest);
CPPUNIT_TEST(TestVector);
CPPUNIT_TEST(TestTwist);
CPPUNIT_TEST(TestWrench);
CPPUNIT_TEST(TestRotation);
CPPUNIT_TEST(TestQuaternion);
CPPUNIT_TEST(TestFrame);
CPPUNIT_TEST(TestJntArray);
CPPUNIT_TEST(TestRotationDiff);
CPPUNIT_TEST(TestEuler);
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void TestVector();
void TestTwist();
void TestWrench();
void TestRotation();
void TestQuaternion();
void TestFrame();
void TestJntArray();
void TestJntArrayWhenEmpty();
void TestRotationDiff();
void TestEuler();
private:
void TestVector2(Vector& v);
void TestTwist2(Twist& t);
void TestWrench2(Wrench& w);
void TestRotation2(const Vector& v,double a,double b,double c);
void TestOneRotation(const std::string& msg,
const KDL::Rotation& R,
const double expectedAngle,
const KDL::Vector& expectedAxis);
void TestArbitraryRotation(const std::string& msg,
const KDL::Vector& v,
const double angle,
const double expectedAngle,
const KDL::Vector& expectedVector);
void TestRangeArbitraryRotation(const std::string& msg,
const KDL::Vector& v,
const KDL::Vector& expectedVector);
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/toolkittest.cpp |
#include"kdl/kdltk/toolkit.hpp"
#include<kdl/kinfam/joint_io.hpp>
#include<kdl/kinfam/joint.hpp>
#include<rtt/os/main.h>
#include<rtt/Logger.hpp>
#include<rtt/TaskContext.hpp>
#include<kdl/kinfam/kuka361.hpp>
#include<kdl/kinfam/unittransmission.hpp>
#include<kdl/kinfam/lineartransmission.hpp>
using namespace RTT;
using namespace KDL;
using namespace std;
int ORO_main(int argc, char** argv)
{
RTT::Toolkit::Import(KDLToolkit);
TaskContext writer("writer");
int retval = 0;
JointTransX tx(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
JointTransY ty(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
JointTransZ tz(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
JointRotX rx(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
JointRotY ry(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
JointRotZ rz(Frame(Rotation::RPY(1,2,3),Vector(1,2,3)));
Property<JointTransX> tx_prop("joint1","first joint",tx);
Property<JointTransY> ty_prop("joint2","second joint",ty);
Property<JointTransZ> tz_prop("joint3","third joint",tz);
Property<JointRotX> rx_prop("joint4","fourth joint",rx);
Property<JointRotY> ry_prop("joint5","fifth joint",ry);
Property<JointRotZ> rz_prop("joint6","sixth joint",rz);
Kuka361 kuka = Kuka361();
SerialChain* robot = kuka.createSerialChain();
LinearTransmission ltrans = LinearTransmission(6,vector<double>(6,1),vector<double>(6,0.5));
Property<LinearTransmission> ltrans_prop("transmission","some transmission",ltrans);
UnitTransmission utrans = UnitTransmission(6);
Property<UnitTransmission> utrans_prop("transmission2","some other transmission",utrans);
Property<SerialChain> kuka_prop("testchain","some chain",*(robot));
Property<ZXXZXZ> kuka_prop2("testchain2","some other chain",kuka);
writer.properties()->addProperty(&tx_prop);
writer.properties()->addProperty(&ty_prop);
writer.properties()->addProperty(&tz_prop);
writer.properties()->addProperty(&rx_prop);
writer.properties()->addProperty(&ry_prop);
writer.properties()->addProperty(&rz_prop);
writer.properties()->addProperty(<rans_prop);
writer.properties()->addProperty(&utrans_prop);
writer.properties()->addProperty(&kuka_prop);
writer.properties()->addProperty(&kuka_prop2);
writer.marshalling()->writeProperties("test.cpf");
writer.marshalling()->readProperties("test.cpf");
Logger::In in("KDLToolkitTest");
if(tx_prop.value().getType()!=tx.getType()||!Equal(tx_prop.value().frame_before_joint(),tx.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<tx_prop.value()<<" ,actual type: "<<tx<<endlog();
retval=-1;
}
if(ty_prop.value().getType()!=ty.getType()||!Equal(ty_prop.value().frame_before_joint(),ty.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<ty_prop.value()<<" ,actual type: "<<ty<<endlog();
retval=-1;
}
if(tz_prop.value().getType()!=tz.getType()||!Equal(tz_prop.value().frame_before_joint(),tz.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<tz_prop.value()<<" ,actual type: "<<tz<<endlog();
retval=-1;
}
if(rx_prop.value().getType()!=rx.getType()||!Equal(rx_prop.value().frame_before_joint(),rx.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<rx_prop.value()<<" ,actual type: "<<rx<<endlog();
retval=-1;
}
if(ry_prop.value().getType()!=ry.getType()||!Equal(ry_prop.value().frame_before_joint(),ry.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<ry_prop.value()<<" ,actual type: "<<ry<<endlog();
retval=-1;
}
if(rz_prop.value().getType()!=rz.getType()||!Equal(rz_prop.value().frame_before_joint(),rz.frame_before_joint(),1e-5)){
log(Error)<<"Property is not the same after writing and rereading"<<endlog();
log(Debug)<<"Property "<<rz_prop.value()<<" ,actual type: "<<rz<<endlog();
retval=-1;
}
delete robot;
return retval;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/jacobiantest.cpp | #include "jacobiantest.hpp"
#include <kinfam_io.hpp>
#include <Eigen/Core>
CPPUNIT_TEST_SUITE_REGISTRATION(JacobianTest);
using namespace KDL;
void JacobianTest::setUp(){}
void JacobianTest::tearDown(){}
void JacobianTest::TestChangeRefPoint(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random Vector
Vector p;
random(p);
Jacobian j2(5);
CPPUNIT_ASSERT(changeRefPoint(j1,p,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeRefPoint(j1,p,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeRefPoint(j2,-p,j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestChangeRefFrame(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random frame
Frame f;
random(f);
Jacobian j2(5);
CPPUNIT_ASSERT(changeRefFrame(j1,f,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeRefFrame(j1,f,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeRefFrame(j2,f.Inverse(),j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestChangeBase(){
//Create a random jacobian
Jacobian j1(5);
j1.data.setRandom();
//Create a random rotation
Rotation r;
random(r);
Jacobian j2(5);
CPPUNIT_ASSERT(changeBase(j1,r,j2));
CPPUNIT_ASSERT(j1!=j2);
Jacobian j3(4);
CPPUNIT_ASSERT(!changeBase(j1,r,j3));
j3.resize(5);
CPPUNIT_ASSERT(changeBase(j2,r.Inverse(),j3));
CPPUNIT_ASSERT_EQUAL(j1,j3);
}
void JacobianTest::TestConstructor(){
//Create an empty Jacobian
Jacobian j1(2);
//Get size
CPPUNIT_ASSERT_EQUAL(j1.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j1.columns(),(unsigned int)2);
//Create a second Jacobian from empty
Jacobian j2(j1);
//Get size
CPPUNIT_ASSERT_EQUAL(j2.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j2.columns(),(unsigned int)2);
Jacobian j3=j1;
//Get size
CPPUNIT_ASSERT_EQUAL(j3.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j3.columns(),(unsigned int)2);
//Test resize
j1.resize(5);
//Get size
CPPUNIT_ASSERT_EQUAL(j1.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j1.columns(),(unsigned int)5);
j2=j1;
//Get size
CPPUNIT_ASSERT_EQUAL(j2.rows(),(unsigned int)6);
CPPUNIT_ASSERT_EQUAL(j2.columns(),(unsigned int)5);
}
void JacobianTest::TestGetSetColumn(){}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/serialchaintest.cpp | #include <kdl/kinfam/serialchain.hpp>
#include <kdl/frames.hpp>
#include <kdl/framevel.hpp>
#include <kdl/frames_io.hpp>
#include <kdl/kinfam/crs450.hpp>
#include <kdl/kinfam/kuka160.hpp>
#include <kdl/kinfam/serialchaincartpos2jnt.hpp>
#include <kdl/kinfam/lineartransmission.hpp>
using namespace KDL;
void CompareFamilies(KinematicFamily* KF1,KinematicFamily* KF2) {
Jnt2CartPos* jnt2cartpos1 = KF1->createJnt2CartPos();
Jnt2CartPos* jnt2cartpos2 = KF2->createJnt2CartPos();
JointVector q(6);
q[0] = 0*KDL::deg2rad;
q[1] = 10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = 30*KDL::deg2rad;
q[4] = 40*KDL::deg2rad;
q[5] = 50*KDL::deg2rad;
Frame F1,F2;
jnt2cartpos1->evaluate(q);
jnt2cartpos1->getFrame(F1);
jnt2cartpos2->evaluate(q);
jnt2cartpos2->getFrame(F2);
if (!Equal(F1,F2,1E-7)) {
std::cout << "the two kinematic families do not give the same result." << std::endl;
std::cout << "Result of first kinematic family " << std::endl;
std::cout << F1 << std::endl;
std::cout << "Result of second kinematic family " << std::endl;
std::cout << F2 << std::endl;
exit(1);
}
delete jnt2cartpos1;
delete jnt2cartpos2;
}
//
// Test whether Jnt2CartPos and CartPos2Jnt give a consistent result.
//
class TestForwardAndInverse {
KinematicFamily* family;
Jnt2CartPos* jnt2cartpos;
Frame F_base_ee;
Frame F_base_ee2;
JointVector q_solved;
JointVector q_initial;
public:
CartPos2Jnt* cartpos2jnt;
public:
static void TestFamily(KinematicFamily* _family) {
JointVector q_initial(6);
q_initial[0] = 0*KDL::deg2rad;
q_initial[1] = 0*KDL::deg2rad;
q_initial[2] = 90*KDL::deg2rad;
q_initial[3] = 0*KDL::deg2rad;
q_initial[4] = 90*KDL::deg2rad;
q_initial[5] = 0*KDL::deg2rad;
TestForwardAndInverse testobj(_family,q_initial);
JointVector q(6);
q[0] = 0*KDL::deg2rad;
q[1] = 10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = 30*KDL::deg2rad;
q[4] = 40*KDL::deg2rad;
q[5] = 50*KDL::deg2rad;
testobj.test(q);
//std::cout << "number of iterations " << ((SerialChainCartPos2Jnt*)testobj.cartpos2jnt)->iter << std::endl;
q[0] = -10*KDL::deg2rad;
q[1] = -10*KDL::deg2rad;
q[2] = 40*KDL::deg2rad;
q[3] = -30*KDL::deg2rad;
q[4] = 20*KDL::deg2rad;
q[5] = 60*KDL::deg2rad;
testobj.test(q);
//std::cout << "number of iterations " << ((SerialChainCartPos2Jnt*)testobj.cartpos2jnt)->iter << std::endl;
}
//
// Test whether Jnt2CartPos and Jnt2Jac give consistent
// results.
//
class TestForwardPosAndJac {
KinematicFamily* family;
Jnt2CartPos* jnt2cartpos;
Jnt2Jac* jnt2jac;
Jacobian<Frame> FJ_base_ee;
Frame F_base_ee1;
Frame F_base_ee2;
public:
static void TestFamily(KinematicFamily* _family) {
TestForwardPosAndJac testobj(_family);
JointVector q(6);
q[0] = 0*KDL::deg2rad;
q[1] = 10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = 30*KDL::deg2rad;
q[4] = 40*KDL::deg2rad;
q[5] = 50*KDL::deg2rad;
testobj.test(q);
q[0] = -50*KDL::deg2rad;
q[1] = -10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = -30*KDL::deg2rad;
q[4] = 20*KDL::deg2rad;
q[5] = 110*KDL::deg2rad;
testobj.test(q);
}
TestForwardPosAndJac(KinematicFamily* _family) :
family(_family),
jnt2cartpos(_family->createJnt2CartPos()),
jnt2jac(_family->createJnt2Jac()),
FJ_base_ee(_family->nrOfJoints())
{
// the transformations should exist :
assert( jnt2jac != 0);
assert( jnt2cartpos != 0);
}
int test(JointVector& q) {
double deltaq = 1E-4;
double epsJ = 1E-4;
if (jnt2jac->evaluate(q)!=0) return 1;
jnt2jac->getJacobian(FJ_base_ee);
for (int i=0; i< q.size() ;i++) {
// test the derivative of J towards qi
double oldqi = q[i];
q[i] = oldqi+deltaq;
if (jnt2cartpos->evaluate(q)!=0) return 1;
jnt2cartpos->getFrame(F_base_ee2);
q[i] = oldqi-deltaq;
if (jnt2cartpos->evaluate(q)!=0) return 1;
jnt2cartpos->getFrame(F_base_ee1);
q[i] = oldqi;
// check Jacobian :
Twist Jcol = diff(F_base_ee1,F_base_ee2,2*deltaq);
if (!Equal(Jcol,FJ_base_ee.deriv(i),epsJ)) {
std::cout << "Difference between symbolic and numeric calculation of Jacobian for column "
<< i << std::endl;
std::cout << "Numeric " << Jcol << std::endl;
std::cout << "Symbolic " << FJ_base_ee.deriv(i) << std::endl;
exit(1);
}
}
}
~TestForwardPosAndJac() {
delete jnt2cartpos;
delete jnt2jac;
}
};
//
// Test whether Jnt2CartVel and Jnt2Jac give consistent
// results.
//
class TestCartVelAndJac {
KinematicFamily* family;
Jnt2CartVel* jnt2cartvel;
Jnt2Jac* jnt2jac;
Jacobian<Frame> FJ_base_ee;
FrameVel F_base_ee;
public:
static void TestFamily(KinematicFamily* _family) {
TestCartVelAndJac testobj(_family);
JointVector qdot(6);
qdot[0] = 0.1;
qdot[1] = 0.2;
qdot[2] = -0.3;
qdot[3] = 0.4;
qdot[4] = -0.5;
qdot[5] = 0.6;
JointVector q(6);
q[0] = 0*KDL::deg2rad;
q[1] = 10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = 30*KDL::deg2rad;
q[4] = 40*KDL::deg2rad;
q[5] = 50*KDL::deg2rad;
std::cout << "q[1] = " << q[1] << std::endl;
testobj.test(q,qdot);
q[0] = -50*KDL::deg2rad;
q[1] = -10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = -30*KDL::deg2rad;
q[4] = 20*KDL::deg2rad;
q[5] = 110*KDL::deg2rad;
testobj.test(q,qdot);
}
TestCartVelAndJac(KinematicFamily* _family) :
family(_family),
jnt2cartvel(_family->createJnt2CartVel()),
jnt2jac(_family->createJnt2Jac()),
FJ_base_ee(_family->nrOfJoints())
{
// the transformations should exist :
assert( jnt2jac != 0);
assert( jnt2cartvel != 0);
}
int test(JointVector& q,JointVector& qdot) {
std::cout << "Testing wether Jnt2CartVel and Jnt2Jac are consistent " << std::endl;
std::cout << "q[1] = " << q[1] << std::endl;
double deltaq = 1E-4;
double epsJ = 1E-4;
int result;
result = jnt2jac->evaluate(q);
assert(result==0);
jnt2jac->getJacobian(FJ_base_ee);
result = jnt2cartvel->evaluate(q,qdot);
jnt2cartvel->getFrameVel(F_base_ee);
assert(result==0);
Twist t = Twist::Zero();
for (int i=0; i< q.size() ;i++) {
t += FJ_base_ee.deriv(i)*qdot[i];
}
if (!Equal(t,F_base_ee.GetTwist(),1E-6)) {
std::cout << "Difference between the resuls"<< std::endl;
std::cout << "via the Jacobian " << t << std::endl;
std::cout << "via the jnt2cartvel transformation " << F_base_ee.GetTwist() << std::endl;
exit(1);
}
}
~TestCartVelAndJac() {
delete jnt2cartvel;
delete jnt2jac;
}
};
//
// Test whether Jnt2CartVel and CartVel2Jnt give consistent
// results.
//
class TestCartVelAndInverse {
KinematicFamily* family;
Jnt2CartVel* jnt2cartvel;
CartVel2Jnt* cartvel2jnt;
FrameVel F_base_ee;
JointVector qdot2;
public:
static void TestFamily(KinematicFamily* _family) {
TestCartVelAndInverse testobj(_family);
JointVector qdot(6);
qdot[0] = 0.1;
qdot[1] = 0.2;
qdot[2] = -0.3;
qdot[3] = 0.4;
qdot[4] = -0.5;
qdot[5] = 0.6;
JointVector q(6);
q[0] = 0*KDL::deg2rad;
q[1] = 10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = 30*KDL::deg2rad;
q[4] = 40*KDL::deg2rad;
q[5] = 50*KDL::deg2rad;
testobj.test(q,qdot);
q[0] = -50*KDL::deg2rad;
q[1] = -10*KDL::deg2rad;
q[2] = 20*KDL::deg2rad;
q[3] = -30*KDL::deg2rad;
q[4] = 20*KDL::deg2rad;
q[5] = 110*KDL::deg2rad;
testobj.test(q,qdot);
}
TestCartVelAndInverse(KinematicFamily* _family) :
family(_family),
jnt2cartvel(_family->createJnt2CartVel()),
cartvel2jnt(_family->createCartVel2Jnt()),
qdot2(_family->nrOfJoints())
{
// the transformations should exist :
assert( cartvel2jnt != 0);
assert( jnt2cartvel != 0);
}
int test(const JointVector& q,const JointVector& qdot) {
std::cout << "Testing wether Jnt2CartVel and CartVel2Jnt are consistent " << std::endl;
double epsJ = 1E-7;
int result;
result = jnt2cartvel->evaluate(q,qdot);
assert(result==0);
jnt2cartvel->getFrameVel(F_base_ee);
cartvel2jnt->setTwist(F_base_ee.GetTwist());
result = cartvel2jnt->evaluate(q, qdot2);
assert(result==0);
for (int i=0;i<qdot.size();++i) {
if (fabs(qdot[i]-qdot2[i])>epsJ) {
std::cout << " original joint velocities and calculated joint velocities do not match" << std::endl;
//std::cerr << " original joint velocities and calculated joint velocities do not match" << std::endl;
for (int j=0;j<qdot.size();j++) {
std::cout << "qdot["<<j<<"]="<<qdot[j]<<" and qdot2["<<j<<"]="<<qdot2[j] << std::endl;
}
std::cout << "Frame : " << F_base_ee.GetFrame() << std::endl;
std::cout << "Twist : " << F_base_ee.GetTwist() << std::endl;
exit(1);
}
}
}
~TestCartVelAndInverse() {
delete jnt2cartvel;
delete cartvel2jnt;
}
};
/**
* a kinematic family class with some non-trivial linear transmission.
*/
class CRS450_exp: public SerialChain {
public:
explicit CRS450_exp(int jointoffset=0) :
SerialChain("CRS450", 6, jointoffset,new LinearTransmission(6) )
{
double L1 = 0.33;
double L2 = 0.305;
double L3 = 0.33;
double L4 = 0.176;
LinearTransmission* tr = (LinearTransmission*)transmission;
tr->setTransmission(2,2.0,1.0);
tr->setTransmission(3,3.0,2.0);
addJoint(new JointRotZ(Frame::Identity())); // j1
addJoint(new JointRotY(Frame(Rotation::Identity(),Vector(0,0,L1))));// j2
addJoint(new JointRotY(Frame(Rotation::Identity(),Vector(0,0,L2))));// j3
addJoint(new JointRotZ(Frame(Rotation::Identity(),Vector(0,0,0)))); // j4
addJoint(new JointRotY(Frame(Rotation::Identity(),Vector(0,0,L3))));// j5
addJoint(new JointRotZ(Frame(Rotation::Identity(),Vector(0,0,0)))); // j6
setLastJointToEE(Frame(Rotation::Identity(),Vector(0,0,L4)));
};
};
int main(int argc,char* argv[]) {
KinematicFamily* family1,*family2,*family3,*family4;
std::cout << std::endl << "Tests on CRS450 " << std::endl;
family1 = new CRS450();
TestForwardAndInverse::TestFamily(family1);
TestForwardPosAndJac::TestFamily(family1);
TestCartVelAndJac::TestFamily(family1);
TestCartVelAndInverse::TestFamily(family1);//
std::cout <<std::endl << "Tests on CRS450_exp " << std::endl;
family2 = new CRS450_exp();
TestForwardAndInverse::TestFamily(family2);
TestForwardPosAndJac::TestFamily(family2);
TestCartVelAndJac::TestFamily(family2);
TestCartVelAndInverse::TestFamily(family2);//
std::cout << std::endl << "Tests on CRS450Feath " << std::endl;
family3 = new CRS450Feath();
TestForwardAndInverse::TestFamily(family3);
TestForwardPosAndJac::TestFamily(family3);
TestCartVelAndJac::TestFamily(family3);
TestCartVelAndInverse::TestFamily(family3);//
std::cout << std::endl << "Comparing the kinematic families "<< std::endl;
CompareFamilies(family1,family3);
std::cout << std::endl << "Tests on CRS450Feath->createSerialChain " << std::endl;
family4 = ((ZXXZXZ*)family3)->createSerialChain();
TestForwardAndInverse::TestFamily(family4);
TestForwardPosAndJac::TestFamily(family4);
TestCartVelAndJac::TestFamily(family4);
TestCartVelAndInverse::TestFamily(family4);//
// testing the clone functionality (valgrind)
KinematicFamily* family1b,*family2b,*family3b,*family4b;
family1b = family1->clone();
family2b = family2->clone();
family3b = family3->clone();
family4b = family4->clone();
delete family4;
delete family3;
delete family2;
delete family1;
delete family4b;
delete family3b;
delete family2b;
delete family1b;
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/zxxzxztest.cpp | #include <kdl/kinfam/zxxzxz.hpp>
#include <kdl/kinfam/zxxzxzjnt2cartpos.hpp>
#include <kdl/kinfam/zxxzxzcartpos2jnt.hpp>
#include <kdl/frames.hpp>
#include <kdl/frames_io.hpp>
#include <kdl/kinfam/lineartransmission.hpp>
#include <kdl/kinfam/unittransmission.hpp>
using namespace KDL;
using namespace std;
/**
* testing of forward and inverse position kinematics of the routines.
* Also tests everything for all configurations.
*/
void test_zxxzxz(double l1,double l2,double l3,double l6) {
cout << "========================================================================================" << endl;
cout << " test_zxxzxz : forward and inverse position kinematics for all configurations" << endl;
cout << "========================================================================================" << endl;
ZXXZXZ kf("tst");
kf.setLinkLengths(l1,l2,l3,l6);
ZXXZXZJnt2CartPos* jnt2cartpos =
(ZXXZXZJnt2CartPos*) kf.createJnt2CartPos();
ZXXZXZCartPos2Jnt* cartpos2jnt =
(ZXXZXZCartPos2Jnt*) kf.createCartPos2Jnt();
SerialChain* kf2 = kf.createSerialChain();
Jnt2CartPos* jnt2cartpos2 = kf2->createJnt2CartPos();
std::vector<double> q(6);
std::vector<double> q2(6);
double epsq = 1E-8;
int config,config2,config3;
Frame F,F2,F3;
bool exitflag=false;
for (int config=0;config<8;config++) {
cout << endl<<"=== Testing configuration : " << config << " === "<< endl;
kf.setConfigurationToJoints(config,q);
config2=kf.getConfigurationFromJoints(q);
if (config != config2) {
cout << "FAIL :test_zxxzxz(): configurations do not match using configuration representation transformation" << endl;
cerr << "FAIL :test_zxxzxz(): configurations do not match using configuration representation transformation" << endl;
cout << "original configuration " << kf.getConfigurationDescription(config) << endl;
cout << "reached configuration " << kf.getConfigurationDescription(config2) << endl;
exitflag=true;
}
// fwd kin
jnt2cartpos->evaluate(q);
jnt2cartpos->getFrame(F);
jnt2cartpos->getConfiguration(config2);
jnt2cartpos2->evaluate(q);
jnt2cartpos2->getFrame(F3);
if (!Equal(F,F3,1E-6)) {
cout << "FAIL :test_zxxzxz(): fwd(q)!=fwd_serialchain(q)" << endl;
cerr << "FAIL :test_zxxzxz(): fwd(q)!=fwd_serialchain(q)" << endl;
cout << "Frame F = fwd(q) " << F << endl;
cout << "Frame F = fwd_serialchain(q) " << F3 << endl;
exitflag=true;
}
if (config!=config2) {
cout << "FAIL :test_zxxzxz(): configurations do not match after jnt2cartpos transform" << endl;
cout << "original configuration " << kf.getConfigurationDescription(config) << endl;
cout << "reached configuration " << kf.getConfigurationDescription(config2) << endl;
cerr << "FAIL :test_zxxzxz(): configurations do not match after jnt2cartpos transform" << endl;
exitflag=true;
}
// inv kin
cartpos2jnt->setConfiguration(config);
cartpos2jnt->setFrame(F);
cartpos2jnt->evaluate(q2);
jnt2cartpos->evaluate(q2);
jnt2cartpos->getConfiguration(config3);
jnt2cartpos->getFrame(F2);
if (!Equal(F,F2,1E-6)) {
cout << "FAIL :test_zxxzxz(): fwd(inv(F))!=F" << endl;
cerr << "FAIL :test_zxxzxz(): fwd(inv(F))!=F" << endl;
exitflag=true;
}
for (int i=0;i<q.size();++i) {
if (fabs(q[i]-q2[i])>epsq) {
cout << "FAIL :test_zxxzxz(): inv(fwd(q))!=q" << endl;
cerr << "FAIL :test_zxxzxz(): inv(fwd(q))!=q" << endl;
exitflag=true;
}
}
if (exitflag) {
cout << "=========== FAILURE REPORT ================" << endl;
cout << "Frame F = fwd(q) = " << F << endl;
cout << "original configuration " << kf.getConfigurationDescription(config) << endl;
cout << "Frame F2 = fwd(inv(F)) = " << F2 << endl;
cout << "configuration of fwd(inv(F)) = " << kf.getConfigurationDescription(config3) << endl;
cout << "Comparing q with q2=inv(fwd(q)) "<< endl;
for (int j=0;j<6;++j) {
std::cout << "q["<<j<<"]="<<q[j]<<" and q2["<<j<<"]="<<q2[j]<<std::endl;
}
}
}
if (exitflag) return exit(-1);
delete jnt2cartpos2;
delete kf2;
delete cartpos2jnt;
delete jnt2cartpos;
}
int main(int argc,char* argv[]) {
test_zxxzxz(0.33,0.305,0.33,0.176);
test_zxxzxz(0.1,0.2,0.3,0.4);
test_zxxzxz(0.5,0.3,0.2,0.5);
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/tests/velocityprofiletest.cpp | #include "velocityprofiletest.hpp"
#include <frames_io.hpp>
CPPUNIT_TEST_SUITE_REGISTRATION( VelocityProfileTest );
using namespace KDL;
void VelocityProfileTest::setUp()
{
}
void VelocityProfileTest::tearDown()
{
}
void VelocityProfileTest::TestTrap_MaxVelocity1()
{
// 2 second ramp up (cover 2 distance),
// 2 second flat velocity (cover 4 distance)
// 2 second ramp down (cover 2 distance),
VelocityProfile_Trap v(2, 1);
double time;
v.SetProfile(2, 10);
CPPUNIT_ASSERT_EQUAL(6.0, v.Duration());
// start
time = 0;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Acc(time));
// end of ramp up
time = 2;
CPPUNIT_ASSERT_EQUAL(4.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// middle of flat velocity
time = 3;
CPPUNIT_ASSERT_EQUAL(6.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// end of flat velocity
time = 4;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-1.0, v.Acc(time));
// middle of ramp down
time = 5;
CPPUNIT_ASSERT_EQUAL(9.5, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-1.0, v.Acc(time));
// end
time = 6;
CPPUNIT_ASSERT_EQUAL(10.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-1.0, v.Acc(time));
// fenceposts - before and after
time = -1;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
time = 11;
CPPUNIT_ASSERT_EQUAL(10.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
}
void VelocityProfileTest::TestTrap_MaxVelocity2()
{
// 2 second ramp up (cover -2 distance),
// 2 second flat velocity (cover -4 distance)
// 2 second ramp down (cover -2 distance),
VelocityProfile_Trap v(2, 1);
v.SetProfile(2, -6);
CPPUNIT_ASSERT_EQUAL(6.0, v.Duration());
}
void VelocityProfileTest::TestTrap_MaxVelocity3()
{
// 2 second ramp up (cover 4 distance),
// 0 second flat velocity (cover 0 distance)
// 2 second ramp down (cover 4 distance),
VelocityProfile_Trap v(4, 2);
v.SetProfile(2, 10);
CPPUNIT_ASSERT_EQUAL(4.0, v.Duration());
// new profile
v.SetProfile(2, -6);
CPPUNIT_ASSERT_EQUAL(4.0, v.Duration());
// another new profile : ramp + 2 sec + ramp
v.SetProfile(13, 13 + 4 + 8 + 4);
CPPUNIT_ASSERT_EQUAL(6.0, v.Duration());
}
void VelocityProfileTest::TestTrap_SetDuration1()
{
// same as first max velocity test, but twice as
// long (max velocity gives 6 seconds)
VelocityProfile_Trap v(2, 1);
double time;
v.SetProfileDuration(2, 10, 12.0);
CPPUNIT_ASSERT_EQUAL(12.0, v.Duration());
// start
time = 0;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.25, v.Acc(time));
// end of ramp up
time = 4;
CPPUNIT_ASSERT_EQUAL(4.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// middle of flat velocity
time = 6;
CPPUNIT_ASSERT_EQUAL(6.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// end of flat velocity
time = 8;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-0.25, v.Acc(time));
// middle of ramp down
time = 10;
CPPUNIT_ASSERT_EQUAL(9.5, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.5, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-0.25, v.Acc(time));
// end
time = 12;
CPPUNIT_ASSERT_EQUAL(10.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(-0.25, v.Acc(time));
}
void VelocityProfileTest::TestTrapHalf_SetProfile_Start()
{
// 2 second ramp up (cover 2 distance),
// 2 second flat velocity (cover 4 distance)
VelocityProfile_TrapHalf v(2, 1, true);
double time;
v.SetProfile(2, 2+6);
CPPUNIT_ASSERT_EQUAL(4.0, v.Duration());
// start
time = 0;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Acc(time));
// end of ramp up
time = 2;
CPPUNIT_ASSERT_EQUAL(4.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// middle of flat velocity
time = 3;
CPPUNIT_ASSERT_EQUAL(6.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// end
time = 4;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// fenceposts - before and after
time = -1;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
time = 5;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
}
void VelocityProfileTest::TestTrapHalf_SetProfile_End()
{
// 2 second flat velocity (cover 4 distance)
// 2 second ramp up (cover 2 distance),
VelocityProfile_TrapHalf v(2, 1, false);
double time;
v.SetProfile(9, 9-6);
CPPUNIT_ASSERT_EQUAL(4.0, v.Duration());
// start - flat velocity
time = 0;
CPPUNIT_ASSERT_EQUAL(9.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(-2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// end of flat velocity
time = 2;
CPPUNIT_ASSERT_EQUAL(5.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(-2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Acc(time));
// middle of ramp down
time = 3;
CPPUNIT_ASSERT_EQUAL(3.5, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(-1.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(1.0, v.Acc(time));
// end
time = 4;
CPPUNIT_ASSERT_EQUAL(3.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// fenceposts - before and after
time = -1;
CPPUNIT_ASSERT_EQUAL(9.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
time = 5;
CPPUNIT_ASSERT_EQUAL(3.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
}
void VelocityProfileTest::TestTrapHalf_SetDuration_Start()
{
// same as TestTrapHalf__SetProfile_Start() but twice as slow
// Lingers at start position with zero velocity for a period of time,
// as does not scale the velocity; only scales the acceleration!?
VelocityProfile_TrapHalf v(2, 1, true);
double time;
v.SetProfileDuration(2, 2+6, 8);
CPPUNIT_ASSERT_EQUAL(8.0, v.Duration());
// start - no motion
time = 0;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// no motion
time = 1.9;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// begin ramp at scaled acceleration
time = 2;
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, v.Pos(time), 0.001);
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333, v.Acc(time), 0.001);
// middle of ramp up
time = 5;
CPPUNIT_ASSERT_DOUBLES_EQUAL(3.5, v.Pos(time), 0.001);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, v.Vel(time), 0.001);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.3333, v.Acc(time), 0.001);
// end - continue with given velocity
time = 8;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// fenceposts - before and after
time = -1;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
time = 9;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
}
void VelocityProfileTest::TestTrapHalf_SetDuration_End()
{
// same as TestTrapHalf__SetProfile_Start() but twice as slow
// Lingers at start position with zero velocity for a period of time,
// as does not scale the velocity; only scales the acceleration!?
VelocityProfile_TrapHalf v(2, 1, true);
double time;
v.SetProfileDuration(2+6, 2, 8);
CPPUNIT_ASSERT_EQUAL(8.0, v.Duration());
// start - no motion
time = 0;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// no motion
time = 1.9;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// begin ramp at scaled acceleration
time = 2;
CPPUNIT_ASSERT_DOUBLES_EQUAL(8.0, v.Pos(time), 0.001);// WRONG, backwards!
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.333, v.Acc(time), 0.001);
// middle of ramp up
time = 5;
CPPUNIT_ASSERT_DOUBLES_EQUAL(6.5, v.Pos(time), 0.001);
CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, v.Vel(time), 0.001);
CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3333, v.Acc(time), 0.001);
// end - continue with given velocity
time = 8;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(-2.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
// fenceposts - before and after
time = -1;
CPPUNIT_ASSERT_EQUAL(8.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
time = 9;
CPPUNIT_ASSERT_EQUAL(2.0, v.Pos(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Vel(time));
CPPUNIT_ASSERT_EQUAL(0.0, v.Acc(time));
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/models.hpp | // Copyright (C) 2009 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Version: 1.0
// Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// URL: http://www.orocos.org/kdl
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef MODELS_HPP
#define MODELS_HPP
namespace KDL{
class Chain;
Chain Puma560();
Chain KukaLWR();
Chain KukaLWRsegment();
Chain KukaLWR_DHnew();
}
#endif | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/CMakeLists.txt | OPTION(BUILD_MODELS "Build models for some well known robots" FALSE)
IF(BUILD_MODELS)
ADD_LIBRARY(orocos-kdl-models SHARED puma560.cpp kukaLWR_DHnew.cpp)
INCLUDE_DIRECTORIES(${PROJ_SOURCE_DIR}/src ${PROJ_BINARY_DIR}/src)
SET_TARGET_PROPERTIES( orocos-kdl-models PROPERTIES
SOVERSION "${KDL_VERSION_MAJOR}.${KDL_VERSION_MINOR}"
VERSION "${KDL_VERSION}"
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS}"
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
PUBLIC_HEADER models.hpp)
TARGET_LINK_LIBRARIES(orocos-kdl-models orocos-kdl)
export(TARGETS orocos-kdl-models APPEND
FILE "${PROJECT_BINARY_DIR}/OrocosKDLTargets.cmake")
INSTALL( TARGETS orocos-kdl-models
EXPORT OrocosKDLTargets
ARCHIVE DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include/kdl
)
ENDIF(BUILD_MODELS)
INCLUDE(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_MODELS_DEMO "Build demo for some of the models" OFF "BUILD_MODELS" OFF)
IF(BUILD_MODELS_DEMO)
ADD_EXECUTABLE(p560test puma560test.cpp)
TARGET_LINK_LIBRARIES(p560test orocos-kdl-models)
SET_TARGET_PROPERTIES( p560test PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS}")
ADD_EXECUTABLE(kukaLWRtestDHnew kukaLWRtestDHnew.cpp)
TARGET_LINK_LIBRARIES(kukaLWRtestDHnew orocos-kdl-models)
SET_TARGET_PROPERTIES( kukaLWRtestDHnew PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS}")
ADD_EXECUTABLE(kukaLWRtestHCG kukaLWRtestHCG.cpp)
TARGET_LINK_LIBRARIES(kukaLWRtestHCG orocos-kdl-models)
SET_TARGET_PROPERTIES( kukaLWRtestHCG PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_ADD} ${KDL_CFLAGS}")
ENDIF(BUILD_MODELS_DEMO) | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/kukaLWRtestDHnew.cpp | #include <chain.hpp>
#include "models.hpp"
#include <frames_io.hpp>
#include <kinfam_io.hpp>
#include <chainfksolverpos_recursive.hpp>
#include <chainidsolver_recursive_newton_euler.hpp>
using namespace KDL;
using namespace std;
void outputLine( double, double, double, double, double, double, double);
int getInputs(JntArray&, JntArray&, JntArray&, int&);
int main(int argc , char** argv){
Chain kLWR=KukaLWR_DHnew();
JntArray q(kLWR.getNrOfJoints());
JntArray qdot(kLWR.getNrOfJoints());
JntArray qdotdot(kLWR.getNrOfJoints());
JntArray tau(kLWR.getNrOfJoints());
Wrenches f(kLWR.getNrOfSegments());
int linenum; //number of experiment= number of line
getInputs(q, qdot,qdotdot,linenum);
ChainFkSolverPos_recursive fksolver(kLWR);
Frame T;
ChainIdSolver_RNE idsolver(kLWR,Vector(0.0,0.0,-9.81));
fksolver.JntToCart(q,T);
idsolver.CartToJnt(q,qdot,qdotdot,f,tau);
std::cout<<"pose: \n"<<T<<std::endl;
std::cout<<"tau: "<<tau<<std::endl;
//write file: code based on example 14.4, c++ how to program, Deitel and Deitel, book p 708
ofstream outPoseFile("poseResultaat.dat",ios::app);
if(!outPoseFile)
{
cerr << "File poseResultaat could not be opened" <<endl;
exit(1);
}
outPoseFile << "linenumber=experimentnr= "<< linenum << "\n";
outPoseFile << T << "\n \n";
outPoseFile.close();
ofstream outTauFile("tauResultaat.dat",ios::app);
if(!outTauFile)
{
cerr << "File tauResultaat could not be opened" <<endl;
exit(1);
}
outTauFile << setiosflags( ios::left) << setw(10) << linenum;
outTauFile << tau << "\n";
outTauFile.close();
}
int getInputs(JntArray &_q, JntArray &_qdot, JntArray &_qdotdot, int &linenr)
{
//cout << " q" << _q<< "\n";
//declaration
//int linenr; //line =experiment number
int counter;
//initialisation
counter=0;
//ask which experiment number= line number in files
cout << "Give experiment number= line number in files \n ?";
cin >> linenr;
//read files: code based on example 14.8, c++ how to program, Deitel and Deitel, book p 712
/*
*READING Q = joint positions
*/
ifstream inQfile("interpreteerbaar/q", ios::in);
if (!inQfile)
{
cerr << "File q could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_q(0)" << setw(15) << "_q(1)" << setw(15) << "_q(2)" << setw(15) << "_q(3)" << setw(15) << "_q(4)" << setw(15) << "_q(5)" << setw(15) << "_q(6)" << " \n" ;
while(!inQfile.eof())
{
//read out a line of the file
inQfile >> _q(0) >> _q(1) >> _q(2) >> _q(3) >> _q(4) >> _q(5) >> _q(6);
counter++;
if(counter==linenr)
{
outputLine( _q(0), _q(1), _q(2), _q(3), _q(4), _q(5), _q(6));
break;
}
}
inQfile.close();
/*
*READING Qdot = joint velocities
*/
counter=0;//reset counter
ifstream inQdotfile("interpreteerbaar/qdot", ios::in);
if (!inQdotfile)
{
cerr << "File qdot could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_qdot(0)" << setw(15) << "_qdot(1)" << setw(15) << "_qdot(2)" << setw(15) << "_qdot(3)" << setw(15) << "_qdot(4)" << setw(15) << "_qdot(5)" << setw(15) << "_qdot(6)" << " \n" ;
while(!inQdotfile.eof())
{
//read out a line of the file
inQdotfile >> _qdot(0) >> _qdot(1) >> _qdot(2) >> _qdot(3) >> _qdot(4) >> _qdot(5) >> _qdot(6) ;
counter++;
if(counter==linenr)
{
outputLine( _qdot(0), _qdot(1), _qdot(2), _qdot(3), _qdot(4), _qdot(5), _qdot(6));
break;
}
}
inQdotfile.close();
/*
*READING Qdotdot = joint accelerations
*/
counter=0;//reset counter
ifstream inQdotdotfile("interpreteerbaar/qddot", ios::in);
if (!inQdotdotfile)
{
cerr << "File qdotdot could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_qdotdot(0)" << setw(15) << "_qdotdot(1)" << setw(15) << "_qdotdot(2)" << setw(15) << "_qdotdot(3)" << setw(15) << "_qdotdot(4)" << setw(15) << "_qdotdot(5)" << setw(15) << "_qdotdot(6)" << " \n" ;
while(!inQdotdotfile.eof())
{
//read out a line of the file
inQdotdotfile >> _qdotdot(0) >> _qdotdot(1) >> _qdotdot(2) >> _qdotdot(3) >> _qdotdot(4) >> _qdotdot(5) >> _qdotdot(6);
counter++;
if(counter==linenr)
{
outputLine(_qdotdot(0), _qdotdot(1), _qdotdot(2), _qdotdot(3), _qdotdot(4), _qdotdot(5), _qdotdot(6) );
break;
}
}
inQdotdotfile.close();
return 0;
}
void outputLine( double x1, double x2, double x3, double x4, double x5, double x6, double x7)
{
cout << setiosflags(ios::left) << setiosflags(ios::fixed | ios::showpoint) <<setw(15)
<< x1 << setw(15) << x2 <<setw(15) <<setw(15) << x3 <<setw(15) << x4 <<setw(15) << x5 <<setw(15) << x6 <<setw(15) << x7 <<"\n";
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/kukaLWR_DHnew.cpp | // Copyright (C) 2009 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Version: 1.0
// Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// URL: http://www.orocos.org/kdl
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <chain.hpp>
#include "models.hpp"
namespace KDL{
Chain KukaLWR_DHnew(){
Chain kukaLWR_DHnew;
//joint 0
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::None),
Frame::DH_Craig1989(0.0, 0.0, 0.31, 0.0)
));
//joint 1
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, 1.5707963, 0.0, 0.0),
Frame::DH_Craig1989(0.0, 1.5707963, 0.0, 0.0).Inverse()*RigidBodyInertia(2,
Vector::Zero(),
RotationalInertia(0.0,0.0,0.0115343,0.0,0.0,0.0))));
//joint 2
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -1.5707963, 0.4, 0.0),
Frame::DH_Craig1989(0.0, -1.5707963, 0.4, 0.0).Inverse()*RigidBodyInertia(2,
Vector(0.0,-0.3120511,-0.0038871),
RotationalInertia(-0.5471572,-0.0000302,-0.5423253,0.0,0.0,0.0018828))));
//joint 3
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -1.5707963, 0.0, 0.0),
Frame::DH_Craig1989(0.0, -1.5707963, 0.0, 0.0).Inverse()*RigidBodyInertia(2,
Vector(0.0,-0.0015515,0.0),
RotationalInertia(0.0063507,0.0,0.0107804,0.0,0.0,-0.0005147))));
//joint 4
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, 1.5707963, 0.39, 0.0),
Frame::DH_Craig1989(0.0, 1.5707963, 0.39, 0.0).Inverse()*RigidBodyInertia(2,
Vector(0.0,0.5216809,0.0),
RotationalInertia(-1.0436952,0.0,-1.0392780,0.0,0.0,0.0005324))));
//joint 5
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, 1.5707963, 0.0, 0.0),
Frame::DH_Craig1989(0.0, 1.5707963, 0.0, 0.0).Inverse()*RigidBodyInertia(2,
Vector(0.0,0.0119891,0.0),
RotationalInertia(0.0036654,0.0,0.0060429,0.0,0.0,0.0004226))));
//joint 6
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH_Craig1989(0.0, -1.5707963, 0.0, 0.0),
Frame::DH_Craig1989(0.0, -1.5707963, 0.0, 0.0).Inverse()*RigidBodyInertia(2,
Vector(0.0,0.0080787,0.0),
RotationalInertia(0.0010431,0.0,0.0036376,0.0,0.0,0.0000101))));
//joint 7
kukaLWR_DHnew.addSegment(Segment(Joint(Joint::RotZ),
Frame::Identity(),
RigidBodyInertia(2,
Vector::Zero(),
RotationalInertia(0.000001,0.0,0.0001203,0.0,0.0,0.0))));
return kukaLWR_DHnew;
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/puma560test.cpp | #include <chain.hpp>
#include "models.hpp"
#include <frames_io.hpp>
#include <kinfam_io.hpp>
#include <chainfksolverpos_recursive.hpp>
#include <chainidsolver_recursive_newton_euler.hpp>
using namespace KDL;
int main(int argc , char** argv){
Chain p560=Puma560();
//Chain p560;
// p560.addSegment(Segment(Joint(Joint::RotX),Frame::Identity(),RigidBodyInertia(1.0,Vector(0.0,1.0,.0),RotationalInertia(1.0,2.0,3.0))));
// p560.addSegment(Segment(Joint(Joint::RotY),Frame(Rotation::Identity(),Vector(0,2,0)),RigidBodyInertia(1.0,Vector(1.0,0.0,.0),RotationalInertia(1.0,2.0,3,4,5,6))));
// p560.addSegment(Segment(Joint(Joint::RotZ),Frame(Rotation::Identity(),Vector(2,0,0)),RigidBodyInertia(1.0,Vector(0.0,0.0,1),RotationalInertia(1.0,2.0,3,4,5,6))));
JntArray q(p560.getNrOfJoints());
JntArray qdot(p560.getNrOfJoints());
JntArray qdotdot(p560.getNrOfJoints());
JntArray tau(p560.getNrOfJoints());
Wrenches f(p560.getNrOfSegments());
for(unsigned int i=0;i<p560.getNrOfJoints();i++){
q(i)=0.0;
qdot(i)=0.0;
qdotdot(i)=0.0;
//if(i<2)
//{
std::cout << "give q(" << i+1 << ")\n" << std::endl;
std::cin >> q(i);
std::cout << "give qdot(" << i+1 << ")\n" << std::endl;
std::cin >> qdot(i);
std::cout << "give qdotdot(" << i << ")\n" << std::endl;
std::cin >> qdotdot(i);
//}
}
ChainFkSolverPos_recursive fksolver(p560);
Frame T;
ChainIdSolver_RNE idsolver(p560,Vector(0.0,0.0,-9.81));
//#include <time.h>
//time_t before,after;
//time(&before);
//unsigned int k=0;
//for(k=0;k<1e7;k++)
fksolver.JntToCart(q,T);
//time(&after);
//std::cout<<"elapsed time for FK: "<<difftime(after,before)<<" seconds for "<<k<<" iterations"<<std::endl;
//std::cout<<"time per iteration for FK: "<<difftime(after,before)/k<<" seconds."<<std::endl;
//time(&before);
//for(k=0;k<1e7;k++)
idsolver.CartToJnt(q,qdot,qdotdot,f,tau);
//time(&after);
//std::cout<<"elapsed time for ID: "<<difftime(after,before)<<" seconds for "<<k<<" iterations"<<std::endl;
//std::cout<<"time per iteration for ID: "<<difftime(after,before)/k<<" seconds."<<std::endl;
std::cout<<T<<std::endl;
std::cout<<"tau: "<<tau<<std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/puma560.cpp | // Copyright (C) 2009 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Version: 1.0
// Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// URL: http://www.orocos.org/kdl
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <chain.hpp>
#include "models.hpp"
namespace KDL{
Chain Puma560(){
Chain puma560;
puma560.addSegment(Segment());
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.0,M_PI_2,0.0,0.0),
RigidBodyInertia(0,Vector::Zero(),RotationalInertia(0,0.35,0,0,0,0))));
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.4318,0.0,0.0,0.0),
RigidBodyInertia(17.4,Vector(-.3638,.006,.2275),RotationalInertia(0.13,0.524,0.539,0,0,0))));
puma560.addSegment(Segment());
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.0203,-M_PI_2,0.15005,0.0),
RigidBodyInertia(4.8,Vector(-.0203,-.0141,.070),RotationalInertia(0.066,0.086,0.0125,0,0,0))));
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.0,M_PI_2,0.4318,0.0),
RigidBodyInertia(0.82,Vector(0,.019,0),RotationalInertia(1.8e-3,1.3e-3,1.8e-3,0,0,0))));
puma560.addSegment(Segment());
puma560.addSegment(Segment());
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.0,-M_PI_2,0.0,0.0),
RigidBodyInertia(0.34,Vector::Zero(),RotationalInertia(.3e-3,.4e-3,.3e-3,0,0,0))));
puma560.addSegment(Segment(Joint(Joint::RotZ),
Frame::DH(0.0,0.0,0.0,0.0),
RigidBodyInertia(0.09,Vector(0,0,.032),RotationalInertia(.15e-3,0.15e-3,.04e-3,0,0,0))));
puma560.addSegment(Segment());
return puma560;
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/models/kukaLWRtestHCG.cpp | #include <chain.hpp>
#include "models.hpp"
#include <frames_io.hpp>
#include <kinfam_io.hpp> //know how to print different types on screen
#include <chainfksolverpos_recursive.hpp>
#include <chainidsolver_recursive_newton_euler.hpp>
#include <jntspaceinertiamatrix.hpp>
#include <chaindynparam.hpp>
using namespace KDL;
using namespace std;
void outputLine( double, double, double, double, double, double, double);
int getInputs(JntArray&, JntArray&, JntArray&, int&);
int main(int argc , char** argv){
Chain kLWR=KukaLWR_DHnew();
JntArray q(kLWR.getNrOfJoints());
JntArray qdot(kLWR.getNrOfJoints());
JntArray qdotdot(kLWR.getNrOfJoints());
JntArray tau(kLWR.getNrOfJoints());
JntArray tauHCGa(kLWR.getNrOfJoints());
JntArray tauHCG(kLWR.getNrOfJoints());
JntArray C(kLWR.getNrOfJoints()); //coriolis matrix
JntArray G(kLWR.getNrOfJoints()); //gravity matrix
Wrenches f(kLWR.getNrOfSegments());
Vector grav(0.0,0.0,-9.81);
JntSpaceInertiaMatrix H(kLWR.getNrOfJoints()); //inertiamatrix H=square matrix of size= number of joints
ChainDynParam chaindynparams(kLWR,grav);
int linenum; //number of experiment= number of line
//read out inputs from files
getInputs(q, qdot,qdotdot,linenum);
//calculation of torques with kukaLWRDH_new.cpp (dynamic model)
ChainFkSolverPos_recursive fksolver(kLWR);
Frame T;
ChainIdSolver_RNE idsolver(kLWR,grav);
fksolver.JntToCart(q,T);
idsolver.CartToJnt(q,qdot,qdotdot,f,tau);
std::cout<<"pose (with dynamic model): \n"<<T<<std::endl;
std::cout<<"tau (with dynamic model): \n"<<tau<<std::endl;
//calculation of the HCG matrices
chaindynparams.JntToMass(q,H);
chaindynparams.JntToCoriolis(q,qdot,C);
chaindynparams.JntToGravity(q,G);
//calculation of the torques with the HCG matrices
Multiply(H, qdotdot, tauHCG); //H*qdotdot
Add(tauHCG,C,tauHCGa); //tauHCGa=H*qdotdot+C
Add(tauHCGa,G,tauHCG); //tauHCG=H*qdotdot+C+G
std::cout<<"H= \n"<<H<<"\n C = \n "<<C<<"\n G= \n"<<G<<" \n tau (with HCG)= \n"<< tauHCG <<std::endl;
//write file: code based on example 14.4, c++ how to program, Deitel and Deitel, book p 708
ofstream outPoseFile("poseResultaat.dat",ios::app);
if(!outPoseFile)
{
cerr << "File poseResultaat could not be opened" <<endl;
exit(1);
}
outPoseFile << "linenumber=experimentnr= "<< linenum << "\n";
outPoseFile << T << "\n \n";
outPoseFile.close();
ofstream outTauFile("tauResultaat.dat",ios::app);
if(!outTauFile)
{
cerr << "File tauResultaat could not be opened" <<endl;
exit(1);
}
outTauFile << setiosflags( ios::left) << setw(10) << linenum;
outTauFile << tau << "\n";
outTauFile.close();
}
int getInputs(JntArray &_q, JntArray &_qdot, JntArray &_qdotdot, int &linenr)
{
//cout << " q" << _q<< "\n";
//declaration
//int linenr; //line =experiment number
int counter;
//initialisation
counter=0;
//ask which experiment number= line number in files
cout << "Give experiment number= line number in files \n ?";
cin >> linenr;
//read files: code based on example 14.8, c++ how to program, Deitel and Deitel, book p 712
/*
*READING Q = joint positions
*/
ifstream inQfile("interpreteerbaar/q", ios::in);
if (!inQfile)
{
cerr << "File q could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_q(0)" << setw(15) << "_q(1)" << setw(15) << "_q(2)" << setw(15) << "_q(3)" << setw(15) << "_q(4)" << setw(15) << "_q(5)" << setw(15) << "_q(6)" << " \n" ;
while(!inQfile.eof())
{
//read out a line of the file
inQfile >> _q(0) >> _q(1) >> _q(2) >> _q(3) >> _q(4) >> _q(5) >> _q(6);
counter++;
if(counter==linenr)
{
outputLine( _q(0), _q(1), _q(2), _q(3), _q(4), _q(5), _q(6));
break;
}
}
inQfile.close();
/*
*READING Qdot = joint velocities
*/
counter=0;//reset counter
ifstream inQdotfile("interpreteerbaar/qdot", ios::in);
if (!inQdotfile)
{
cerr << "File qdot could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_qdot(0)" << setw(15) << "_qdot(1)" << setw(15) << "_qdot(2)" << setw(15) << "_qdot(3)" << setw(15) << "_qdot(4)" << setw(15) << "_qdot(5)" << setw(15) << "_qdot(6)" << " \n" ;
while(!inQdotfile.eof())
{
//read out a line of the file
inQdotfile >> _qdot(0) >> _qdot(1) >> _qdot(2) >> _qdot(3) >> _qdot(4) >> _qdot(5) >> _qdot(6) ;
counter++;
if(counter==linenr)
{
outputLine( _qdot(0), _qdot(1), _qdot(2), _qdot(3), _qdot(4), _qdot(5), _qdot(6));
break;
}
}
inQdotfile.close();
/*
*READING Qdotdot = joint accelerations
*/
counter=0;//reset counter
ifstream inQdotdotfile("interpreteerbaar/qddot", ios::in);
if (!inQdotdotfile)
{
cerr << "File qdotdot could not be opened \n";
exit(1);
}
//print headers
cout << setiosflags( ios::left) << setw(15) << "_qdotdot(0)" << setw(15) << "_qdotdot(1)" << setw(15) << "_qdotdot(2)" << setw(15) << "_qdotdot(3)" << setw(15) << "_qdotdot(4)" << setw(15) << "_qdotdot(5)" << setw(15) << "_qdotdot(6)" << " \n" ;
while(!inQdotdotfile.eof())
{
//read out a line of the file
inQdotdotfile >> _qdotdot(0) >> _qdotdot(1) >> _qdotdot(2) >> _qdotdot(3) >> _qdotdot(4) >> _qdotdot(5) >> _qdotdot(6);
counter++;
if(counter==linenr)
{
outputLine(_qdotdot(0), _qdotdot(1), _qdotdot(2), _qdotdot(3), _qdotdot(4), _qdotdot(5), _qdotdot(6) );
break;
}
}
inQdotdotfile.close();
return 0;
}
void outputLine( double x1, double x2, double x3, double x4, double x5, double x6, double x7)
{
cout << setiosflags(ios::left) << setiosflags(ios::fixed | ios::showpoint) <<setw(15)
<< x1 << setw(15) << x2 <<setw(15) <<setw(15) << x3 <<setw(15) << x4 <<setw(15) << x5 <<setw(15) << x6 <<setw(15) << x7 <<"\n";
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/geometry.cpp | #include <frames.hpp>
#include <frames_io.hpp>
int main()
{
//Creating Vectors
KDL::Vector v1;//Default constructor
KDL::Vector v2(1.0,2.0,3.0);//Most used constructor
KDL::Vector v3(v2);//Copy constructor
KDL::Vector v4 = KDL::Vector::Zero();//Static member
//Use operator << to print the values of your vector
std::cout<<"v1 ="<<v1<<std::endl;
std::cout<<"v2 = "<<v2<<std::endl;
std::cout<<"v3 = "<<v3<<std::endl;
std::cout<<"v4 = "<<v4<<std::endl;
//Get/Set values of a vector
v1[0]=4.0;
v1[1]=5.0;
v1[2]=6.0;
v2(0)=7.0;
v2(1)=8.0;
v2(2)=9.0;
v3.x(10.0);
v3.y(11.0);
v3.z(12.0);
std::cout<<"v1: "<<v1[0]<<", "<<v1[1]<<", "<<v1[2]<<std::endl;
std::cout<<"v2: "<<v2(0)<<", "<<v2(1)<<", "<<v2(2)<<std::endl;
std::cout<<"v3: "<<v3.x()<<", "<<v3.y()<<", "<<v3.z()<<std::endl;
//double - vector operators
std::cout<<"2*v2 = "<<2*v2<<std::endl;
std::cout<<"v1*2 = "<<v1*2<<std::endl;
std::cout<<"v1/2 = "<<v1/2<<std::endl;
//vector - vector operators
std::cout<<"v1+v2 = "<<v1+v2<<std::endl;
std::cout<<"v3-v1 = "<<v3-v1<<std::endl;
v3-=v1;
v2+=v1;
std::cout<<"v3-=v1; v3 = "<<v3<<std::endl;
std::cout<<"v2+=v1; v2 = "<<v2<<std::endl;
//cross and dot product between two vectors
std::cout<<"cross(v1,v2) = "<<v1*v2<<std::endl;
std::cout<<"dot(v1,v2) = "<<dot(v1,v2)<<std::endl;
//Inversing the sign of a vector
v1=-v2;
std::cout<<"v1=-v2; v1="<<v1<<std::endl;
v1.ReverseSign();
std::cout<<"v1.ReverseSign(); v1 = "<<v1<<std::endl;
//Equal operators
std::cout<<"v1==v2 ? "<<(v1==v2)<<std::endl;
std::cout<<"v1!=v2 ? "<<(v1!=v2)<<std::endl;
std::cout<<"Equal(v1,v2,1e-6) ? "<<Equal(v1,v2,1e-6)<<std::endl;
//Calculating the norm and normalising your vector
std::cout<<"norm(v3): "<<v3.Norm()<<std::endl;
v3.Normalize();
std::cout<<"Normalize(v3)"<<v3<<std::endl;
//Setting your vector to zero
SetToZero(v1);
std::cout<<"SetToZero(v1); v1 = "<<v1<<std::endl;
//Creating Rotations:
//Default constructor
KDL::Rotation r1;
//Creating a rotation matrix out of three unit vectors Vx, Vy,
//Vz. Be carefull, these vectors should be normalised and
//orthogonal. Otherwise this can result in an inconsistent
//rotation matrix
KDL::Rotation r2(KDL::Vector(0,0,1),
KDL::Vector(0,-1,0),
KDL::Vector(-1,0,0));
//Creating a rotation matrix out of 9 values, Be carefull, these
//values can result in an inconsisten rotation matrix if the
//resulting rows/columns are not orthogonal/normalized
KDL::Rotation r3(0,0,-1,1,0,0,0,-1,0);
//Creating an Identity rotation matrix
KDL::Rotation r4=KDL::Rotation::Identity();
//Creating a Rotation matrix from a rotation around X
KDL::Rotation r5=KDL::Rotation::RotX(M_PI/3);
//Creating a Rotation matrix from a rotation around Y
KDL::Rotation r6=KDL::Rotation::RotY(M_PI/3);
//Creating a Rotation matrix from a rotation around Z
KDL::Rotation r7=KDL::Rotation::RotZ(M_PI/3);
//Creating a Rotation matrix from a rotation around a arbitrary
//vector, the vector should not be normalised
KDL::Rotation r8=KDL::Rotation::Rot(KDL::Vector(1.,2.,3.),M_PI/4);
//Creating a Rotation matrix from a rotation around a arbitrary
//vector, the vector should be normalised
KDL::Rotation r9=KDL::Rotation::Rot2(KDL::Vector(0.4472,0.5477,0.7071),
M_PI/4);
//Creating a Rotation matrix from Euler ZYZ rotation angles
KDL::Rotation r10=KDL::Rotation::EulerZYZ(1.,2.,3.);
//Creating a Rotation matrix from Euler ZYX rotation angles
KDL::Rotation r11=KDL::Rotation::EulerZYX(1.,2.,3.);
//Creating a Rotation matrix from Roll-Pitch-Yaw rotation angles
KDL::Rotation r12=KDL::Rotation::RPY(1.,2.,3.);
//Printing the rotations:
std::cout<<"r1: "<<r1<<std::endl;
std::cout<<"r2: "<<r2<<std::endl;
std::cout<<"r3: "<<r3<<std::endl;
std::cout<<"r4: "<<r4<<std::endl;
std::cout<<"r5: "<<r5<<std::endl;
std::cout<<"r6: "<<r6<<std::endl;
std::cout<<"r7: "<<r7<<std::endl;
std::cout<<"r8: "<<r8<<std::endl;
std::cout<<"r9: "<<r9<<std::endl;
std::cout<<"r10: "<<r10<<std::endl;
std::cout<<"r11: "<<r11<<std::endl;
std::cout<<"r12: "<<r12<<std::endl;
//Getting information out of the rotation matrix:
//The individual elements
std::cout<<"r8(1,2): "<<r8(1,2)<<std::endl;
//The equivalent rotation vector;
std::cout<<"equiv rot vector of r11: "<<r11.GetRot()<<std::endl;
//The equivalent rotation vector and angle:
double angle=r10.GetRotAngle(v1);
std::cout<<"equiv rot vector of r10:"<<v1<<"and angle: "<<angle<<std::endl;
//The Euler ZYZ angles
double alfa,beta,gamma;
r9.GetEulerZYZ(alfa,beta,gamma);
std::cout<<"EulerZYZ: "<<alfa<<", "<<beta<<", "<<gamma<<std::endl;
//The Euler ZYZ angles
r9.GetEulerZYX(alfa,beta,gamma);
std::cout<<"EulerZYX: "<<alfa<<", "<<beta<<", "<<gamma<<std::endl;
//The Roll-Pitch-Yaw angles
r9.GetRPY(alfa,beta,gamma);
std::cout<<"Roll-Pitch-Yaw: "<<alfa<<", "<<beta<<", "<<gamma<<std::endl;
//The underlying unitvector X
r8.UnitX(v1);//or
std::cout<<"UnitX of r8:"<<r8.UnitX()<<std::endl;
//The underlying unitvector Y
r8.UnitY(v1);//or
std::cout<<"Unity of r8:"<<r8.UnitY()<<std::endl;
//The underlying unitvector Z
r8.UnitZ(v1);//or
std::cout<<"UnitZ of r8:"<<r8.UnitZ()<<std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/CMakeLists.txt | IF(ENABLE_EXAMPLES)
INCLUDE_DIRECTORIES(${PROJ_SOURCE_DIR}/src ${PROJ_SOURCE_DIR}/models ${PROJ_BINARY_DIR}/src)
add_executable(geometry geometry.cpp )
TARGET_LINK_LIBRARIES(geometry orocos-kdl)
add_executable(trajectory_example trajectory_example.cpp )
TARGET_LINK_LIBRARIES(trajectory_example orocos-kdl)
add_executable(chainiksolverpos_lma_demo chainiksolverpos_lma_demo.cpp )
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo orocos-kdl orocos-kdl-models)
ENDIF(ENABLE_EXAMPLES)
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/plotframe.m | function plotframe(T,scale)
if nargin <2
scale=0.2;
end
origin=T*[0;0;0;1];
x = T*[scale;0;0;1];
y = T*[0;scale;0;1];
z = T*[0;0;scale;1];
line([origin(1) x(1)],[origin(2) x(2)],[origin(3) x(3)],'color','red','linewidth',2);
line([origin(1) y(1)],[origin(2) y(2)],[origin(3) y(3)],'color','green','linewidth',2);
line([origin(1) z(1)],[origin(2) z(2)],[origin(3) z(3)],'color','blue','linewidth',2); | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/trajectory_example.cpp | /**
* \file path_example.cpp
* An example to demonstrate the use of trajectory generation
* functions.
*
* There are is a matlab/octave file in the examples directory to visualise the results
* of this example program. (visualize_trajectory.m)
*
*/
#include <frames.hpp>
#include <frames_io.hpp>
#include <trajectory.hpp>
#include <trajectory_segment.hpp>
#include <trajectory_stationary.hpp>
#include <trajectory_composite.hpp>
#include <trajectory_composite.hpp>
#include <velocityprofile_trap.hpp>
#include <path_roundedcomposite.hpp>
#include <rotational_interpolation_sa.hpp>
#include <utilities/error.h>
#include <trajectory_composite.hpp>
int main(int argc,char* argv[]) {
using namespace KDL;
// Create the trajectory:
// use try/catch to catch any exceptions thrown.
// NOTE: exceptions will become obsolete in a future version.
try {
// Path_RoundedComposite defines the geometric path along
// which the robot will move.
//
Path_RoundedComposite* path = new Path_RoundedComposite(0.2,0.01,new RotationalInterpolation_SingleAxis());
// The routines are now robust against segments that are parallel.
// When the routines are parallel, no rounding is needed, and no attempt is made
// add constructing a rounding arc.
// (It is still not possible when the segments are on top of each other)
// Note that you can only rotate in a deterministic way over an angle less then M_PI!
// With an angle == M_PI, you cannot predict over which side will be rotated.
// With an angle > M_PI, the routine will rotate over 2*M_PI-angle.
// If you need to rotate over a larger angle, you need to introduce intermediate points.
// So, there is a common use case for using parallel segments.
path->Add(Frame(Rotation::RPY(M_PI,0,0), Vector(-1,0,0)));
path->Add(Frame(Rotation::RPY(M_PI/2,0,0), Vector(-0.5,0,0)));
path->Add(Frame(Rotation::RPY(0,0,0), Vector(0,0,0)));
path->Add(Frame(Rotation::RPY(0.7,0.7,0.7), Vector(1,1,1)));
path->Add(Frame(Rotation::RPY(0,0.7,0), Vector(1.5,0.3,0)));
path->Add(Frame(Rotation::RPY(0.7,0.7,0), Vector(1,1,0)));
// always call Finish() at the end, otherwise the last segment will not be added.
path->Finish();
// Trajectory defines a motion of the robot along a path.
// This defines a trapezoidal velocity profile.
VelocityProfile* velpref = new VelocityProfile_Trap(0.5,0.1);
velpref->SetProfile(0,path->PathLength());
Trajectory* traject = new Trajectory_Segment(path, velpref);
Trajectory_Composite* ctraject = new Trajectory_Composite();
ctraject->Add(traject);
ctraject->Add(new Trajectory_Stationary(1.0,Frame(Rotation::RPY(0.7,0.7,0), Vector(1,1,0))));
// use the trajectory
double dt=0.1;
std::ofstream of("./trajectory.dat");
for (double t=0.0; t <= traject->Duration(); t+= dt) {
Frame current_pose;
current_pose = traject->Pos(t);
for (int i=0;i<4;++i)
for (int j=0;j<4;++j)
of << current_pose(i,j) << "\t";
of << "\n";
// also velocities and accelerations are available !
//traject->Vel(t);
//traject->Acc(t);
}
of.close();
// you can get some meta-info on the path:
for (int segmentnr=0; segmentnr < path->GetNrOfSegments(); segmentnr++) {
double starts,ends;
Path::IdentifierType pathtype;
if (segmentnr==0) {
starts = 0.0;
} else {
starts = path->GetLengthToEndOfSegment(segmentnr-1);
}
ends = path->GetLengthToEndOfSegment(segmentnr);
pathtype = path->GetSegment(segmentnr)->getIdentifier();
std::cout << "segment " << segmentnr << " runs from s="<<starts << " to s=" <<ends;
switch(pathtype) {
case Path::ID_CIRCLE:
std::cout << " circle";
break;
case Path::ID_LINE:
std::cout << " line ";
break;
default:
std::cout << " unknown ";
break;
}
std::cout << std::endl;
}
std::cout << " trajectory written to the ./trajectory.dat file " << std::endl;
delete ctraject;
} catch(Error& error) {
std::cout <<"I encountered this error : " << error.Description() << std::endl;
std::cout << "with the following type " << error.GetType() << std::endl;
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/visualize_trajectory.m | % visualize.m the output of the trajectory_example file.
% this file runs with Matlab or octave
T=load('./trajectory.dat');
figure(1);
clf;
plot3(0,0,0);
hold on;
for i=1:size(T,1)
tf = reshape(T(i,:),4,4)';
plotframe(tf,0.03);
end
axis equal;grid on;
dt=0.1;
time = (1:length(T(:,4)) )*dt;
figure(2);
subplot(4,1,1);
plot(time,T(:,4));
xlabel('time [s]');
ylabel('position x [m]');
subplot(4,1,2);
plot(time,T(:,8));
xlabel('time [s]');
ylabel('position y [m]');
subplot(4,1,3);
plot(time,T(:,12));
xlabel('time [s]');
ylabel('position z [m]');
subplot(4,1,4);
x=diff(T(:,4));
y=diff(T(:,8));
z=diff(T(:,12));
v=sqrt(x.*x + y.*y + z.*z);
plot(time(1:end-1),v);
xlabel('time [s]');
ylabel('path velocity'); | 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/README | To build one of the examples do:
g++ -I<KDL_INCLUDE_DIR> -L<KDL_LIB_DIR> -lorocos-kdl <example.cpp> -o <example>
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/examples/chainiksolverpos_lma_demo.cpp | /**
\file chainiksolverpos_lma_demo.cpp
\brief Test program for inverse position kinematics
results with 1 million inv pos kin.
<code>
#times successful 999992
#times -1 result 0
#times -2 result 5
#times -3 result 3
average number of iter 16.6437
min. nr of iter 13
max. nr of iter 500
min. difference after solving 3.86952e-12
max. difference after solving 4.79339e-05
min. trans. difference after solving 3.86952e-12
max. trans. difference after solving 4.79339e-05
min. rot. difference after solving 0
max. rot. difference after solving 0.000261335
elapsed time 199.14
estimate of average time per invposkin (ms)0.19914
estimate of longest time per invposkin (ms) 5.98245
estimate of shortest time per invposkin (ms) 0.155544
</code>
*/
/**************************************************************************
begin : May 2011
copyright : (C) 2011 Erwin Aertbelien
email : firstname.lastname@mech.kuleuven.ac.be
History (only major changes)( AUTHOR-Description ) :
***************************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307 USA *
* *
***************************************************************************/
#include <iostream>
#include <frames_io.hpp>
#include <models.hpp>
#include <chainiksolverpos_lma.hpp>
#include <chainfksolverpos_recursive.hpp>
#include <boost/timer.hpp>
/**
* tests the inverse kinematics on the given kinematic chain for a
* large number of times and provides statistics on the result.
* \TODO provide other examples.
*/
void test_inverseposkin(KDL::Chain& chain) {
using namespace KDL;
using namespace std;
boost::timer timer;
int num_of_trials = 1000000;
int total_number_of_iter = 0;
int n = chain.getNrOfJoints();
int nrofresult_ok = 0;
int nrofresult_minus1=0;
int nrofresult_minus2=0;
int nrofresult_minus3=0;
int min_num_of_iter = 10000000;
int max_num_of_iter = 0;
double min_diff = 1E10;
double max_diff = 0;
double min_trans_diff = 1E10;
double max_trans_diff = 0;
double min_rot_diff = 1E10;
double max_rot_diff = 0;
Eigen::Matrix<double,6,1> L;
L(0)=1;L(1)=1;L(2)=1;
L(3)=0.01;L(4)=0.01;L(5)=0.01;
ChainFkSolverPos_recursive fwdkin(chain);
ChainIkSolverPos_LMA solver(chain,L);
JntArray q(n);
JntArray q_init(n);
JntArray q_sol(n);
for (int trial=0;trial<num_of_trials;++trial) {
q.data.setRandom();
q.data *= M_PI;
q_init.data.setRandom();
q_init.data *= M_PI;
Frame pos_goal,pos_reached;
fwdkin.JntToCart(q,pos_goal);
//solver.compute_fwdpos(q.data);
//pos_goal = solver.T_base_head;
int retval;
retval = solver.CartToJnt(q_init,pos_goal,q_sol);
switch (retval) {
case 0:
nrofresult_ok++;
break;
case -1:
nrofresult_minus1++;
break;
case -2:
nrofresult_minus2++;
break;
case -3:
nrofresult_minus3++;
break;
}
if (retval !=0) {
cout << "-------------- failed ----------------------------" << endl;
cout << "pos " << pos_goal << endl;
cout << "reached pos " << solver.T_base_head << endl;
cout << "TF from pos to head \n" << pos_goal.Inverse()*solver.T_base_head << endl;
cout << "gradient " << solver.grad.transpose() << endl;
cout << "q " << q.data.transpose()/M_PI*180.0 << endl;
cout << "q_sol " << q_sol.data.transpose()/M_PI*180.0 << endl;
cout << "q_init " << q_init.data.transpose()/M_PI*180.0 << endl;
cout << "return value " << retval << endl;
cout << "last #iter " << solver.lastNrOfIter << endl;
cout << "last diff " << solver.lastDifference << endl;
cout << "jacobian of goal values ";
solver.display_jac(q);
std::cout << "jacobian of solved values ";
solver.display_jac(q_sol);
}
total_number_of_iter += solver.lastNrOfIter;
if (solver.lastNrOfIter > max_num_of_iter) max_num_of_iter = solver.lastNrOfIter;
if (solver.lastNrOfIter < min_num_of_iter) min_num_of_iter = solver.lastNrOfIter;
if (retval!=-3) {
if (solver.lastDifference > max_diff) max_diff = solver.lastDifference;
if (solver.lastDifference < min_diff) min_diff = solver.lastDifference;
if (solver.lastTransDiff > max_trans_diff) max_trans_diff = solver.lastTransDiff;
if (solver.lastTransDiff < min_trans_diff) min_trans_diff = solver.lastTransDiff;
if (solver.lastRotDiff > max_trans_diff) max_rot_diff = solver.lastRotDiff;
if (solver.lastRotDiff < min_trans_diff) min_rot_diff = solver.lastRotDiff;
}
fwdkin.JntToCart(q_sol,pos_reached);
}
cout << "------------------ statistics ------------------------------"<<endl;
cout << "#times successful " << nrofresult_ok << endl;
cout << "#times -1 result " << nrofresult_minus1 << endl;
cout << "#times -2 result " << nrofresult_minus2 << endl;
cout << "#times -3 result " << nrofresult_minus3 << endl;
cout << "average number of iter " << (double)total_number_of_iter/(double)num_of_trials << endl;
cout << "min. nr of iter " << min_num_of_iter << endl;
cout << "max. nr of iter " << max_num_of_iter << endl;
cout << "min. difference after solving " << min_diff << endl;
cout << "max. difference after solving " << max_diff << endl;
cout << "min. trans. difference after solving " << min_trans_diff << endl;
cout << "max. trans. difference after solving " << max_trans_diff << endl;
cout << "min. rot. difference after solving " << min_rot_diff << endl;
cout << "max. rot. difference after solving " << max_rot_diff << endl;
double el = timer.elapsed();
cout << "elapsed time " << el << endl;
cout << "estimate of average time per invposkin (ms)" << el/num_of_trials*1000 << endl;
cout << "estimate of longest time per invposkin (ms) " << el/total_number_of_iter*max_num_of_iter *1000 << endl;
cout << "estimate of shortest time per invposkin (ms) " << el/total_number_of_iter*min_num_of_iter *1000 << endl;
}
int main(int argc,char* argv[]) {
std::cout <<
" This example generates random joint positions, applies a forward kinematic transformation,\n"
<< " and calls ChainIkSolverPos_LMA on the resulting pose. In this way we are sure that\n"
<< " the resulting pose is reachable. However, some percentage of the trials will be at\n"
<< " near singular position, where it is more difficult to achieve convergence and accuracy\n"
<< " The initial position given to the algorithm is also a random joint position\n"
<< " This routine asks for an accuracy of 10 micrometer, one order of magnitude better than a\n"
<< " a typical industrial robot.\n"
<< " This routine can take more then 6 minutes to execute. It then gives statistics on execution times\n"
<< " and failures.\n"
<< " Typically when executed 1 000 000 times, you will still see some small amount of failures\n"
<< " Typically these failures are in the neighbourhoud of singularities. Most failures of type -2 still\n"
<< " reach an accuracy better than 1E-4.\n"
<< " This is much better than ChainIkSolverPos_NR, which fails a few times per 100 trials.\n";
using namespace KDL;
Chain chain;
chain = KDL::Puma560();
//chain = KDL::KukaLWR_DHnew();
ChainIkSolverPos_LMA solver(chain);
test_inverseposkin(chain);
return 0;
}
/** results with 1 million inv pos kin.
#times successful 999992
#times -1 result 0
#times -2 result 5
#times -3 result 3
average number of iter 16.6437
min. nr of iter 13
max. nr of iter 500
min. difference after solving 3.86952e-12
max. difference after solving 4.79339e-05
min. trans. difference after solving 3.86952e-12
max. trans. difference after solving 4.79339e-05
min. rot. difference after solving 0
max. rot. difference after solving 0.000261335
elapsed time 199.14
estimate of average time per invposkin (ms)0.19914
estimate of longest time per invposkin (ms) 5.98245
estimate of shortest time per invposkin (ms) 0.155544
*/
| 0 |
apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl | apollo_public_repos/apollo-platform/ros/orocos_kinematics_dynamics/orocos_kdl/doc/CMakeLists.txt |
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(docs "doxygen" "Doxyfile")
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/kdl.tag DESTINATION share/doc/liborocos-kdl/ OPTIONAL) # only installs if found.
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.