diff --git a/evogym/simulator/SimulatorCPP/Environment.cpp b/evogym/simulator/SimulatorCPP/Environment.cpp index 5dee864e..42e77e0b 100644 --- a/evogym/simulator/SimulatorCPP/Environment.cpp +++ b/evogym/simulator/SimulatorCPP/Environment.cpp @@ -262,7 +262,7 @@ bool Environment::revert_to_snapshot(long int sim_time) { return true; } -Ref Environment::get_pos_at_time(long int sim_time) { +RefMatrixXd Environment::get_pos_at_time(long int sim_time) { if (history.count(sim_time) <= 0) { Matrix empty; @@ -273,7 +273,7 @@ Ref Environment::get_pos_at_time(long int sim_time) { return history[sim_time].points_pos; } -Ref Environment::get_vel_at_time(long int sim_time) { +RefMatrixXd Environment::get_vel_at_time(long int sim_time) { if (history.count(sim_time) <= 0) { Matrix empty; @@ -285,7 +285,7 @@ Ref Environment::get_vel_at_time(long int sim_time) { return history[sim_time].points_vel; } -Ref Environment::object_pos_at_time(long int sim_time, string object_name) { +RefMatrixXd Environment::object_pos_at_time(long int sim_time, string object_name) { if (history.count(sim_time) <= 0 || object_name_to_index.count(object_name) <= 0) { Matrix empty; @@ -300,7 +300,7 @@ Ref Environment::object_pos_at_time(long int sim_time, string object_ return history[sim_time].points_pos(Eigen::all, Eigen::seq(min_index, max_index)); } -Ref Environment::object_vel_at_time(long int sim_time, string object_name) { +RefMatrixXd Environment::object_vel_at_time(long int sim_time, string object_name) { if (history.count(sim_time) <= 0 || object_name_to_index.count(object_name) <= 0) { Matrix empty; diff --git a/evogym/simulator/SimulatorCPP/Environment.h b/evogym/simulator/SimulatorCPP/Environment.h index def4313f..b1b6302d 100644 --- a/evogym/simulator/SimulatorCPP/Environment.h +++ b/evogym/simulator/SimulatorCPP/Environment.h @@ -17,6 +17,12 @@ using namespace std; using namespace Eigen; +#ifdef __APPLE__ +using RefMatrixXd = Matrix ; +#else +using RefMatrixXd = Ref ; +#endif + class Environment { private: @@ -92,11 +98,11 @@ class Environment vector* get_objects(); Robot* get_robot(string robot_name); - Ref get_pos_at_time(long int sim_time); - Ref get_vel_at_time(long int sim_time); + RefMatrixXd get_pos_at_time(long int sim_time); + RefMatrixXd get_vel_at_time(long int sim_time); - Ref object_pos_at_time(long int sim_time, string object_name); - Ref object_vel_at_time(long int sim_time, string object_name); + RefMatrixXd object_pos_at_time(long int sim_time, string object_name); + RefMatrixXd object_vel_at_time(long int sim_time, string object_name); double object_orientation_at_time(long int sim_time, string object_name); void translate_object(double x, double y, string object_name); diff --git a/evogym/simulator/SimulatorCPP/Sim.cpp b/evogym/simulator/SimulatorCPP/Sim.cpp index 935b7b7e..c00cd421 100644 --- a/evogym/simulator/SimulatorCPP/Sim.cpp +++ b/evogym/simulator/SimulatorCPP/Sim.cpp @@ -136,10 +136,10 @@ int Sim::get_time() { return sim_time; } -Ref Sim::pos_at_time(long int sim_time) { +RefMatrixXd Sim::pos_at_time(long int sim_time) { return environment.get_pos_at_time(sim_time); } -Ref Sim::vel_at_time(long int sim_time) { +RefMatrixXd Sim::vel_at_time(long int sim_time) { return environment.get_vel_at_time(sim_time); } double Sim::object_orientation_at_time(long int sim_time, string object_name) { @@ -151,10 +151,10 @@ void Sim::translate_object(double x, double y, string object_name) { } -Ref Sim::object_pos_at_time(long int sim_time, string object_name) { +RefMatrixXd Sim::object_pos_at_time(long int sim_time, string object_name) { return environment.object_pos_at_time(sim_time, object_name); } -Ref Sim::object_vel_at_time(long int sim_time, string object_name) { +RefMatrixXd Sim::object_vel_at_time(long int sim_time, string object_name) { return environment.object_vel_at_time(sim_time, object_name); } diff --git a/evogym/simulator/SimulatorCPP/Sim.h b/evogym/simulator/SimulatorCPP/Sim.h index 9d3eea8b..4b51406b 100644 --- a/evogym/simulator/SimulatorCPP/Sim.h +++ b/evogym/simulator/SimulatorCPP/Sim.h @@ -42,10 +42,10 @@ class Sim void force_save(); void revert(long int sim_time); int get_time(); - Ref pos_at_time(long int sim_time); - Ref vel_at_time(long int sim_time); - Ref object_pos_at_time(long int sim_time, string object_name); - Ref object_vel_at_time(long int sim_time, string object_name); + RefMatrixXd pos_at_time(long int sim_time); + RefMatrixXd vel_at_time(long int sim_time); + RefMatrixXd object_pos_at_time(long int sim_time, string object_name); + RefMatrixXd object_vel_at_time(long int sim_time, string object_name); double object_orientation_at_time(long int sim_time, string object_name); void translate_object(double x, double y, string object_name); Ref get_actuator_indices(string robot_name);