Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterate mode 2 (regular iterate, comms driven mail) does not work as documented #48

Open
crmoore opened this issue Nov 16, 2018 · 0 comments

Comments

@crmoore
Copy link

crmoore commented Nov 16, 2018

Iterate is delayed after receiving mail. Even indefinitely if mail is regular and faster than app_tick.

OnNewMail is always called as soon as mail arrives, even if max_app_tick should be limiting it.

Reproduction:

  • A simple MOOSApp that subscribes to a single variable. Run with iterate_mode=2, app_tick=1, max_app_tick=1. Print a message on each Iterate and OnNewMail.
  • publish data at 2hz with umm
  • Observe behavior of the subscriber app: OnNewMail is called at 2hz, Iterate is not called.

Test app

  • Run with main --moos_app_tick=1 --moos_max_app_tick=1 --moos_iterate_mode=2
  • Run umm with umm -p=TEST_VAR:10@2
#include <MOOS/libMOOS/App/MOOSApp.h>

#include <iostream>
#include <chrono>

using namespace std::chrono;

class TestApp : public CMOOSApp
{
	bool OnConnectToServer() override;
	bool OnNewMail(std::list<CMOOSMsg>& Main) override;
	bool Iterate() override;

private:
	steady_clock::time_point iter_time, mail_time;
	int mail_count{0}, iter_count{0};
};

int main(int argc, char** argv){

	TestApp App;

	std::cerr << "Running...\n";
	App.Run("TestApp", "mission.moos", argc, argv);
	std::cerr << "Done\n";
}

bool TestApp::OnConnectToServer() {
	std::cerr << "OnConnectToServer\n";

	Register("TEST_VAR", 0);
	return true;
}

bool TestApp::OnNewMail(std::list<CMOOSMsg>& mail) {
	auto now = steady_clock::now();
	double dt_s = duration_cast<duration<double>>(now - mail_time).count();
	mail_time = now;

	std::cerr << "\nOnNewMail " << mail_count++
	          << " " << dt_s << ": " + std::to_string(mail.size()) + "\n";

	for(CMOOSMsg& msg : mail){
		msg.Trace();
	}

	return true;
}


bool TestApp::Iterate() {
	auto now = steady_clock::now();
	double dt_s = duration_cast<duration<double>>(now - iter_time).count();
	iter_time = now;

	std::cerr << "\nIterate " << iter_count++ << " " << dt_s << "\n";

	return true;
}```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant