HAPTIX API

haptix_sim.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
21 
22 #ifndef __HAPTIX_SIM_API_HAPTIX_H__
23 #define __HAPTIX_SIM_API_HAPTIX_H__
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "haptix.h"
30 
31 // ---------- constants ----------
32 
34 #define hxsMAXCONTACT 200
35 
37 #define hxsMAXLINKS 100
38 
40 #define hxsMAXJOINTS 50
41 
43 #define hxsMAXMODELS 50
44 
46 #define hxsMAXNAMESIZE 100
47 
61 typedef enum {hxsNOCOLLIDE, hxsDETECTIONONLY, hxsCOLLIDE} hxsCollideMode;
62 
63 // ---------- data structures ----------
64 
67 {
68  float x;
69  float y;
70  float z;
71 };
72 
76 typedef struct _hxsVector3 hxsVector3;
77 
79 struct _hxsColor
80 {
81  float r;
82  float g;
83  float b;
84  float alpha;
85 };
86 
92 typedef struct _hxsColor hxsColor;
93 
96 {
97  float w;
98  float x;
99  float y;
100  float z;
101 };
102 
105 typedef struct _hxsQuaternion hxsQuaternion;
106 
110 {
111  hxsVector3 pos;
112  hxsQuaternion orient;
113 };
114 
117 typedef struct _hxsTransform hxsTransform;
118 
122 {
124  hxsVector3 force;
125 
129  hxsVector3 torque;
130 };
131 
134 typedef struct _hxsWrench hxsWrench;
135 
137 struct _hxsJoint
138 {
141 
143  float pos;
144 
146  float vel;
147 
149  float acc;
150 
153 
155  hxsWrench wrench_reactive;
156 };
157 
160 typedef struct _hxsJoint hxsJoint;
161 
163 struct _hxsLink
164 {
167 
170  hxsTransform transform;
171 
173  hxsVector3 lin_vel;
174 
176  hxsVector3 ang_vel;
177 
179  hxsVector3 lin_acc;
180 
182  hxsVector3 ang_acc;
183 };
184 
187 typedef struct _hxsLink hxsLink;
188 
190 struct _hxsModel
191 {
194 
197  hxsTransform transform;
198 
202 
205  hxsLink links[hxsMAXLINKS];
206 
210 
213  hxsJoint joints[hxsMAXJOINTS];
214 
217 };
218 
221 typedef struct _hxsModel hxsModel;
222 
225 {
228 
231 
234  hxsVector3 point;
235 
238  hxsVector3 normal;
239 
241  float distance;
242 
244  hxsWrench wrench;
245 };
246 
249 typedef struct _hxsContactPoint hxsContactPoint;
250 
253 {
256 
258  hxsContactPoint contacts[hxsMAXCONTACT];
259 };
260 
263 typedef struct _hxsContactPoints hxsContactPoints;
264 
273 {
277 
280  hxsModel models[hxsMAXMODELS];
281 
284  hxsTransform camera_transform;
285 };
286 
295 typedef struct _hxsSimInfo hxsSimInfo;
296 
297 // ---------- API functions ----------
298 
303 hxResult hxs_sim_info(hxsSimInfo *_siminfo);
304 
308 hxResult hxs_camera_transform(hxsTransform *_transform);
309 
313 hxResult hxs_set_camera_transform(const hxsTransform *_transform);
314 
319 hxResult hxs_contacts(const char *_model, hxsContactPoints *_contact);
320 
326 hxResult hxs_model_joint_state(const char *_model, hxsModel *_state);
327 
337 hxResult hxs_set_model_joint_state(const char *_model, const char *_joint,
338  float _pos, float _vel);
339 
352 hxResult hxs_add_model(const char *_sdf, const char *_name,
353  float _x, float _y, float _z, float _roll, float _pitch, float _yaw,
354  int _gravity_mode, hxsModel *_model);
355 
359 hxResult hxs_remove_model(const char *_name);
360 
366 hxResult hxs_set_model_transform(const char *_name,
367  const hxsTransform *_transform);
368 
374 hxResult hxs_model_transform(const char *_name, hxsTransform *_transform);
375 
380 hxResult hxs_model_gravity_mode(const char *_name, int *_gravity_mode);
381 
386 hxResult hxs_set_model_gravity_mode(const char *_name, const int _gravity_mode);
387 
395 hxResult hxs_linear_velocity(const char *_name, hxsVector3 *_velocity);
396 
403 hxResult hxs_set_linear_velocity(const char *_name,
404  const hxsVector3 *_velocity);
405 
413 hxResult hxs_angular_velocity(const char *_name, hxsVector3 *_ang_vel);
414 
423 hxResult hxs_set_angular_velocity(const char *_name,
424  const hxsVector3 *_ang_vel);
425 
433 hxResult hxs_apply_force(const char *_modelName, const char *_linkName,
434  const hxsVector3 *_force, const float _duration);
435 
443 hxResult hxs_apply_torque(const char *_modelName, const char *_linkName,
444  const hxsVector3 *_torque, const float _duration);
445 
453 hxResult hxs_apply_wrench(const char *_modelName, const char *_linkName,
454  const hxsWrench *_wrench, const float _duration);
455 
459 hxResult hxs_reset(int _resetLimbPose);
460 
465 hxResult hxs_start_logging(const char *_dirname);
466 
470 hxResult hxs_is_logging(int *_result);
471 
475 
481 hxResult hxs_set_model_color(const char *_model, const hxsColor *_color);
482 
488 hxResult hxs_model_color(const char *_model, hxsColor *_color);
489 
495 hxResult hxs_set_model_collide_mode(const char *_model,
496  const hxsCollideMode *_collide_mode);
497 
503 hxResult hxs_model_collide_mode(const char *_model,
504  hxsCollideMode *_collide_mode);
505 
510 hxResult hxs_add_constraint(const char *_sdf, const char *_model);
511 
516 hxResult hxs_remove_constraint(const char *_name, const char *_model);
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 
522 #endif
hxResult hxs_set_angular_velocity(const char *_name, const hxsVector3 *_ang_vel)
Set the angular velocity of a model.
char name[100]
Model name.
Definition: haptix_sim.h:193
hxResult hxs_reset(int _resetLimbPose)
Send world reset command/Carry over limb pose between world reset.
hxResult hxs_set_model_joint_state(const char *_model, const char *_joint, float _pos, float _vel)
Set simulation state (position and velocity) of joint named "_joint" in model "_model" to the desired...
hxsTransform transform
The position and orientation of the model, relative to the global coordinate frame.
Definition: haptix_sim.h:197
hxResult hxs_sim_info(hxsSimInfo *_siminfo)
Get simulation information.
hxsContactPoint contacts[200]
Description of contacts.
Definition: haptix_sim.h:258
hxResult hxs_model_collide_mode(const char *_model, hxsCollideMode *_collide_mode)
Get the collide mode of the object.
hxResult hxs_set_model_transform(const char *_name, const hxsTransform *_transform)
Set model transform (position and orientation in the global coordinate frame).
float torque_motor
Torque due to actuation (N-m).
Definition: haptix_sim.h:152
char link2[100]
Name of the second contacting link.
Definition: haptix_sim.h:230
hxResult hxs_linear_velocity(const char *_name, hxsVector3 *_velocity)
Get the linear velocity of a model.
int contact_count
Number of currently active contacts.
Definition: haptix_sim.h:255
hxResult hxs_add_model(const char *_sdf, const char *_name, float _x, float _y, float _z, float _roll, float _pitch, float _yaw, int _gravity_mode, hxsModel *_model)
Add model during runtime.
hxResult hxs_model_gravity_mode(const char *_name, int *_gravity_mode)
Get whether or not this model is affected by gravity.
hxResult hxs_start_logging(const char *_dirname)
Start recording log file.
hxsTransform camera_transform
Information about the camera.
Definition: haptix_sim.h:284
char link1[100]
Name of the first contacting link.
Definition: haptix_sim.h:227
hxResult hxs_set_model_collide_mode(const char *_model, const hxsCollideMode *_collide_mode)
Set the collide mode of the object.
#define hxsMAXJOINTS
Maximum number of joints per model.
Definition: haptix_sim.h:40
hxResult hxs_set_model_gravity_mode(const char *_name, const int _gravity_mode)
Set whether or not this model is affected by gravity.
Information about a model.
Definition: haptix_sim.h:190
Information about a joint. A joint is a component of a model.
Definition: haptix_sim.h:137
hxResult hxs_apply_force(const char *_modelName, const char *_linkName, const hxsVector3 *_force, const float _duration)
Apply force to a link.
hxsLink links[100]
Array of links in the model.
Definition: haptix_sim.h:205
hxsJoint joints[50]
Array of joints in the model.
Definition: haptix_sim.h:213
int link_count
Number of links in the model.
Definition: haptix_sim.h:201
A translation and orientation constructed of a hxVector3 and hxQuaternion.
Definition: haptix_sim.h:109
#define hxsMAXNAMESIZE
Maximum number of characters allowed per name.
Definition: haptix_sim.h:46
int model_count
Number of models in simulation.
Definition: haptix_sim.h:276
hxResult hxs_set_model_color(const char *_model, const hxsColor *_color)
Set the color of the model.
hxResult hxs_camera_transform(hxsTransform *_transform)
Get information about the simulation camera.
int gravity_mode
1 if the model is affected by gravity, 0 otherwise.
Definition: haptix_sim.h:216
int joint_count
Number of joints in the model.
Definition: haptix_sim.h:209
hxsWrench wrench_reactive
Force/torque pair due to external disturbances.
Definition: haptix_sim.h:155
Definition: haptix_sim.h:121
A three-tuple vector.
Definition: haptix_sim.h:66
hxResult hxs_model_joint_state(const char *_model, hxsModel *_state)
Get simulation state (position and velocity) of joint named "_joint" in model "_model".
float acc
Acceleration (rad/s/s).
Definition: haptix_sim.h:149
hxResult hxs_is_logging(int *_result)
Determine if logging is running.
hxResult hxs_remove_model(const char *_name)
Remove model.
Information about a contact point.
Definition: haptix_sim.h:224
hxResult hxs_model_transform(const char *_name, hxsTransform *_transform)
Get model transform (position and orientation in the global coordinate frame).
hxResult hxs_stop_logging()
Stop recording log file.
hxResult hxs_contacts(const char *_model, hxsContactPoints *_contact)
Get information about active contacts for a model.
hxResult hxs_apply_wrench(const char *_modelName, const char *_linkName, const hxsWrench *_wrench, const float _duration)
Apply a wrench to a link.
float distance
Normal distance (penetration depth) in link 1 frame (m).
Definition: haptix_sim.h:241
hxsVector3 normal
Description of contact frame relative to link 1 frame: normal direction (unit vector) of contact forc...
Definition: haptix_sim.h:238
hxsVector3 point
Description of contact frame relative to link 1 frame: origin of contact on link 1.
Definition: haptix_sim.h:234
hxResult hxs_apply_torque(const char *_modelName, const char *_linkName, const hxsVector3 *_torque, const float _duration)
Apply torque to a link.
hxsVector3 force
3-dimensional force vector (Newtons).
Definition: haptix_sim.h:124
A quaternion.
Definition: haptix_sim.h:95
Simulation information.
Definition: haptix_sim.h:272
hxsVector3 torque
3-dimensional torque vector.
Definition: haptix_sim.h:129
hxResult hxs_set_camera_transform(const hxsTransform *_transform)
Set camera transform.
hxResult hxs_remove_constraint(const char *_name, const char *_model)
Remove constraint.
#define hxsMAXCONTACT
Maximum number of contacts.
Definition: haptix_sim.h:34
hxResult hxs_add_constraint(const char *_sdf, const char *_model)
Dynamically add constraint between two links during runtime.
#define hxsMAXLINKS
Maximum number of links per model.
Definition: haptix_sim.h:37
char name[100]
Joint name.
Definition: haptix_sim.h:140
hxResult
API return codes.
Definition: haptix.h:60
A 4-tuple representing a color in RGBA space.
Definition: haptix_sim.h:79
Information about contacts.
Definition: haptix_sim.h:252
hxResult hxs_set_linear_velocity(const char *_name, const hxsVector3 *_velocity)
Set the linear velocity of a model.
hxResult hxs_angular_velocity(const char *_name, hxsVector3 *_ang_vel)
Get the angular velocity of a model.
hxResult hxs_model_color(const char *_model, hxsColor *_color)
Get the color of the model.
float pos
Position (radians).
Definition: haptix_sim.h:143
hxsWrench wrench
Contact force/torque pair in link 1 frame at "point".
Definition: haptix_sim.h:244
Structures and functions for the primary HAPTIX API.
float vel
Velocity (rad/s).
Definition: haptix_sim.h:146
hxsModel models[50]
Array of models in simulation.
Definition: haptix_sim.h:280
#define hxsMAXMODELS
Maximum number of models per simulation.
Definition: haptix_sim.h:43