From: <jpi...@us...> - 2011-11-07 21:16:16
|
Revision: 9025 http://octave.svn.sourceforge.net/octave/?rev=9025&view=rev Author: jpicarbajal Date: 2011-11-07 21:16:09 +0000 (Mon, 07 Nov 2011) Log Message: ----------- robotics. adding subfolders Added Paths: ----------- trunk/octave-forge/extra/robotics/ trunk/octave-forge/extra/robotics/DESCRIPTION trunk/octave-forge/extra/robotics/INDEX trunk/octave-forge/extra/robotics/PKG_DEL trunk/octave-forge/extra/robotics/devel/ trunk/octave-forge/extra/robotics/inst/ trunk/octave-forge/extra/robotics/inst/@Quaternion/ trunk/octave-forge/extra/robotics/inst/@Quaternion/Quaternion.m trunk/octave-forge/extra/robotics/inst/@Quaternion/private/ trunk/octave-forge/extra/robotics/inst/@Quaternion/private/q2Q.m trunk/octave-forge/extra/robotics/inst/@Quaternion/private/wrapperfield.m trunk/octave-forge/extra/robotics/inst/@Quaternion/subsref.m Removed Paths: ------------- trunk/octave-forge/extra/robotics/ Added: trunk/octave-forge/extra/robotics/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/robotics/DESCRIPTION (rev 0) +++ trunk/octave-forge/extra/robotics/DESCRIPTION 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,11 @@ +Name: Robotics +Version: 0.0.1 +Date: 2011-11-7 +Author: Peter Corke <pet...@gm...>, Juan Pablo Carbajal <car...@if...> +Maintainer: Juan Pablo Carbajal <car...@if...> +Title: Robotics Toolbox +Description: Toolbox for simulation in robotics and control. +Depends: octave (>= 3.4.0), quaternions_oo +Autoload: no +License: GPL version 3 or later and LGPL +Url: http://octave.sf.net, http://petercorke.com/Robotics_Toolbox.html Added: trunk/octave-forge/extra/robotics/INDEX =================================================================== --- trunk/octave-forge/extra/robotics/INDEX (rev 0) +++ trunk/octave-forge/extra/robotics/INDEX 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,3 @@ +robotics >> Robotics Toolbox +Quaternions + @Quaternions/Quaternions Added: trunk/octave-forge/extra/robotics/PKG_DEL =================================================================== --- trunk/octave-forge/extra/robotics/PKG_DEL (rev 0) +++ trunk/octave-forge/extra/robotics/PKG_DEL 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,17 @@ +%1 +dirlist = {}; +dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); + +if (! exist (fullfile (dirname, "inst"), "dir")) + for ii=1:length (dirlist) + ## Run this if the package is installed + rmpath ( [ dirname filesep dirlist{ii}]) + end +else + warning("robotics:Devel","Removing path for testing."); + for ii=1:length(dirlist) + rmpath ([ dirname "/inst/" dirlist{ii}]) + endfor +endif + +clear dirlist dirname Added: trunk/octave-forge/extra/robotics/inst/@Quaternion/Quaternion.m =================================================================== --- trunk/octave-forge/extra/robotics/inst/@Quaternion/Quaternion.m (rev 0) +++ trunk/octave-forge/extra/robotics/inst/@Quaternion/Quaternion.m 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,71 @@ +## Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +## +## 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 3 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, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{Q} =} Quaternion () +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{q1}) +## @deftypefnx {Function File} {@var{Q} =} Quaternion ([@var{s} @var{x} @var{y} @var{z}]) +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{s}) +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{v}) +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{th},@var{v}) +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{r}) +## @deftypefnx {Function File} {@var{Q} =} Quaternion (@var{t}) +## Create an object of the Quaternion class. +## +## This is a wrapper class of the quaterion class of the quaternions_oo package. +## +## Quaternion() is the identitity quaternion 1<0,0,0> representing a null +## rotation. +## +## Quaternion (@var{q1}) is a copy of the quaternion Q1 +## +## Quaternion ([@var{s} @var{x} @var{y} @var{z}]) is a quaternion formed by +## specifying directly its 4 elements +## +## Quaternion (@var{s}) is a quaternion formed from the scalar S and zero vector +## part: S<0,0,0> +## +## Quaternion (@var{v}) is a pure quaternion with the specified vector part: 0<V> +## +## Quaternion (@var{th},@var{v}) is a unit quaternion corresponding to rotation +## of TH about the vector V. +## +## Quaternion (@var{r}) is a unit quaternion corresponding to the orthonormal +## rotation matrix R. +## +## Quaternion (@var{t}) is a unit quaternion equivalent to the rotational part +## of the homogeneous transform T. +## +## @seealso{quaternion} +## @end deftypefn + +function Q = Quaternions(varargin) + + switch nargin + case 0 + Q = struct("q_wrap",quaternion(1,0,0,0), "R",eye(3),"T",[eye(3) zeros(3,1); 0 0 0 1],... + "s",1,"v",[0 0 0]); + otherwise + error("robotics:Devel","multiple constructors not implemented"); + end + + Q = class (Q, 'Quaternion'); + +endfunction + +%!test +%! Q = Quaternion(); + +%!error Quaternion([1 0 0 0]) Added: trunk/octave-forge/extra/robotics/inst/@Quaternion/private/q2Q.m =================================================================== --- trunk/octave-forge/extra/robotics/inst/@Quaternion/private/q2Q.m (rev 0) +++ trunk/octave-forge/extra/robotics/inst/@Quaternion/private/q2Q.m 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,33 @@ +## Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +## +## 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 3 of the License, or +## 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, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} q2Q (@var{obj}) +## Convertas a quaterion in to a Quaternion. +## +## @end deftypefn + +function Q = q2Q (Q,q) + + Q.s = q(0); + Q.v(1) = q(1); + Q.v(2) = q(2); + Q.v(3) = q(3); + + ## TODO Rest of the fields + + warning("robotics:Devel","Conversion from quaternion to Quaterninon not finished."); + +endfunction Added: trunk/octave-forge/extra/robotics/inst/@Quaternion/private/wrapperfield.m =================================================================== --- trunk/octave-forge/extra/robotics/inst/@Quaternion/private/wrapperfield.m (rev 0) +++ trunk/octave-forge/extra/robotics/inst/@Quaternion/private/wrapperfield.m 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,24 @@ +## Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +## +## 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 3 of the License, or +## 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, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} warapperfield (@var{obj}) +## Returns the wrapped quaternion. +## +## @end deftypefn + +function q = wrapperfield (obj) + q = obj.q_wrap; +endfunction Added: trunk/octave-forge/extra/robotics/inst/@Quaternion/subsref.m =================================================================== --- trunk/octave-forge/extra/robotics/inst/@Quaternion/subsref.m (rev 0) +++ trunk/octave-forge/extra/robotics/inst/@Quaternion/subsref.m 2011-11-07 21:16:09 UTC (rev 9025) @@ -0,0 +1,87 @@ +## Copyright (C) 2011 Carnë Draug <car...@gm...> +## Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> +## Improvement based on John W. Eaton's idea. +## +## 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 3 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, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} subsrefs () +## @end deftypefn + +function varargout = subsref (obj, idx) + + persistent __method__ method4field typeNotImplemented + if isempty(__method__) + + __method__ = struct(); + + __method__.inv = @(o,a) q2Q(obj, conj(wrapperfield(obj))); + + __method__.norm = @(o,a) abs(wrapperfield(obj)); + + __method__.unit = @(o,a) error(typeNotImplemented,'unit',o); + + __method__.unitize = @(o,a) error(typeNotImplemented,'unitize',o); + + __method__.plot = @(o,a) error(typeNotImplemented,'plot',o); + + __method__.interp = @(o,a) error(typeNotImplemented,'interp',o); + + __method__.scale = @(o,a) error(typeNotImplemented,'scale',o); + + __method__.dot = @(o,a) error(typeNotImplemented,'dot',o); + + # Error strings + method4field = "Class %s has no field %s. Use %s() for the method."; + typeNotImplemented = "%s no implemented for class %s."; + + end + + if ( !strcmp (class (obj), 'Quaternion') ) + error ("Object must be of the Quaternion class but '%s' was used", class (obj) ); + elseif ( idx(1).type != '.' ) + error ("Invalid index for class %s", class (obj) ); + endif + + method = idx(1).subs; + if ~isfield(__method__, method) + error('Unknown method %s.',method); + else + fhandle = __method__.(method); + end + + if numel (idx) == 1 % can't access properties, only methods + + error (method4field, class (obj), method, method); + + end + + if strcmp (idx(2).type, '()') + + args = idx(2).subs; + if isempty(args) + out = fhandle (obj); + else + out = fhandle (obj, args{:}); + end + + varargout{1} = out; + + else + + error (typeNotImplemented,[method idx(2).type], class (obj)); + + end + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |