Skip to content

Commit

Permalink
Merge pull request #32 from TakesxiSximada/sximada-patch-13
Browse files Browse the repository at this point in the history
fix simulator type error on macOS
  • Loading branch information
TakesxiSximada authored Oct 22, 2023
2 parents 4a0fdc3 + ecf8b19 commit 533b985
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions evogym/simulator/SimulatorCPP/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool Environment::revert_to_snapshot(long int sim_time) {
return true;
}

Ref <MatrixXd> 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 <double, 2, Dynamic> empty;
Expand All @@ -273,7 +273,7 @@ Ref <MatrixXd> Environment::get_pos_at_time(long int sim_time) {

return history[sim_time].points_pos;
}
Ref <MatrixXd> 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 <double, 2, Dynamic> empty;
Expand All @@ -285,7 +285,7 @@ Ref <MatrixXd> Environment::get_vel_at_time(long int sim_time) {
return history[sim_time].points_vel;
}

Ref <MatrixXd> 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 <double, 2, Dynamic> empty;
Expand All @@ -300,7 +300,7 @@ Ref <MatrixXd> 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 <MatrixXd> 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 <double, 2, Dynamic> empty;
Expand Down
14 changes: 10 additions & 4 deletions evogym/simulator/SimulatorCPP/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
using namespace std;
using namespace Eigen;

#ifdef __APPLE__
using RefMatrixXd = Matrix <double, 2, Dynamic>;
#else
using RefMatrixXd = Ref <MatrixXd>;
#endif

class Environment
{
private:
Expand Down Expand Up @@ -92,11 +98,11 @@ class Environment
vector<SimObject*>* get_objects();
Robot* get_robot(string robot_name);

Ref <MatrixXd> get_pos_at_time(long int sim_time);
Ref <MatrixXd> 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 <MatrixXd> object_pos_at_time(long int sim_time, string object_name);
Ref <MatrixXd> 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);

Expand Down
8 changes: 4 additions & 4 deletions evogym/simulator/SimulatorCPP/Sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ int Sim::get_time() {
return sim_time;
}

Ref <MatrixXd> 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 <MatrixXd> 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) {
Expand All @@ -151,10 +151,10 @@ void Sim::translate_object(double x, double y, string object_name) {
}


Ref <MatrixXd> 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 <MatrixXd> 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);
}

Expand Down
8 changes: 4 additions & 4 deletions evogym/simulator/SimulatorCPP/Sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Sim
void force_save();
void revert(long int sim_time);
int get_time();
Ref <MatrixXd> pos_at_time(long int sim_time);
Ref <MatrixXd> vel_at_time(long int sim_time);
Ref <MatrixXd> object_pos_at_time(long int sim_time, string object_name);
Ref <MatrixXd> 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 <MatrixXi> get_actuator_indices(string robot_name);
Expand Down

0 comments on commit 533b985

Please sign in to comment.