lebai-motion-control  3.1.6
lebai motion control C interface
lmc_tg.h
Go to the documentation of this file.
1 
7 #ifndef LMC_TG
8 #define LMC_TG
12 #include <stdbool.h>
13 
14 
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
33 typedef struct lmc_tg lmc_tg_t;
34 
39 typedef enum lmc_tg_update_state {
44 
45 
50 typedef enum lmc_tg_buffer_ret {
65 
77 
82 typedef struct lmc_tg_update_ret {
83  lmc_tg_update_state_t state;
86 
87 
92 typedef enum lmc_tg_group_type {
98 
103 typedef enum lmc_tg_space_type {
107 
112 typedef struct lmc_tg_runtime_data {
113  unsigned int id;
114  unsigned int is_stopped;
115  double time_cost;
116  lmc_tg_group_type_t group_type;
117  lmc_tg_space_type_t space_type;
118  unsigned int blending;
120 
125 typedef struct lmc_tg_move_param {
126  double v ;
127  double acc; ;
128  double time; ;
129  unsigned int smooth_move_to_next;
130  double blend_radius; ;
131  unsigned int interruptable; ;
133 
138 typedef struct lmc_tg_speed_param {
139  double acc;
140  double time;
141  unsigned int pos_constraints;
143 
148 typedef struct lmc_tg_toward_param {
149  double v ;
150  double acc;
152 
161 
167 void lmc_tg_delete(lmc_tg_t** tg_addr);
168 
177 int lmc_tg_init(lmc_tg_t * const tg, lmc_robot_model_t const* const robot_model,
178 lmc_tg_config_t const* const config);
179 
185 void lmc_tg_cleanup(lmc_tg_t * const tg);
186 
187 
188 
196 int lmc_tg_set_limit(lmc_tg_t * const tg, lmc_tg_limit_t const* const limit);
197 
198 
207 void lmc_tg_set_joint_pos(lmc_tg_t * const tg, lmc_joint_state_t const * const joint_state);
208 
209 
220 int lmc_tg_set_group(lmc_tg_t * const tg, lmc_tg_group_type_t group);
221 
222 
229 lmc_tg_group_type_t lmc_tg_get_group(lmc_tg_t * const tg);
230 
231 
237 void lmc_tg_recovery(lmc_tg_t * const tg);
238 
239 
247 
248 
257 int lmc_tg_get_updated_date(lmc_tg_t const * const tg, lmc_joint_cmd_t * const joint_cmd, lmc_tg_runtime_data_t * const tg_runtime_data);
258 
265 lmc_tg_update_state_t lmc_tg_get_update_state(lmc_tg_t const * const tg);
266 
267 
268 
278 lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint(lmc_tg_t * const tg, int id, double const * const target, lmc_tg_move_param_t const * const param);
279 
280 
281 
291 lmc_tg_buffer_ret_t lmc_tg_buffer_move_line(lmc_tg_t * const tg, int id, lmc_transform_t const * const target, lmc_tg_move_param_t const * const param);
292 
303 lmc_tg_buffer_ret_t lmc_tg_buffer_move_circle(lmc_tg_t * const tg, int id, lmc_translation_t const* const way_point, lmc_transform_t const * const target, lmc_tg_move_param_t const * const param);
304 
317 lmc_tg_buffer_ret_t lmc_tg_buffer_move_circle_by_angle(lmc_tg_t * const tg, int id, lmc_translation_t const* const way_point1, lmc_translation_t const* const way_point2, double angle, lmc_euler_zyx_t const* const target_rot, lmc_tg_move_param_t const * const param);
318 
343 lmc_tg_buffer_ret_t lmc_tg_buffer_speed_joint(lmc_tg_t * const tg, int id, double const * const vel, lmc_tg_speed_param_t const * const param);
344 
345 
376 lmc_tg_buffer_ret_t lmc_tg_buffer_speed_line(lmc_tg_t * const tg, int id, lmc_twist_t const * const t, lmc_tg_speed_param_t const * const param);
377 
378 
388 lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pt(lmc_tg_t * const tg, int id, double duration, lmc_joint_cmd_t const* const joint_data);
389 
399 lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pvt(lmc_tg_t * const tg, int id, double duration, lmc_joint_cmd_t const* const joint_data);
400 
410 lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pvat(lmc_tg_t * const tg, int id, double duration, lmc_joint_cmd_t const* const joint_data);
411 
421 lmc_tg_buffer_ret_t lmc_tg_set_toward_joint(lmc_tg_t * const tg, int id, double const * const target, lmc_tg_toward_param_t const* const param);
422 
423 
424 
435 lmc_tg_buffer_ret_t lmc_tg_buffer_singularity_robust_move_line(lmc_tg_t * const tg, int id, lmc_transform_t const * const target, lmc_tg_move_param_t const * const param);
436 
437 
443 void lmc_tg_stop_trajectory(lmc_tg_t * const tg);
444 
445 
446 
453 void lmc_tg_interrupt_trajectory(lmc_tg_t * const tg);
454 
461 void lmc_tg_set_vel_scale(lmc_tg_t * const tg, double scale);
462 
470 void lmc_tg_release_control(lmc_tg_t * const tg, double t);
471 
479 void lmc_tg_sieze_control(lmc_tg_t * const tg, double vel_scale);
480 
481 
488 size_t lmc_tg_get_buffer_size(lmc_tg_t const* const tg);
489 
496 int lmc_tg_get_buffer_empty(lmc_tg_t const* const tg);
497 
498 
505 int lmc_tg_get_buffer_full(lmc_tg_t const* const tg);
506 
513 double lmc_tg_get_remain_move_time(lmc_tg_t const* const tg);
514 
523 int lmc_tg_update_joint_state(lmc_tg_t * const tg, lmc_joint_state_t const * const joint_state);
524 
527 #ifdef __cplusplus
528 }
529 #endif /* __cplusplus */
530 
531 #endif /* LMC_TG */
Cartesian translation coordinate.
Definition: lmc_math.h:29
lmc_tg_update_state_t lmc_tg_get_update_state(lmc_tg_t const *const tg)
Get trajectory generator update state.
void lmc_tg_recovery(lmc_tg_t *const tg)
This function recover the error, only call this function when the trajectory update in error state...
lmc_tg_group_type_t group_type
Definition: lmc_tg.h:116
Limitation data structure for trajectory generator.
Definition: lmc_tg_config.h:27
Trjecotry generator update ret value.
Definition: lmc_tg.h:82
lmc_tg_buffer_ret_t lmc_tg_set_toward_joint(lmc_tg_t *const tg, int id, double const *const target, lmc_tg_toward_param_t const *const param)
Try to set new toward joint target.
size_t lmc_tg_get_buffer_size(lmc_tg_t const *const tg)
Get number of buffered trajectory .
struct lmc_tg_update_ret lmc_tg_update_ret_t
Trjecotry generator update ret value.
double time_cost
Definition: lmc_tg.h:115
Trjecotry generator toward parameter.
Definition: lmc_tg.h:148
struct lmc_tg_move_param lmc_tg_move_param_t
Trjecotry generator move parameter.
lmc_tg_update_error_code
Trjecotry generator update error code, when error happens, check the type for error.
Definition: lmc_tg.h:70
Trjecotry generator runtime data.
Definition: lmc_tg.h:112
unsigned int interruptable
Definition: lmc_tg.h:130
lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pt(lmc_tg_t *const tg, int id, double duration, lmc_joint_cmd_t const *const joint_data)
Try to add a joint move pt trajectory.
lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pvt(lmc_tg_t *const tg, int id, double duration, lmc_joint_cmd_t const *const joint_data)
Try to add a joint move pvt trajectory.
struct lmc_tg_speed_param lmc_tg_speed_param_t
Trjecotry generator speed parameter.
lmc_tg_buffer_ret_t lmc_tg_buffer_move_circle(lmc_tg_t *const tg, int id, lmc_translation_t const *const way_point, lmc_transform_t const *const target, lmc_tg_move_param_t const *const param)
Try to add a move circle trajectory to buffer using way point and end pose.
int lmc_tg_set_limit(lmc_tg_t *const tg, lmc_tg_limit_t const *const limit)
Set trajectory generator limit parameters.
lmc_tg_buffer_ret_t lmc_tg_buffer_move_line(lmc_tg_t *const tg, int id, lmc_transform_t const *const target, lmc_tg_move_param_t const *const param)
Try to add a move line trajectory to buffer.
Transform velocity representation.
Definition: lmc_math.h:96
lmc_tg_update_error_code_t error_code
Definition: lmc_tg.h:84
void lmc_tg_set_vel_scale(lmc_tg_t *const tg, double scale)
Set the velocity scale of trajectory data range from 0.0 to 1.0.
joint command data
Definition: lmc_joint.h:35
Trajectory generator configuration data structure.
unsigned int id
Definition: lmc_tg.h:113
void lmc_tg_sieze_control(lmc_tg_t *const tg, double vel_scale)
Sieze the control after release it. it will move from current position to the position when release...
Configuration data structure for trajectory generator.
Definition: lmc_tg_config.h:45
int lmc_tg_get_buffer_full(lmc_tg_t const *const tg)
Get if buffer is full.
lmc_tg_buffer_ret_t lmc_tg_buffer_singularity_robust_move_line(lmc_tg_t *const tg, int id, lmc_transform_t const *const target, lmc_tg_move_param_t const *const param)
Try to add a singlarirty robust move line trajectory to buffer. This trajectory will try to avoid sin...
unsigned int smooth_move_to_next
Definition: lmc_tg.h:128
lmc_tg_update_state
Trajectory generator update state.
Definition: lmc_tg.h:39
lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint(lmc_tg_t *const tg, int id, double const *const target, lmc_tg_move_param_t const *const param)
Try to add a move joint trajectory to buffer.
unsigned int is_stopped
Definition: lmc_tg.h:114
lmc_tg_space_type
Trajectory generator space type.
Definition: lmc_tg.h:103
int lmc_tg_get_updated_date(lmc_tg_t const *const tg, lmc_joint_cmd_t *const joint_cmd, lmc_tg_runtime_data_t *const tg_runtime_data)
Get usefull trajectory generator update data.
struct lmc_tg_toward_param lmc_tg_toward_param_t
Trjecotry generator toward parameter.
Joint related data structure.
struct lmc_tg_runtime_data lmc_tg_runtime_data_t
Trjecotry generator runtime data.
int lmc_tg_set_group(lmc_tg_t *const tg, lmc_tg_group_type_t group)
This function set group, group change must be done by manual. The trajectory type under current group...
enum lmc_tg_space_type lmc_tg_space_type_t
Trajectory generator space type.
unsigned int pos_constraints
Definition: lmc_tg.h:141
void lmc_tg_stop_trajectory(lmc_tg_t *const tg)
This function stop the trajecotry with an deceleration.
lmc_tg_buffer_ret_t lmc_tg_buffer_move_joint_pvat(lmc_tg_t *const tg, int id, double duration, lmc_joint_cmd_t const *const joint_data)
Try to add a joint move pvat trajectory.
Euler zyx representation of rotation.
Definition: lmc_math.h:51
Definition: lmc_tg.h:104
enum lmc_tg_update_error_code lmc_tg_update_error_code_t
Trjecotry generator update error code, when error happens, check the type for error.
lmc_tg_buffer_ret_t lmc_tg_buffer_speed_line(lmc_tg_t *const tg, int id, lmc_twist_t const *const t, lmc_tg_speed_param_t const *const param)
Try to add a speed linear trajectory to buffer.
lmc_tg_group_type_t lmc_tg_get_group(lmc_tg_t *const tg)
This function get current group.
Definition: lmc_tg.h:95
struct lmc_robot_model lmc_robot_model_t
Robot model data structure.
enum lmc_tg_buffer_ret lmc_tg_buffer_ret_t
trjecotry generator buffer xxx function ret
int lmc_tg_get_buffer_empty(lmc_tg_t const *const tg)
Get if buffer is empty.
lmc_tg_update_state_t state
Definition: lmc_tg.h:83
void lmc_tg_set_joint_pos(lmc_tg_t *const tg, lmc_joint_state_t const *const joint_state)
This function set current joint anchor point of trajectory generator caculation. It must be called wh...
joint state data
Definition: lmc_joint.h:21
lmc_tg_buffer_ret
trjecotry generator buffer xxx function ret
Definition: lmc_tg.h:50
lmc_tg_update_ret_t lmc_tg_update(lmc_tg_t *const tg)
Core calculation function of trajectory generator, always call it in realtime loop,.
void lmc_tg_cleanup(lmc_tg_t *const tg)
Cleanup all runtime data of trajectory generator.
lmc_tg_buffer_ret_t lmc_tg_buffer_speed_joint(lmc_tg_t *const tg, int id, double const *const vel, lmc_tg_speed_param_t const *const param)
Try to add a speed joint trajectory to buffer.
int lmc_tg_update_joint_state(lmc_tg_t *const tg, lmc_joint_state_t const *const joint_state)
Update trajectory generator joint state, should be called in realtime loop, update every cycle...
void lmc_tg_delete(lmc_tg_t **tg_addr)
Delete a trajectory generator instance.
unsigned int blending
Definition: lmc_tg.h:118
struct lmc_tg lmc_tg_t
Trajectory generator data structure.
Definition: lmc_tg.h:33
Transform representation.
Definition: lmc_math.h:86
enum lmc_tg_group_type lmc_tg_group_type_t
Trjecotry generator group type.
lmc_tg_space_type_t space_type
Definition: lmc_tg.h:117
Trjecotry generator move parameter.
Definition: lmc_tg.h:125
lmc_tg_group_type
Trjecotry generator group type.
Definition: lmc_tg.h:92
lmc_tg_t * lmc_tg_new()
Create a trajectory generator instance.
void lmc_tg_interrupt_trajectory(lmc_tg_t *const tg)
This function interrupt current running the trajecotry if it&#39;s interruptable. After current trajector...
Definition: lmc_tg.h:93
Robot model related data structures and functions.
int lmc_tg_init(lmc_tg_t *const tg, lmc_robot_model_t const *const robot_model, lmc_tg_config_t const *const config)
Init a trajectory generator.
double lmc_tg_get_remain_move_time(lmc_tg_t const *const tg)
Get total time to move remain trajectoies in buffer.
void lmc_tg_release_control(lmc_tg_t *const tg, double t)
Give up the control of trajectory generator, the trajectory generator will output as lmc_tg_update_jo...
lmc_tg_buffer_ret_t lmc_tg_buffer_move_circle_by_angle(lmc_tg_t *const tg, int id, lmc_translation_t const *const way_point1, lmc_translation_t const *const way_point2, double angle, lmc_euler_zyx_t const *const target_rot, lmc_tg_move_param_t const *const param)
Try to add a move circle trajectory to buffer using two way point and angle.
Trjecotry generator speed parameter.
Definition: lmc_tg.h:138
enum lmc_tg_update_state lmc_tg_update_state_t
Trajectory generator update state.