Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for viscousPos/Neg and coulombPos/Neg friction parameters #254

Merged
merged 6 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ extern "C" {
#define EOMTHEEMSAPPLCFG_VERSION_MAJOR (VERSION_MAJOR_OFFSET+3)
// <o> minor <0-255>
// <o> minor <0-255>
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 49
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 50

// </h>version

// <h> build date
// <o> year <2010-2030>
#define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2022
// <o> month <1-12>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 3
// <o> day <1-31>
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 28
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 2
// <o> hour <0-23>
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 16
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 21
// <o> minute <0-59>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 50
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 13
// </h>build date
// </h>Info

Expand Down Expand Up @@ -495,7 +495,7 @@ extern "C" {

// <o> max size of output datagrams <64-1500>
// <i> default: 1024
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1408
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1416
pattacini marked this conversation as resolved.
Show resolved Hide resolved

// </h>datagrams in socket

Expand Down Expand Up @@ -554,7 +554,7 @@ extern "C" {

// <o> capacity of the ropframe of reply rops <16-1440:8>
// <i> default: 128
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 256
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 264



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ extern "C" {
#define EOMTHEEMSAPPLCFG_VERSION_MAJOR 3
// <o> minor <0-255>
// <o> minor <0-255>
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 33
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 34
// </h>version

// <h> build date
// <o> year <2010-2030>
#define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2022
// <o> month <1-12>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 3
// <o> day <1-31>
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 28
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 2
// <o> hour <0-23>
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 16
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 21
// <o> minute <0-59>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 50
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 00
// </h>build date

// </h>Info
Expand Down Expand Up @@ -489,7 +489,7 @@ extern "C" {

// <o> max size of output datagrams <64-1500>
// <i> default: 1024
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1408
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1416

// </h>datagrams in socket

Expand Down Expand Up @@ -548,7 +548,7 @@ extern "C" {

// <o> capacity of the ropframe of reply rops <16-1440:8>
// <i> default: 128
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 256
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 264



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extern "C" {
// <o> minor <0-255>


#define EOMTHEEMSAPPLCFG_VERSION_MINOR 47
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 48


// </h>version
Expand All @@ -96,13 +96,13 @@ extern "C" {
// <o> year <2010-2030>
#define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2022
// <o> month <1-12>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1
#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 3
// <o> day <1-31>
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 28
#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 2
// <o> hour <0-23>
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 16
#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 21
// <o> minute <0-59>
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 50
#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 11

// </h>build date

Expand Down Expand Up @@ -504,7 +504,7 @@ extern "C" {

// <o> max size of output datagrams <64-1500>
// <i> default: 1024
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1408
#define EOMTHEEMSAPPLCFG_SOCKET_OUTDGRAMSIZEOF 1416

// </h>datagrams in socket

Expand Down Expand Up @@ -555,15 +555,15 @@ extern "C" {

// <o> capacity of the ropframe of regular rops <16-1440:8>
// <i> default: 768
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREGULARSCAPACITY 1024
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREGULARSCAPACITY 1024

// <o> capacity of the ropframe of occasional rops <16-1440:8>
// <i> default: 128
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEOCCASIONALSCAPACITY 128
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEOCCASIONALSCAPACITY 128

// <o> capacity of the ropframe of reply rops <16-1440:8>
// <i> default: 128
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 256
#define EOMTHEEMSAPPLCFG_TRANSCEIVER_ROPFRAMEREPLIESCAPACITY 264



Expand Down
6 changes: 3 additions & 3 deletions emBODY/eBcode/arch-arm/embobj/plus/mc/Controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ void MController_config_joint(int j, eOmc_joint_config_t* config) //
MController_motor_config_torque_PID(j, &(config->pidtorque));

Motor_config_filter(o->motor+j, config->tcfiltertype);
Motor_config_friction(o->motor+j, config->motor_params.bemf_value, config->motor_params.ktau_value);
Motor_config_friction(o->motor+j, config->motor_params.bemf_value, config->motor_params.ktau_value, config->motor_params.friction);

Joint_config(o->joint+j, j, config);

Expand All @@ -1517,9 +1517,9 @@ void MController_config_motor(int m, eOmc_motor_config_t* config) //
Motor_config(smc->motor+m, m, config);
}

void MController_config_motor_friction(int m, eOmc_motor_params_t* friction) //
void MController_config_motor_friction(int m, eOmc_motor_params_t* params) //
{
Motor_config_friction(smc->motor+m, friction->bemf_value, friction->ktau_value);
Motor_config_friction(smc->motor+m, params->bemf_value, params->ktau_value, params->friction);
}

void MController_config_joint_impedance(int j, eOmc_impedance_t* impedance) //
Expand Down
2 changes: 1 addition & 1 deletion emBODY/eBcode/arch-arm/embobj/plus/mc/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extern void MController_get_motor_state(int m, eOmc_motor_status_t* motor_status
extern void MController_update_joint_targets(int j);
extern void MController_update_motor_pos_fbk(int m, int32_t position_raw);
extern void MController_update_motor_current_fbk(int m, int16_t current);
extern void MController_config_motor_friction(int m, eOmc_motor_params_t* friction); //
extern void MController_config_motor_friction(int m, eOmc_motor_params_t* params); //
extern void MController_config_joint_impedance(int j, eOmc_impedance_t* impedance); //

extern void MController_config_minjerk_pid(int j, eOmc_PID_t *pid_conf); //
Expand Down
4 changes: 2 additions & 2 deletions emBODY/eBcode/arch-arm/embobj/plus/mc/Motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ void Motor_config_filter(Motor* o, uint8_t filter) //
PID_config_filter(&o->trqPID, filter);
}

void Motor_config_friction(Motor* o, float Bemf, float Ktau) //
void Motor_config_friction(Motor* o, float Bemf, float Ktau, eOmc_FrictionParams_t friction) //
{
PID_config_friction(&o->trqPID, Bemf, Ktau);
PID_config_friction(&o->trqPID, Bemf, Ktau, friction);
}

void Motor_calibrate_withOffset(Motor* o, int32_t offset) //
Expand Down
2 changes: 1 addition & 1 deletion emBODY/eBcode/arch-arm/embobj/plus/mc/Motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ extern void Motor_config_torque_PID(Motor* o, eOmc_PID_t* pid);
extern void Motor_config_speed_PID(Motor* o, eOmc_PID_t* pid);

extern void Motor_config_filter(Motor* o, uint8_t filter); //
extern void Motor_config_friction(Motor* o, float Bemf, float Ktau); //
extern void Motor_config_friction(Motor* o, float Bemf, float Ktau, eOmc_FrictionParams_t friction); //
extern void Motor_calibrate_withOffset(Motor* o, int32_t offset); //
extern BOOL Motor_calibrate_moving2Hardstop(Motor* o, int32_t pwm, int32_t zero); //
extern void Motor_uncalibrate(Motor* o);
Expand Down
13 changes: 12 additions & 1 deletion emBODY/eBcode/arch-arm/embobj/plus/mc/Pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ void PID_config(PID* o, eOmc_PID_t* config)

}

void PID_config_friction(PID *o, float Kbemf, float Ktau)
void PID_config_friction(PID *o, float Kbemf, float Ktau, eOmc_FrictionParams_t friction)
{
o->Kbemf = Kbemf;
o->Ktau = Ktau;
o->viscous_pos_val = friction.viscous_pos_val;
o->viscous_neg_val = friction.viscous_neg_val;
o->coulomb_pos_val = friction.coulomb_pos_val;
o->coulomb_neg_val = friction.coulomb_neg_val;
}

void PID_config_filter(PID *o, uint8_t filter)
Expand Down Expand Up @@ -175,7 +179,14 @@ float PID_do_out(PID* o, float En)
return o->out_lpf;
}

#include "EOtheErrorManager.h"

float PID_do_friction_comp(PID *o, float vel_fbk, float trq_ref)
{
#ifdef USE_VISCOUS_COULOMB
//return o->Ktau*(o->coulomb_pos_val + o->viscous_pos_val*vel_fbk + o->Kff*trq_ref);
return o->Ktau*(o->Kbemf*vel_fbk+o->Kff*trq_ref);
#else
return o->Ktau*(o->Kbemf*vel_fbk+o->Kff*trq_ref);
#endif // USE_VISCOUS_COULOMB
}
9 changes: 7 additions & 2 deletions emBODY/eBcode/arch-arm/embobj/plus/mc/Pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ typedef struct //PID

float stiction_up;
float stiction_down;


float viscous_pos_val;
float viscous_neg_val;
float coulomb_pos_val;
float coulomb_neg_val;

#ifdef FINGER_MK3
float out_max_open;
float out_max_close;
Expand All @@ -65,7 +70,7 @@ typedef struct //PID
PID* PID_new(uint8_t n);
extern void PID_init(PID* o);
extern void PID_config(PID* o, eOmc_PID_t* config);
extern void PID_config_friction(PID *o, float Kbemf, float Ktau);
extern void PID_config_friction(PID *o, float Kbemf, float Ktau, eOmc_FrictionParams_t friction);
extern void PID_config_filter(PID *o, uint8_t filter);

extern void PID_reset(PID* o);
Expand Down