29class ObservationFormatter
32 explicit ObservationFormatter(
const std::vector<std::string> & joint_names);
37 std::vector<float> format(
38 const control_msgs::msg::Float64Values & interface_data,
39 const geometry_msgs::msg::Twist & velocity_cmd,
const std::vector<double> & previous_action);
40 size_t get_observation_dim()
const {
return observation_dim_; }
43 std::vector<double> extract_joint_positions(
44 const control_msgs::msg::Float64Values & interface_data);
45 void set_interface_names(
const std::vector<std::string> & interface_names);
46 void update_feet_contacts_from_interfaces(
47 const control_msgs::msg::Float64Values & msg,
const std::string & left_contact_full_name,
48 const std::string & right_contact_full_name);
51 void set_default_joint_positions(
const std::vector<double> & default_positions);
52 void set_motor_targets(
const std::vector<double> & motor_targets);
53 void set_velocity_commands(
const std::vector<double> & commands);
54 void update_action_history(
const std::vector<double> & action);
61 void set_imu_upside_down(
bool upside_down) { imu_upside_down_ = upside_down; }
62 void set_gyro_deadband(
double deadband) { gyro_deadband_ = deadband; }
63 void update_imitation_phase(
double phase_frequency_factor);
64 std::vector<double> get_imitation_phase()
const {
return imitation_phase_; }
67 void extract_interface_data(
68 const control_msgs::msg::Float64Values & msg, std::vector<double> & gyro,
69 std::vector<double> & accelero, std::vector<double> & joint_positions,
70 std::vector<double> & joint_velocities);
72 void format_joint_data(
73 const std::vector<double> & joint_positions,
const std::vector<double> & joint_velocities,
74 std::vector<float> & observation);
75 void append_doubles_as_floats(
const std::vector<double> & src, std::vector<float> & dst);
77 std::vector<std::string> joint_names_;
79 size_t observation_dim_;
80 std::vector<double> default_joint_positions_;
81 bool default_joint_positions_set_;
82 bool imu_upside_down_;
83 double gyro_deadband_;
84 std::vector<std::string> interface_names_;
85 std::vector<double> last_action_;
86 std::vector<double> last_last_action_;
87 std::vector<double> last_last_last_action_;
88 std::vector<double> motor_targets_;
90 double right_contact_;
92 double num_steps_in_gait_period_;
93 std::vector<double> imitation_phase_;
94 std::vector<double> velocity_commands_;