34 #include <sys/types.h> 39 #endif // HAVE_CONFIG_H 150 int force_send_control_mode = 0;
155 force_send_control_mode = 1;
328 torque[i] += spur->
torque[i];
360 if (v > fabs(spur->
v))
364 else if (v < -fabs(spur->
v))
377 else if (v < spur->vref_smooth - dv)
386 if (w > fabs(spur->
w))
390 else if (w < -fabs(spur->
w))
403 else if (w < spur->wref_smooth - dw)
444 tilt = atan(cos(odm->
theta - spur->
dir) * tan(spur->
tilt));
472 #if defined(HAVE_LIBRT) // clock_nanosleepが利用可能 473 struct timespec request;
475 if (clock_gettime(CLOCK_MONOTONIC, &request) == -1)
483 request.tv_sec += request.tv_nsec / 1000000000;
484 request.tv_nsec = request.tv_nsec % 1000000000;
486 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &request, 0);
491 pthread_testcancel();
504 pthread_testcancel();
506 #endif // defined(HAVE_LIBRT) 507 pthread_cleanup_pop(1);
513 static double before_time = 0;
523 before_time = now_time;
524 if (before_time == 0)
528 pthread_mutex_lock(&spur->
mutex);
543 spur_freeze.
vref = 0;
544 spur_freeze.
wref = 0;
619 spin(&odometry, spur);
650 pthread_mutex_unlock(&spur->
mutex);
656 if (pthread_create(thread, NULL, (
void *)
control_loop, NULL) != 0)
MotorControlMode wheel_mode_prev[YP_PARAM_MAX_MOTOR_NUM]
double gravity_compensation(OdometryPtr odm, SpurUserParamsPtr spur)
void apply_motor_speed(SpurUserParamsPtr spur)
double spin(OdometryPtr odm, SpurUserParamsPtr spur)
double wheel_vel_end[YP_PARAM_MAX_MOTOR_NUM]
void control_loop_cleanup(void *data)
double wvelref[YP_PARAM_MAX_MOTOR_NUM]
void odometry(OdometryPtr xp, short *cnt, short *pwm, double dt, double time)
double torque[YP_PARAM_MAX_MOTOR_NUM]
double wheel_accel[YP_PARAM_MAX_MOTOR_NUM]
double timeoptimal_servo(double err, double vel_max, double vel, double acc)
void wheel_torque(OdometryPtr odm, SpurUserParamsPtr spur, double *torque)
double p(YPSpur_param id, enum motor_id motor)
double wang[YP_PARAM_MAX_MOTOR_NUM]
void run_control(Odometry odometry, SpurUserParamsPtr spur)
MotorControlMode wheel_mode[YP_PARAM_MAX_MOTOR_NUM]
double wheel_angle[YP_PARAM_MAX_MOTOR_NUM]
int parameter_set(char param, char id, long long int value64)
void cstrans_odometry(YPSpur_cs cs, OdometryPtr dst_odm)
void wheel_vel(OdometryPtr odm, SpurUserParamsPtr spur)
double line_follow(OdometryPtr odm, SpurUserParamsPtr spur)
double wheel_vel[YP_PARAM_MAX_MOTOR_NUM]
double timeoptimal_servo2(double err, double vel_max, double vel, double acc, double vel_end)
SpurUserParamsPtr get_spur_user_param_ptr()
double orient(OdometryPtr odm, SpurUserParamsPtr spur)
double circle_follow(OdometryPtr odm, SpurUserParamsPtr spur)
#define YP_PARAM_MAX_MOTOR_NUM
double grav_torque[YP_PARAM_MAX_MOTOR_NUM]
int robot_speed_smooth(SpurUserParamsPtr spur)
double wvel[YP_PARAM_MAX_MOTOR_NUM]
void yprintf(ParamOutputLv level, const char *format,...)
int motor_enable[YP_PARAM_MAX_MOTOR_NUM]
void robot_speed(SpurUserParamsPtr spur)
void apply_motor_torque(SpurUserParamsPtr spur)
OdometryPtr get_odometry_ptr()
int state(YPSpur_state id)
int option(ParamOptions option)
int isset_p(YPSpur_param id, enum motor_id motor)
void init_control_thread(pthread_t *thread)
double torque_prev[YP_PARAM_MAX_MOTOR_NUM]
void update_ref_speed(SpurUserParamsPtr spur)
void wheel_angle(OdometryPtr odm, SpurUserParamsPtr spur)
ParametersPtr get_param_ptr()
int stop_line(OdometryPtr odm, SpurUserParamsPtr spur)
void coordinate_synchronize(Odometry *odm, SpurUserParamsPtr spur)
double wheel_vel_smooth[YP_PARAM_MAX_MOTOR_NUM]
int motor_control(SpurUserParamsPtr spur)