Skip to content

Commit

Permalink
simtime is now initialized form wall time
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Apr 20, 2024
1 parent bd38dd2 commit fa0d8b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/multirotor_simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ simulation_rate: 100.0 # Hz
clock_rate: 100.0 # Hz
realtime_factor: 1.0 # [-]

# when true, the simulation time will get initialized from wall time
sim_time_from_wall_time: true

g: 9.81 # [ms^-2]

iterate_without_input: true
Expand Down
15 changes: 12 additions & 3 deletions src/multirotor_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ void MultirotorSimulator::onInit() {

srand(time(NULL));

sim_time_ = ros::Time(0);
last_published_time_ = ros::Time(0);

mrs_lib::ParamLoader param_loader(nh_, "MultirotorSimulator");

std::string custom_config_path;
Expand All @@ -132,6 +129,18 @@ void MultirotorSimulator::onInit() {
double clock_rate;
param_loader.loadParam("clock_rate", clock_rate);

bool sim_time_from_wall_time;
param_loader.loadParam("sim_time_from_wall_time", sim_time_from_wall_time);

if (sim_time_from_wall_time) {
sim_time_ = ros::Time(ros::WallTime::now().toSec());
} else {
sim_time_ = ros::Time(0);
}

last_published_time_ = sim_time_;
last_sim_time_status_ = sim_time_;

drs_params_.paused = false;

std::vector<std::string> uav_names;
Expand Down

0 comments on commit fa0d8b6

Please sign in to comment.