RcsPySim
A robot control and simulation library
BodyParamInfo.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (c) 2020, Fabio Muratore, Honda Research Institute Europe GmbH, and
3  Technical University of Darmstadt.
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8  1. Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10  2. Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  3. Neither the name of Fabio Muratore, Honda Research Institute Europe GmbH,
14  or Technical University of Darmstadt, nor the names of its contributors may
15  be used to endorse or promote products derived from this software without
16  specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL FABIO MURATORE, HONDA RESEARCH INSTITUTE EUROPE GMBH,
22  OR TECHNICAL UNIVERSITY OF DARMSTADT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  POSSIBILITY OF SUCH DAMAGE.
29 *******************************************************************************/
30 
31 #ifndef _BODYPARAMINFO_H
32 #define _BODYPARAMINFO_H
33 
34 #include <Rcs_graph.h>
35 
36 #include <PhysicsConfig.h>
37 
38 #include <string>
39 
40 namespace Rcs
41 {
42 
43 /**
44  * Information on a body and changing physics params.
45  *
46  * Apart from the body, this struct holds material parameters not storable in RcsBody, and flags to track modified parameters.
47  */
49 {
51  {
52  MOD_MASS = 1 << 0, // body mass changed
53  MOD_COM = 1 << 1, // body center of gravity changed
54  MOD_INERTIA = 1 << 2, // body inertia changed
55  MOD_SHAPE = 1 << 3, // collision shapes changed
56  MOD_POSITION = 1 << 4, // position changed
57  MOD_ORIENTATION = 1 << 5 // orientation changed
58  };
59 
60  //! The graph containing the body
61  RcsGraph* graph;
62 
63  //! The body
64  RcsBody* body;
65 
66  //! prefix for parameter names
67  std::string paramNamePrefix;
68 
69  //! Material of the body's first shape
70  PhysicsMaterial material;
71 
72  //! Flags tracking the modified state of the body
74 
75  BodyParamInfo(RcsGraph* graph, const char* bodyName, PhysicsConfig* physicsConfig);
76 
77  //! Reset all change flags
78  void resetChanged();
79 
80  //! Check if a parameter changed
81  inline bool isChanged(int flag)
82  {
83  return (modifiedFlag & flag) == flag;
84  }
85 
86  //! Mark if a parameter as changed
87  inline void markChanged(int flag)
88  {
89  modifiedFlag |= flag;
90  }
91 };
92 
93 } // namespace Rcs
94 
95 #endif //_BODYPARAMINFO_H
BodyParamInfo(RcsGraph *graph, const char *bodyName, PhysicsConfig *physicsConfig)
void resetChanged()
Reset all change flags.
RcsBody * body
The body.
Definition: BodyParamInfo.h:64
int modifiedFlag
Flags tracking the modified state of the body.
Definition: BodyParamInfo.h:73
std::string paramNamePrefix
prefix for parameter names
Definition: BodyParamInfo.h:67
void markChanged(int flag)
Mark if a parameter as changed.
Definition: BodyParamInfo.h:87
bool isChanged(int flag)
Check if a parameter changed.
Definition: BodyParamInfo.h:81
RcsGraph * graph
The graph containing the body.
Definition: BodyParamInfo.h:61
PhysicsMaterial material
Material of the body&#39;s first shape.
Definition: BodyParamInfo.h:70