C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyCharacterPoseOverride.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 diguyCharacterPoseOverride
31  **
32  */
33 
34 #ifndef __diguyCharacterPoseOverride_H
35 #define __diguyCharacterPoseOverride_H
36 
37 
38 #ifdef SWIG
40 #else
41 #define CPLUSPLUS_ONLY
42 #endif
43 
44 #ifdef CPLUSPLUS_ONLY
45 #include <stdlib.h>
46 
47 class bdiPoseOverride;
48 class bdiScenarioCharacter;
49 class bdiTopology;
50 #endif
51 
52 
53 #include <declspec_diguy.h>
54 
55 /****************************************************************************/
56 class BDI_DECLSPEC_diguy diguyCharacterPoseOverride
57 {
58 
59 public:
60 
61 #ifdef CPLUSPLUS_ONLY
62 
63  /*l
64  *b Description:
65  **
66  ** Allocates an array of floats to hold the joint angles for
67  ** each degree of freedom, or weights to specify how pose angles
68  ** will affect a character. The size of the array will be equal
69  ** to the value returned by get_num_vars().
70  **
71  ** The allocated array should be freed by calling free_pose_array().
72  **
73  ** The allocated array will contain uninitialized values.
74  **
75  ** If the array is to hold weights, each entry in the array
76  ** should be set to a valid value between 0.0 and 1.0.
77  **
78  ** If the array is to hold pose angles, each pose variable whose
79  ** corresponding weight is going to be non-0 should be set to a
80  ** valid value.
81  **
82  *b Returns:
83  **
84  ** pointer to array of floats, NULL if the array cannot be allocated
85  **
86  *b Callable From:
87  **
88  *- - C++
89  **
90  *b C++ Example:
91  **
92  ** See example for set_pose_in_radians().
93  */
94  float* allocate_pose_array();
95 
96  /*l
97  *b Description:
98  **
99  ** Frees an array allocated with allocate_pose_array().
100  **
101  *b Arguments:
102  **
103  *a array - array of pose angles to be freed
104  **
105  *b Returns:
106  **
107  ** 0 on success, -1 on failure
108  **
109  *b Callable From:
110  **
111  *- - C++
112  */
113  int free_pose_array(float* array);
114 
115 #endif
116 
117  /*l
118  *b Description:
119  **
120  ** This function returns the number of the variables
121  ** representing joint angles.
122  **
123  *b Returns:
124  **
125  ** an integer representing the number of joint angles
126  **
127  *b Callable From:
128  **
129  *- - C++
130  *- - Script
131  */
132  int get_num_vars();
133 
134 #ifdef CPLUSPLUS_ONLY
135 
136  /*l
137  *b Description:
138  **
139  ** This function allocates an array of pointer to char*s
140  ** (i.e., C-style strings).
141  **
142  ** This array can then be passed to get_var_names().
143  **
144  ** It should be freed using the function free_var_names().
145  ** The size of the array will be equal to the value returned
146  ** by get_num_vars().
147  **
148  *b Returns:
149  **
150  ** an array of pointers to char*'s (i.e. pointers to strings)
151  **
152  *b Callable From:
153  **
154  *- - C++
155  **
156  *b C++ Example:
157  **
158  ** See example for get_var_names().
159  */
160  char** allocate_var_names();
161 
162  /*l
163  *b Description:
164  **
165  ** This function fills out the passed array of strings with
166  ** the list of the names of the variables representing joint
167  ** angles.
168  **
169  *b Arguments:
170  **
171  *a var_names - an array of strings as allocated by
172  *a allocate_var_names()
173  **
174  *b Returns:
175  **
176  ** 0 on success, -1 on failure
177  **
178  *b Callable From:
179  **
180  *- - C++
181  **
182  *b C++ Example:
183  **
184  *e //
185  *e // Create a pose override for character.
186  *e //
187  *e pose_override = character1->create_pose_override();
188  *e
189  *e //
190  *e // Allocate a list of joint angle names and fill it.
191  *e // Print the joint angle names, then destroy the array.
192  *e //
193  *e char** varnames = pose_override->allocate_var_names();
194  *e pose_override->get_var_names(varnames);
195  *e
196  *e for (i = 0; i < character1->get_pose_array_size(); i++)
197  *e bdi_log_printf(BDI_LOG_INFO, "%s\n", varnames[i]);
198  *e
199  *e pose_override->free_var_names(varnames);
200  */
201  int get_var_names(char** var_names);
202 
203  /*l
204  *b Description:
205  **
206  ** This function frees the array of strings allocated by
207  ** allocate_var_names().
208  **
209  *b Arguments:
210  **
211  *a var_names - an array of strings as allocated by
212  *a allocate_var_names()
213  **
214  *b Returns:
215  **
216  ** 0 on success, -1 on failure
217  **
218  *b Callable From:
219  **
220  *- - C++
221  */
222  int free_var_names(char** var_names);
223 
224  /*l
225  *b Description:
226  **
227  ** Get the index of the given variable in the array of pose angles.
228  **
229  *b Arguments:
230  **
231  *a varname - the name of the pose angle variable whose index is desired
232  **
233  *b Returns:
234  **
235  ** index of the pose variable, if it exists, -1 if not
236  **
237  *b Callable From:
238  **
239  *- - C++
240  **
241  *b C++ Example:
242  **
243  ** See example for set_pose_in_radians().
244  */
245  int get_var_index(const char* varname);
246 
247  /*l
248  *b Description:
249  **
250  ** This function fills out the passed array of floats with the most
251  ** recent values passed in a call to set_pose_in_radians().
252  **
253  ** Note that this may not be the actual pose of the character; this
254  ** is only the pose angles for this specific pose override. Other
255  ** pose overrides, gazing, etc., will also affect the pose of the
256  ** character. Use the function diguyCharacter::get_pose_in_radians()
257  ** to read the "real" pose of the character, as computed by the DI-Guy
258  ** motion engine.
259  **
260  *b Arguments:
261  **
262  *a pose_array - array of floats allocated by allocate_pose_array()
263  **
264  *b Returns:
265  **
266  ** 0 on success, -1 on failure
267  **
268  *b Callable From:
269  **
270  *- - C++
271  */
272  int get_pose_in_radians(float* pose_array);
273 
274  /*l
275  *b Description:
276  **
277  ** This function specifies the joint angle data that will modify
278  ** or override the joint angles the character normally computes.
279  ** The replacement data is in pose_array.
280  **
281  ** If weights array is non-NULL, then each element specifies the
282  ** proportion of the value on pose array to mix in with the value
283  ** normally computed by the character. A weight of 0.0 means to
284  ** ignore the value in pose_array. A weight of 1.0 means fully
285  ** override the value computed by the character.
286  **
287  ** If weights_array is NULL, then default_weight will be used for
288  ** *all* of the joint angles.
289  **
290  ** Note that all weights for an Euler triple (e.g. -
291  ** q.cervical_rz/rx/ry) must be equal to ensure proper
292  ** interpolation.
293  **
294  ** Also note that the first six variables that contain the character's
295  ** overall position and orientation cannot be changed using a pose
296  ** override. These values must be changed using the functions
297  ** diguyCharacter::set_position() and
298  ** diguyCharacter::set_orientation().
299  **
300  *b Arguments:
301  **
302  *a pose_array - the array containing the pose angles for this
303  *a override object
304  *a weight_array - the multiplier used to determine how the new
305  *a pose_array values are to be combined with the
306  *a existing pose
307  *a default_weight - the value to be used to set the weights if
308  *a weights_array is NULL
309  **
310  *b Returns:
311  **
312  ** 0 on success, -1 on failure
313  **
314  *b Callable From:
315  **
316  *- - C++
317  **
318  *b C++ Example:
319  **
320  *e //
321  *e // Create a pose override for character.
322  *e //
323  *e pose_override = character1->create_pose_override();
324  *e
325  *e //
326  *e // Allocate an array for pose angles.
327  *e //
328  *e pose_array = pose_override->allocate_pose_array();
329  *e for (i=0; i<pose_override->get_num_vars(); i++)
330  *e pose_array[i] = 0.0f;
331  *e
332  *e //
333  *e // Allocate a weights_array, and initialize it to all 0s.
334  *e //
335  *e weights_array = pose_override->allocate_pose_array();
336  *e for (i=0; i<pose_override->get_num_vars(); i++)
337  *e weights_array[i] = 0.0f;
338  *e
339  *e //
340  *e // Find the indices of the character's back angles. Set the
341  *e // weights for these angles in weights_array to 1.0. This
342  *e // means that when we call set_pose_in_radians(), the values
343  *e // in pose_array will completely override the original
344  *e // data for the back.
345  *e //
346  *e back_rz_index = pose_override->get_var_index("q.back_rz");
347  *e back_rx_index = pose_override->get_var_index("q.back_rx");
348  *e back_ry_index = pose_override->get_var_index("q.back_ry");
349  *e
350  *e pose_array[back_rz_index] = 0.57f; // angle measured in radians
351  *e pose_array[back_rx_index] = 0.0f; // angle measured in radians
352  *e pose_array[back_ry_index] = 0.0f; // angle measured in radians
353  *e
354  *e weights_array[back_rz_index] = 1.0f;
355  *e weights_array[back_rx_index] = 1.0f;
356  *e weights_array[back_ry_index] = 1.0f;
357  *e
358  *e pose_override->set_pose_in_radians(pose_array,
359  *e weights_array,
360  *e 0.0f);
361  */
362  int set_pose_in_radians(float* pose_array,
363  float* weights_array = NULL,
364  float default_weight = 1.0f);
365 
366 #endif
367 
368  /*l
369  *b Description:
370  **
371  ** Get the default weight for pose angles.
372  **
373  *b Returns:
374  **
375  ** the default pose angle weight
376  **
377  *b Callable From:
378  **
379  *- - C++
380  *- - Script
381  */
382  float get_default_weight();
383 
384  /*l
385  *b Description:
386  **
387  ** Set the default weight for pose angles.
388  **
389  ** The default weight will be used to set values in a pose's weights
390  ** array if the array passed in, for instance, set_pose_in_radians(),
391  ** is NULL.
392  **
393  *b Arguments:
394  **
395  *a default_weight - the desired default weight
396  **
397  *b Returns:
398  **
399  ** 0 on success, -1 on failure
400  **
401  *b Callable From:
402  **
403  *- - C++
404  *- - Script
405  */
406  int set_default_weight(float default_weight);
407 
408 
413 #ifdef CPLUSPLUS_ONLY
414 
415  bdiPoseOverride* get_scripted_object() {return m_scripted_object;}
417 private:
418 
419  /*
420  * private constructor
421  */
422  diguyCharacterPoseOverride(bdiPoseOverride* scripted_object,
423  bdiScenarioCharacter* character);
424 
425  /*
426  * private destructor
427  */
428  virtual ~diguyCharacterPoseOverride();
429 
430  /*
431  * internal data
432  */
433  bdiPoseOverride* m_scripted_object;
434  bdiScenarioCharacter* m_character;
435 
436  friend class bdiPoseOverride;
437  friend class diguyCharacter;
438  friend class bdiScenarioCharacter;
439 
440 #endif
441 
442 };
443 
444 
445 #endif /* __diguyCharacterPoseOverride_H */
446 
447 
448 /*
449  * Copyright (C) 1992-2013 Boston Dynamics
450  * ALL RIGHTS RESERVED.
451  *
452  * These coded instructions, statements, and computer programs
453  * contain unpublished proprietary information of Boston Dynamics
454  * and are protected by Copyright Laws of the United States.
455  * They may not be used, duplicated, or disclosed in any form, in
456  * whole or in part, without the prior written consent from Boston
457  * Dynamics.
458  *
459  * RESTRICTED RIGHTS LEGEND
460  * Use, duplication, or disclosure by the government is subject
461  * to restrictions as set forth in FAR 52.227.19(c)(2) or
462  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
463  * Computer Software clause at DFARS 252.227-7013 and/or in
464  * similar or successor clauses in the FAR, or the DOD or NASA
465  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
466  * Commercial Computer Software--Restricted Rights at 48 CFR
467  * 52.227-19, as applicable. Unpublished-rights reserved under
468  * the Copyright Laws of the United States.
469  * Contractor/Manufacturer is:
470  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
471  */
472 
473 
474 
475 
476 
477 
478 
479