C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyChainSimulation.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 1992-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer programs
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 
28 /*********************************************************************
29  **
30  *t diguyChainSimulation
31  **
32  */
33 
34 #ifndef __diguyChainSimulation_H
35 #define __diguyChainSimulation_H
36 
37 
38 #ifdef SWIG
40 #else
41 #define CPLUSPLUS_ONLY
42 #endif
43 
44 #ifdef CPLUSPLUS_ONLY
45 class bdiScenarioChain;
46 class bdiScenarioChainSettings;
47 class diguyChainSettings;
48 class diguyPathShape;
49 #endif
50 
51 
52 #include <declspec_diguy.h>
53 
54 /****************************************************************************/
55 class BDI_DECLSPEC_diguy diguyChainSimulation
56 {
57 
58 public:
59 
60  /*l
61  *b Description:
62  **
63  ** This function returns the chain settings this chain simulation is
64  ** using.
65  **
66  *b Returns:
67  **
68  ** object of type diguyChainSettings; will never be NULL
69  **
70  *b Callable From:
71  **
72  *- - C++
73  *- - Script
74  */
75  diguyChainSettings* get_settings();
76 
77  /*l
78  *b Description:
79  **
80  ** This function sets the settings this chain simulation will use.
81  **
82  *b Arguments:
83  **
84  *a settings - name of new settings to use
85  **
86  *b Returns:
87  **
88  ** 0 on success, -1 on failure
89  **
90  *b Callable From:
91  **
92  *- - C++
93  *- - Script
94  */
95  int update_settings(const char* settings);
96 
97  /*l
98  *b Description:
99  **
100  ** This function runs the simulation forward the specified number of
101  ** seconds, to let the chain settle into a stable configuration.
102  **
103  ** Note that the chain will appear to achieve the new configuration
104  ** instantly.
105  **
106  ** Specifying a large amount of time can result in a frame rate
107  ** hitch.
108  **
109  *b Arguments:
110  **
111  *a time_runoff - how much time to run off, in seconds
112  **
113  *b Returns:
114  **
115  ** 0 on success, -1 on failure
116  **
117  *b Callable From:
118  **
119  *- - C++
120  *- - Script
121  */
122  int do_stabilization_time_runoff(float time_runoff);
123 
124  /*l
125  *b Description:
126  **
127  ** This function can 'freeze' or 'unfreeze' a chain.
128  **
129  ** If a chain is frozen, all chain masses will remain in their
130  ** current positions and will not move until the chain is unfrozen.
131  **
132  ** A frozen chain requires no simulation time.
133  **
134  *b Arguments:
135  **
136  *a is_frozen - pass 1 to freeze the chain; 0 to unfreeze
137  **
138  *b Callable From:
139  **
140  *- - C++
141  *- - Script
142  */
143  void set_is_frozen(int is_frozen);
144 
145  /*l
146  *b Returns:
147  **
148  ** 1 if chain is frozen, 0 if not
149  **
150  *b Callable From:
151  **
152  *- - C++
153  *- - Script
154  */
155  int get_is_frozen();
156 
157  /*l
158  *b Description:
159  **
160  ** This function connects a chain mass to a character, or disconnects
161  ** a chain mass if the passed character_name is NULL.
162  **
163  ** As the character moves the chain mass will move with it, dragging
164  ** adjacent masses along. This allows a firefighter to pick up one
165  ** end of a hose and drag the hose to a new location, for example.
166  **
167  ** In each time-step of the scenario a new position for the specified
168  ** chain mass will be computed based on the position of the
169  ** character.
170  **
171  ** When the chain sim is created, and when the scenario is reset, one
172  ** chain mass will be automatically connected to the chain's
173  ** character. The index of the mass that will be connected is set by
174  ** a call to
175  ** diguyChainSettings::set_index_of_chain_mass_connected_to_character().
176  **
177  ** Chain masses can be connected to a specific link of the connection
178  ** character by passing the link's name. If NULL is passed, the
179  ** connection will be made to the character's "position" link. Note
180  ** that a non-NULL link name must be used for the link offset
181  ** arguments to have an effect.
182  **
183  ** The chain mass can gradually be shifted from its current position
184  ** to the connection position using the connection_smoothing_period
185  ** argument. Passing in 0.5, for example, will cause the link to
186  ** shift to its new connection point within approximately 0.5
187  ** seconds, avoiding an abrupt and potentially ugly impulse to the
188  ** simulation.
189  **
190  *b Arguments:
191  **
192  *a chain_mass_index - index of chain mass
193  *a character_name - name of character to attach to; must not be NULL
194  *a link_name - name of link to attach to; can be NULL; if
195  *a so, will attach to character's base position
196  *a link_offset_x - link attachment offset in X
197  *a link_offset_y - link attachment offset in Y
198  *a link_offset_z - link attachment offset in Z
199  *a connection_smoothing_period - how much time to take, in seconds,
200  *a to gradually shift the chain mass
201  *a to its new connection point
202  **
203  *b Returns:
204  **
205  ** 0 on success, -1 on failure
206  **
207  *b Callable From:
208  **
209  *- - C++
210  *- - Script
211  */
212  int set_chain_mass_connection_character(int chain_mass_index,
213  const char* character_name,
214  const char* link_name = NULL,
215  float link_offset_x = 0.0f,
216  float link_offset_y = 0.0f,
217  float link_offset_z = 0.0f,
218  float connection_smoothing_period = 0.1f);
219 
220  /*l
221  *b Description:
222  **
223  ** This function sets the position of one chain mass, and optionally
224  ** fixes it there.
225  **
226  ** The passed position is always relative to the chain character's
227  ** parent, if there is one.
228  **
229  ** If the fix_mass_position argument is 1, the chain mass will remain
230  ** fixed in the new position, as if
231  ** set_chain_mass_position_is_fixed(1) were called.
232  **
233  *b Arguments:
234  **
235  *a chain_mass_index - index of chain mass; pass -1 to
236  *a affect all chain masses
237  *a mass_x - position x
238  *a mass_y - position y
239  *a mass_z - position z
240  *a fix_mass_position - pass 1 to fix chain mass in place;
241  *a 0 to leave it free to move
242  **
243  *b Returns:
244  **
245  ** 0 on success, -1 on failure
246  **
247  *b Callable From:
248  **
249  *- - C++
250  *- - Script
251  */
252  int set_chain_mass_position(int chain_mass_index,
253  float mass_x,
254  float mass_y,
255  float mass_z,
256  int fix_mass_position);
257 
258  /*l
259  *b Description:
260  **
261  ** This function sets the positions of all chain masses to lie along
262  ** the passed path shape.
263  **
264  ** If the stretch_to_fit argument is 1, chain masses will be spaced
265  ** along the entire length of the path shape. If the path shape is
266  ** longer than the nominal length of the chain, the chain will be
267  ** stretched out. If the path shape is shorter, the chain will be
268  ** compressed.
269  **
270  *b Arguments:
271  **
272  *a path_shape - path shape for new chain mass positions
273  *a stretch_to_fit - pass 1 to stretch chain to take up entire
274  *a length of path_shape; pass 0 to leave
275  *a chain at its nominal length
276  **
277  *b Returns:
278  **
279  ** 0 on success, -1 on failure
280  **
281  *b Callable From:
282  **
283  *- - C++
284  *- - Script
285  */
286  int set_chain_mass_positions_along_path_shape(diguyPathShape* path_shape,
287  int stretch_to_fit = 1);
288 
289  /*l
290  *b Description:
291  **
292  ** This function can fix or unfix a chain mass in place. If it is
293  ** fixed the chain mass will remain in its current position until it
294  ** is unfixed.
295  **
296  ** Fixed chain masses do not require simulation time, so the more
297  ** masses in a chain that are fixed, the lower the computational load
298  ** of the chain simulation.
299  **
300  *b Arguments:
301  **
302  *a chain_mass_index - index of chain mass; pass -1 to
303  *a affect all chain masses
304  *a is_fixed - pass 1 to fix chain mass position;
305  *a 0 to unfix it
306  **
307  *b Returns:
308  **
309  ** 0 on success, -1 on failure
310  **
311  *b Callable From:
312  **
313  *- - C++
314  *- - Script
315  */
316  int set_chain_mass_position_is_fixed(int chain_mass_index,
317  int is_fixed);
318 
319  /*l
320  *b Returns:
321  **
322  ** 1 if chain mass is fixed, 0 if not
323  **
324  *b Callable From:
325  **
326  *- - C++
327  *- - Script
328  */
329  int get_chain_mass_position_is_fixed(int mass_index);
330 
331  /*l
332  *b Returns:
333  **
334  ** length of the chain
335  **
336  *b Callable From:
337  **
338  *- - C++
339  *- - Script
340  */
341  float get_length();
342 
343 
348 #ifdef CPLUSPLUS_ONLY
349 
350  bdiScenarioChain* get_scripted_object() {return m_scripted_object;}
351 
352 private:
353 
354  /*l
355  ** A private constructor.
356  */
357  diguyChainSimulation(bdiScenarioChain* scripted_object);
358 
359  /*l
360  ** A private destructor.
361  */
363 
364  /*l
365  ** A pointer to internal data.
366  */
367  bdiScenarioChain* m_scripted_object;
368 
369  friend class bdiScenarioChain;
370 
371 #endif
372 
373 };
374 
375 
376 #endif /* __diguyChainSimulation_H */
377 
378 
379 /*
380  * Copyright (C) 1992-2013 Boston Dynamics
381  * ALL RIGHTS RESERVED.
382  *
383  * These coded instructions, statements, and computer programs
384  * contain unpublished proprietary information of Boston Dynamics
385  * and are protected by Copyright Laws of the United States.
386  * They may not be used, duplicated, or disclosed in any form, in
387  * whole or in part, without the prior written consent from Boston
388  * Dynamics.
389  *
390  * RESTRICTED RIGHTS LEGEND
391  * Use, duplication, or disclosure by the government is subject
392  * to restrictions as set forth in FAR 52.227.19(c)(2) or
393  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
394  * Computer Software clause at DFARS 252.227-7013 and/or in
395  * similar or successor clauses in the FAR, or the DOD or NASA
396  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
397  * Commercial Computer Software--Restricted Rights at 48 CFR
398  * 52.227-19, as applicable. Unpublished-rights reserved under
399  * the Copyright Laws of the United States.
400  * Contractor/Manufacturer is:
401  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
402  */
403