#!/usr/bin/env python
PACKAGE = "ema_controllers"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

# enables
gen.add("enable_control", bool_t, 0, "Enable control", False)

controller = gen.enum([gen.const("BB", int_t, 0, "Bang_bang"),
                       gen.const("PID", int_t, 1, "PID "),
                       gen.const("PID_ILC", int_t, 2, "PID_ILC "),
                       gen.const("PID_ES", int_t, 3, "PID_ES ")],
                      "Set controller")

enable_config = gen.add_group("Enable_config", type="hide")
enable_config.add("control_sel", int_t, 0, "Controller selection", 1, 0, 3, edit_method=controller)

enable_config.add("enable_quad", bool_t, 0, "Enable quad muscle-ch1", True)
enable_config.add("enable_hams", bool_t, 0, "Enable hams muscle-ch2", True)

channels = gen.enum([gen.const("ch12Left", int_t, 0, "ch12_left"),
                     gen.const("ch34Right", int_t, 1, "ch34_right ")],
                    "Set leg")
enable_config.add("channels_sel", int_t, 0, "Channel selection", 1, 0, 3, edit_method=channels)

enable_config.add("co_activation", bool_t, 0, "Enable co-activation", False)
enable_config.add("min_pw_q", int_t, 0, "Min PW to apply in control (QUAD)", 0, 0, 500)
enable_config.add("min_pw_h", int_t, 0, "Min PW to apply in control (HAMS)", 0, 0, 500)

# ref
gen.add("step_time", double_t, 0, "Indicate the period time of the step [s]", 3, 0, 8)

ref_config = gen.add_group("Ref_param", type="hide")
ref_config.add("ref_path", str_t, 0, "Indicate the reference path", "")
ref_config.add("save_path", str_t, 0, "Indicate where to save the file", "")

# currents
stim_config = gen.add_group("Stim_param", type="hide")
stim_config.add("current_quad", int_t, 0, "Current applied to quad muscle [mA]", 0, 0, 80)
stim_config.add("current_hams", int_t, 0, "Current applied to hams muscle [mA]", 0, 0, 80)

# PID param
pid_config = gen.add_group("PID_param", type="hide")
pid_config.add("Kp", double_t, 0, "Kp parameter", 0.02, 0, 3)
pid_config.add("Ki", double_t, 0, "Ki parameter", 0.001, 0, 3)
pid_config.add("Kd", double_t, 0, "Kd parameter", 0.0005, 0, 3)

# ES param
esc_config = gen.add_group("ESC_param", type="hide")
esc_config.add("ES_A", double_t, 0, "Divider A", 0, 2, 1000)
esc_config.add("ES_omega", double_t, 0, "Frequency of ES", 10, 0, 50)
esc_config.add("ES_phase", double_t, 0, "Phase of ES", 0, 0, 6.28)

# ILC param
ilc_config = gen.add_group("ILC_param", type="hide")
ilc_config.add("ILC_alpha", double_t, 0, "% for memory", 0.2, 0, 1)
ilc_config.add("ILC_beta", double_t, 0, "% for PID", 0.8, 0, 1)
ilc_config.add("ILC_gama", double_t, 0, "proportional gain", 0.02, 0, 1)

exit(gen.generate(PACKAGE, "dynamic_tutorials", "Tutorials"))
