1 /***************************************************************************** 2 * DynaMechs: A Multibody Dynamic Simulation Library 3 * 4 * Copyright (C) 1994-2001 Scott McMillan All Rights Reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with this library; if not, write to the Free 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 ***************************************************************************** 20 * File: dmTreadmill.hpp 21 * Author: Steven Rodenbaugh 22 * Created: 2000 23 * Summary: class definition for a dynamic environment with a treadmill 24 *****************************************************************************/ 25 26 #ifndef _DM_TREADMILL_HPP 27 #define _DM_TREADMILL_HPP 28 29 #include <dm.h> 30 #include <dmObject.hpp> 31 #include <dmEnvironment.hpp> 32 33 #include <vector> 34 35 //====================================================================== 36 37 /* Steven Rodenbaugh writes.... 38 39 General Notes: 40 - Might make this be a child a general class like dmMovingEnvironment 41 - Need generalized way to specify environment type -probably change to env file 42 - Need permission from Scott to be using his code? 43 - Need class description here 44 - Should probably add OpenGL support equivalent to rest of DynaMechs 45 46 - The parsing method follows the same technique utilized in the rest of 47 of DynaMechs (This does have the drawback that there is not a graceful 48 recovery from parse errors. In the future, that should probably be 49 addressed.) 50 - The information that strictly concerns the graphical representation is 51 included in another file because it does not impact the simulation 52 */ 53 54 55 //====================================================================== 56 57 /** 58 The treadmill is a dynamic environment requiring simulation to update its 59 state. It can be thought of as surface with a horizontal velocity 60 component. It has a length along the direction of motion, width 61 perpendicular in the horizontal plane, and a normal (up) direction. 62 63 It is derived from {\tt dmEnvironment}, and when hydrodynamics are enabled 64 in the build, this class appends to the base class state vectors. 65 */ 66 67 68 class DM_DLL_API dmTreadmill : public dmEnvironment 69 { 70 public: 71 /// 72 dmTreadmill(); 73 /// 74 virtual ~dmTreadmill(); 75 76 /// 77 void setPosition(const CartesianVector position); 78 /// 79 void getPosition(CartesianVector pos) const; 80 81 /// 82 void setWidth (Float width); 83 /// 84 Float getWidth() const; 85 86 /// 87 void setLength (Float length); 88 /// 89 Float getLength() const; 90 91 // dmSystem functions 92 /// getNumDOFs() const93 virtual unsigned int getNumDOFs() const 94 { 95 return dmEnvironment::getNumDOFs() + 1; 96 } 97 /// 98 virtual void setState(Float treadmill_pos[], Float treadmill_vel[]); 99 /// 100 virtual void getState(Float treadmill_pos[], Float treadmill_vel[]) const; 101 102 /// 103 void setVelocityDirection(const CartesianVector v_dir); 104 /// 105 void getVelocityDirection(CartesianVector v_dir) const; 106 107 /// 108 void setNormalDirection(const CartesianVector normal); 109 /// 110 void getNormalDirection(CartesianVector normal) const; 111 112 /// These functions should be moved to the loader 113 //void loadConveyorData(const char *filename); 114 /// 115 //const char *getConveyorFilename() const {return m_conveyor_filename;} 116 117 /// 118 //virtual Float getGroundDepth(CartesianVector contact_pos, 119 // CartesianVector ground_normal); 120 121 /// 122 //virual Float getGroundElevation(CartesianVector contact_pos, 123 // CartesianVector ground_normal); 124 125 // dynamics algorithm 126 /// 127 virtual void dynamics(Float *qy, Float *qdy); 128 virtual void draw() const; 129 130 protected: // Functions 131 void computeOrientation(); 132 133 private: // Functions 134 dmTreadmill(const dmTreadmill &); 135 dmTreadmill &operator=(const dmTreadmill &); 136 137 private: // Variables 138 Float m_half_width; 139 Float m_half_length; 140 CartesianVector m_position; 141 CartesianVector m_normal; // normalized 142 CartesianVector m_forward; // normalized 143 CartesianVector m_left; // normalized 144 145 Float m_q, m_qd, m_qdd; 146 147 //CartesianVector m_earthz; 148 HomogeneousTransformationMatrix m_eTc, m_cTe; 149 }; 150 151 #endif 152