Simbody  3.4 (development)
ObservedPointFitter.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMBODY_OBSERVED_POINT_FITTER_H_
00002 #define SimTK_SIMBODY_OBSERVED_POINT_FITTER_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                               Simbody(tm)                                  *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2007-12 Stanford University and the Authors.        *
00013  * Authors: Peter Eastman                                                     *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "SimTKcommon.h"
00028 #include "simbody/internal/common.h"
00029 #include "simbody/internal/MultibodySystem.h"
00030 
00031 namespace SimTK {
00032 
00045 class SimTK_SIMBODY_EXPORT ObservedPointFitter {
00046 public:
00052     static Real findBestFit
00053        (const MultibodySystem&             system, 
00054         State&                             state, 
00055         const Array_<MobilizedBodyIndex>&  bodyIxs, 
00056         const Array_<Array_<Vec3> >&       stations, 
00057         const Array_<Array_<Vec3> >&       targetLocations, 
00058         Real                               tolerance=0.001);
00059 
00061     static Real findBestFit
00062        (const MultibodySystem&                  system, 
00063         State&                                  state, 
00064         const std::vector<MobilizedBodyIndex>&  bodyIxs, 
00065         const std::vector<std::vector<Vec3> >&  stations, 
00066         const std::vector<std::vector<Vec3> >&  targetLocations, 
00067         Real                                    tolerance=0.001) 
00068     {
00069         Array_<Array_<Vec3> > stationCopy(stations);
00070         Array_<Array_<Vec3> > targetCopy(targetLocations);
00071         return findBestFit(system,state,
00072                     ArrayViewConst_<MobilizedBodyIndex>(bodyIxs), // no copying here
00073                     stationCopy, targetCopy, tolerance);
00074     }
00075 
00090     static Real findBestFit
00091        (const MultibodySystem&             system, 
00092         State&                             state, 
00093         const Array_<MobilizedBodyIndex>&  bodyIxs, 
00094         const Array_<Array_<Vec3> >&       stations, 
00095         const Array_<Array_<Vec3> >&       targetLocations, 
00096         const Array_<Array_<Real> >&       weights, 
00097         Real                               tolerance=0.001);
00098 
00100     static Real findBestFit
00101        (const MultibodySystem&                  system, 
00102         State&                                  state, 
00103         const std::vector<MobilizedBodyIndex>&  bodyIxs, 
00104         const std::vector<std::vector<Vec3> >&  stations, 
00105         const std::vector<std::vector<Vec3> >&  targetLocations, 
00106         const std::vector<std::vector<Real> >&  weights, 
00107         Real                                    tolerance=0.001)
00108     {
00109         Array_<Array_<Vec3> > stationCopy(stations);
00110         Array_<Array_<Vec3> > targetCopy(targetLocations);
00111         Array_<Array_<Real> > weightCopy(weights);
00112         return findBestFit(system,state,
00113                     ArrayViewConst_<MobilizedBodyIndex>(bodyIxs), // no copying here
00114                     stationCopy, targetCopy, weightCopy,
00115                     tolerance);
00116     }
00117 
00118 
00119 private:
00120     static void createClonedSystem(const MultibodySystem& original, MultibodySystem& copy, const Array_<MobilizedBodyIndex>& originalBodyIxs, Array_<MobilizedBodyIndex>& copyBodyIxs, bool& hasArtificialBaseBody);
00121     static void findUpstreamBodies(MobilizedBodyIndex currentBodyIx, const Array_<int> numStations, const SimbodyMatterSubsystem& matter, Array_<MobilizedBodyIndex>& bodyIxs, int requiredStations);
00122     static void findDownstreamBodies(MobilizedBodyIndex currentBodyIx, const Array_<int> numStations, const Array_<Array_<MobilizedBodyIndex> > children, Array_<MobilizedBodyIndex>& bodyIxs, int& requiredStations);
00123     static int findBodiesForClonedSystem(MobilizedBodyIndex primaryBodyIx, const Array_<int> numStations, const SimbodyMatterSubsystem& matter, const Array_<Array_<MobilizedBodyIndex> > children, Array_<MobilizedBodyIndex>& bodyIxs);
00124     class OptimizerFunction;
00125 };
00126 
00127 } // namespace SimTK
00128 
00129 #endif // SimTK_SIMBODY_OBSERVED_POINT_FITTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines