Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mars.orogen
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ task_context "Task" do

output_port('time', 'double')
output_port('simulated_time', '/base/Time')
output_port('system_time', '/base/Time')
output_port('loop_time_real', 'double')
output_port('loop_time_sim', 'double')
output_port('realtime_factor', 'double')

port_driven 'control_action'

Expand Down
13 changes: 12 additions & 1 deletion tasks/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,18 @@ void Task::receiveData(
const data_broker::DataPackage& package,
int id)
{
_simulated_time.write(base::Time::fromMilliseconds(simulatorInterface->getTime()));
base::Time simtime = base::Time::fromMilliseconds(simulatorInterface->getTime());
base::Time systemtime = base::Time::now();
_simulated_time.write(simtime);
_system_time.write(systemtime);
double realdiff = (systemtime - lastSimUpdateSystemTime).toSeconds();
double simdiff = (simtime - lastSimUpdateSimTime).toSeconds();
_loop_time_real.write(realdiff);
_loop_time_sim.write(simdiff);
_realtime_factor.write(simdiff/realdiff);

lastSimUpdateSimTime = simtime;
lastSimUpdateSystemTime = systemtime;
}

bool Task::setGravity_internal(::base::Vector3d const & value){
Expand Down
3 changes: 3 additions & 0 deletions tasks/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ namespace mars {
pthread_t thread_info;
static lib_manager::LibManager* libManager;

base::Time lastSimUpdateSimTime;
base::Time lastSimUpdateSystemTime;

mars::interfaces::PluginInterface* multisimPlugin;

int getOptionCount(const std::vector<Option>& options);
Expand Down