81 lines
2.4 KiB
C
81 lines
2.4 KiB
C
#ifndef LINUXCNC_WEB_WASM_SIM_MOTION_QUEUE_H
|
|
#define LINUXCNC_WEB_WASM_SIM_MOTION_QUEUE_H
|
|
|
|
#include "sim_posemath.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum sim_motion_result {
|
|
SIM_MOTION_OK = 0,
|
|
SIM_MOTION_ERR_ARGUMENT = -600,
|
|
SIM_MOTION_ERR_NONFINITE = -601,
|
|
SIM_MOTION_ERR_RANGE = -602,
|
|
SIM_MOTION_ERR_GEOMETRY = -603,
|
|
SIM_MOTION_ERR_MOTION_TYPE = -604,
|
|
SIM_MOTION_ERR_STATE = -605,
|
|
SIM_MOTION_ERR_CAPACITY = -606,
|
|
SIM_MOTION_ERR_BUFFER = -607,
|
|
};
|
|
|
|
enum sim_motion_profile {
|
|
SIM_MOTION_PROFILE_BLEND = 0,
|
|
SIM_MOTION_PROFILE_EXACT_STOP = 1,
|
|
};
|
|
|
|
#define SIM_MOTION_QUEUE_CAPACITY 64u
|
|
|
|
typedef struct sim_motion_command {
|
|
sim_posemath_segment segment;
|
|
uint32_t id;
|
|
uint32_t tag;
|
|
} sim_motion_command;
|
|
|
|
typedef struct sim_motion_state {
|
|
sim_posemath_pose position;
|
|
double velocity;
|
|
double progress;
|
|
uint32_t tick;
|
|
uint32_t queue_depth;
|
|
uint32_t active_id;
|
|
uint32_t active_tag;
|
|
int motion_type;
|
|
int status;
|
|
} sim_motion_state;
|
|
|
|
typedef struct sim_motion_queue {
|
|
sim_motion_command commands[SIM_MOTION_QUEUE_CAPACITY];
|
|
uint32_t head;
|
|
uint32_t count;
|
|
uint32_t next_id;
|
|
uint32_t tick;
|
|
double cycle_time;
|
|
double velocity_limit;
|
|
sim_motion_state state;
|
|
} sim_motion_queue;
|
|
|
|
int sim_motion_init(sim_motion_queue *queue, double cycle_time, double velocity_limit);
|
|
uint32_t sim_motion_size(void);
|
|
uint32_t sim_motion_command_size(void);
|
|
uint32_t sim_motion_state_size(void);
|
|
int sim_motion_reset(sim_motion_queue *queue);
|
|
int sim_motion_enqueue(sim_motion_queue *queue, const sim_motion_command *command, uint32_t *id_out);
|
|
int sim_motion_step(sim_motion_queue *queue);
|
|
int sim_motion_set_profile(sim_motion_queue *queue, int profile);
|
|
int sim_motion_set_lookahead(sim_motion_queue *queue, uint32_t depth);
|
|
int sim_motion_set_dynamics(sim_motion_queue *queue, double acceleration_limit, double jerk_limit);
|
|
int sim_motion_set_paused(sim_motion_queue *queue, uint32_t paused);
|
|
int sim_motion_peek(const sim_motion_queue *queue, uint32_t offset, sim_motion_command *command);
|
|
int sim_motion_read_state(const sim_motion_queue *queue, sim_motion_state *state);
|
|
uint32_t sim_motion_queue_depth(const sim_motion_queue *queue);
|
|
uint64_t sim_motion_state_hash(const sim_motion_queue *queue);
|
|
uint64_t sim_motion_plan_hash(const sim_motion_queue *queue);
|
|
uint32_t sim_motion_canonical(const sim_motion_queue *queue, char *output, uint32_t capacity);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|