Fixing bug -- record was trying to use options as topic names

This commit is contained in:
Jeremy Leibs 2010-06-10 17:38:12 +00:00
parent 2b7d2af41d
commit adb849966a
4 changed files with 64 additions and 3 deletions

View File

@ -70,6 +70,7 @@ struct PlayerOptions
bool has_time;
bool loop;
float time;
bool endless;
std::vector<std::string> bags;
};
@ -152,8 +153,9 @@ private:
void doPublish(rosbag::MessageInstance const& m);
void doEndless();
void printTime();
private:

View File

@ -53,6 +53,7 @@ rosbag::PlayerOptions parseOptions(int argc, char** argv) {
("rate,r", po::value<float>()->default_value(1.0), "multiply the publish rate by FACTOR")
("start,s", po::value<float>()->default_value(0.0), "start SEC seconds into the bag files")
("loop,l", "loop playback")
("endless", "don't terminate at end of bag")
("try-future-version", "still try to open a bag file, even if the version is not known to the player")
("input-file", po::value< std::vector<std::string> >(), "input files");

View File

@ -68,7 +68,8 @@ PlayerOptions::PlayerOptions() :
try_future(false),
has_time(false),
loop(false),
time(0.0f)
time(0.0f),
endless(false)
{
}
@ -193,6 +194,9 @@ void Player::publish() {
doPublish(m);
}
if (options_.endless)
doEndless();
if (!node_handle_.ok()) {
std::cout << std::endl;
break;
@ -306,6 +310,60 @@ void Player::doPublish(MessageInstance const& m) {
pub_iter->second.publish(m);
}
void Player::doEndless() {
ros::Time const& time = ros::TIME_MAX;
ros::Time translated = time_translator_.translate(time);
ros::WallTime horizon = ros::WallTime(translated.sec, translated.nsec);
time_publisher_.setHorizon(time);
time_publisher_.setWCHorizon(horizon);
if (options_.at_once) {
return;
}
while ((paused_ || !time_publisher_.horizonReached()) && node_handle_.ok())
{
bool charsleftorpaused = true;
while (charsleftorpaused && node_handle_.ok())
{
switch (readCharFromStdin()){
case ' ':
paused_ = !paused_;
if (paused_) {
paused_time_ = ros::WallTime::now();
}
else
{
ros::WallDuration shift = ros::WallTime::now() - paused_time_;
paused_time_ = ros::WallTime::now();
time_translator_.shift(ros::Duration(shift.sec, shift.nsec));
horizon += shift;
time_publisher_.setWCHorizon(horizon);
}
break;
case EOF:
if (paused_)
{
printTime();
time_publisher_.runStalledClock(ros::WallDuration(.1));
}
else
charsleftorpaused = false;
}
}
printTime();
time_publisher_.runClock(ros::WallDuration(.1));
}
}
void Player::setupTerminal() {
if (terminal_modified_)
return;

View File

@ -125,7 +125,7 @@ rosbag::RecorderOptions parseOptions(int argc, char** argv) {
for (std::vector<std::string>::iterator i = bags.begin();
i != bags.end();
i++)
opts.topics.push_back(std::string(argv[optind]));
opts.topics.push_back(*i);
}