1 #ifndef OPENSIM_PLANAR_JOINT_H_
2 #define OPENSIM_PLANAR_JOINT_H_
3 /* -------------------------------------------------------- ----------------- *
4  *                         OpenSim:  PlanarJoint.h                            *
5  * -------------------------------------------------------------------------- *
6  * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
7  * See http://opensim.stanford.edu and the NOTICE file for more information.  *
8  * OpenSim is developed at Stanford University and supported by the US        *
9  * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
10  * through the Warrior Web program.                                           *
11  *                                                                            *
12  * Copyright (c) 2005-2017 Stanford University and the Authors                *
13  * Author(s): Ajay Seth                                                       *
14  *                                                                            *
15  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
16  * not use this file except in compliance with the License. You may obtain a  *
17  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
18  *                                                                            *
19  * Unless required by applicable law or agreed to in writing, software        *
20  * distributed under the License is distributed on an "AS IS" BASIS,          *
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
22  * See the License for the specific language governing permissions and        *
23  * limitations under the License.                                             *
24  * -------------------------------------------------------------------------- */
25 
26 
27 // INCLUDE
28 #include "Joint.h"
29 
30 namespace OpenSim {
31 
32 //=============================================================================
33 //=============================================================================
34 /**
35 A class implementing a Planar joint. The underlying implementation
36 in Simbody is a SimTK::MobilizedBody::Planar. A Planar joint provides three
37 ordered mobilities; rotation about Z and translation in X then Y.
38 
39 \image html planarJoint.gif
40 
41 @author Ajay Seth
42 */
43 class OSIMSIMULATION_API PlanarJoint : public Joint {
44 OpenSim_DECLARE_CONCRETE_OBJECT(PlanarJoint, Joint);
45 
46 public:
47     /** Indices of Coordinates for use as arguments to getCoordinate() and
48         updCoordinate().
49 
50         <b>C++ example</b>
51         \code{.cpp}
52         const auto& rz = myPlanarJoint.
53                          getCoordinate(PlanarJoint::Coord::RotationZ);
54         \endcode
55 
56         <b>Python example</b>
57         \code{.py}
58         import opensim
59         rz = myPlanarJoint.getCoordinate(opensim.PlanarJoint.Coord_RotationZ)
60         \endcode
61 
62         <b>Java example</b>
63         \code{.java}
64         rz = myPlanarJoint.getCoordinate(PlanarJoint.Coord.RotationZ);
65         \endcode
66 
67         <b>MATLAB example</b>
68         \code{.m}
69         rz = myPlanarJoint.get_coordinates(0);
70         \endcode
71     */
72     enum class Coord: unsigned {
73         RotationZ    = 0u, ///< 0
74         TranslationX = 1u, ///< 1
75         TranslationY = 2u  ///< 2
76     };
77 
78 private:
79     /** Specify the Coordinates of the GimbalJoint */
80     CoordinateIndex rz{ constructCoordinate(Coordinate::MotionType::Rotational,
81                                     static_cast<unsigned>(Coord::RotationZ)) };
82     CoordinateIndex tx{ constructCoordinate(Coordinate::MotionType::Translational,
83                                     static_cast<unsigned>(Coord::TranslationX)) };
84     CoordinateIndex ty{ constructCoordinate(Coordinate::MotionType::Translational,
85                                     static_cast<unsigned>(Coord::TranslationY)) };
86 
87 public:
88     /** Use Joint's constructors. @see Joint */
89     using Joint::Joint;
90 
91     /** Exposes getCoordinate() method defined in base class (overloaded below).
92         @see Joint */
93     using Joint::getCoordinate;
94 
95     /** Exposes updCoordinate() method defined in base class (overloaded below).
96         @see Joint */
97     using Joint::updCoordinate;
98 
99     /** Get a const reference to a Coordinate associated with this Joint.
100         @see Coord */
getCoordinate(Coord idx)101     const Coordinate& getCoordinate(Coord idx) const {
102         return get_coordinates( static_cast<unsigned>(idx) );
103     }
104 
105     /** Get a writable reference to a Coordinate associated with this Joint.
106         @see Coord */
updCoordinate(Coord idx)107     Coordinate& updCoordinate(Coord idx) {
108         return upd_coordinates( static_cast<unsigned>(idx) );
109     }
110 
111 protected:
112     /** Model component interface */
113     void extendAddToSystem(SimTK::MultibodySystem& system) const override;
114 
115 //=============================================================================
116 };  // END of class PlanarJoint
117 //=============================================================================
118 //=============================================================================
119 
120 } // end of namespace OpenSim
121 
122 #endif // OPENSIM_PLANAR_JOINT_H_
123