Pause service for rosbag player#949
Pause service for rosbag player#949mikepurvis merged 8 commits intoros:kinetic-develfrom locusrobotics:pause-service
Conversation
tools/rosbag/src/player.cpp
Outdated
| } | ||
| else | ||
| { | ||
| ros::WallDuration shift = ros::WallTime::now() - paused_time_; |
There was a problem hiding this comment.
I realize this logic is duplicated in the keyboard input processing below, and can put it in a method if preferred.
|
That said, it may be good to rename the service to something a little less generic if we can't conveniently namespace it. |
tools/rosbag/src/player.cpp
Outdated
|
|
||
| if (res.success) | ||
| { | ||
| res.message = (requested_pause_state_ ? "Pause" : "Resume") + std::string(" requested."); |
There was a problem hiding this comment.
Wondering if this should be past tense? Eg, Bag playback is now paused/resumed.
tools/rosbag/src/player.cpp
Outdated
| requested_pause_state_(false), | ||
| terminal_modified_(false) | ||
| { | ||
| pause_service_ = node_handle_.advertiseService("pause", &Player::pauseCallback, this); |
There was a problem hiding this comment.
Obviously a different service name here.
Perhaps another option might be:
ros::NodeHandle private_node_handle('~');
pause_service_ = private_node_handle.advertiseService("pause", &Player::pauseCallback, this);
This should get you a rosbag/pause service name, but it will be trivial to rename/remap it from roslaunch or wherever else.
There was a problem hiding this comment.
I wasn't sure what the best route was here. The problem with a private node handle is that if you're running rosbag play outside a launch file, it will by default be given an anonymous name, and so calling the service is a pain (e.g., rosservice call /play_1484077899473435649/pause). As I couldn't envisage a use case wherein we'd be running more than one rosbag play instance, I figured a service in the global namespace would work.
However, I also can't really see using this outside of a launch file, and even if we did, we could assign a name via the command line. I'll move it back to the private node handle.
|
This seems simple and straightforward. I'd support a merge if the service name can be sorted out. |
…service using a private node handle.
|
LGTM. |
jspricke
left a comment
There was a problem hiding this comment.
Thanks! +1 apart from some comments.
tools/rosbag/src/player.cpp
Outdated
| terminal_modified_(false) | ||
| { | ||
| ros::NodeHandle private_node_handle("~"); | ||
| pause_service_ = private_node_handle.advertiseService("pause", &Player::pauseCallback, this); |
There was a problem hiding this comment.
maybe name it "pause_playback"?
|
|
||
| ros::NodeHandle node_handle_; | ||
|
|
||
| ros::ServiceServer pause_service_; |
There was a problem hiding this comment.
I guess this changes the ABI, but I don't think anyone is relying on that @dirk-thomas ?
There was a problem hiding this comment.
If we can avoid breaking the ABI than we should for sure aim for that. While we don't "guarantee" it we try to make an effort where possible.
There was a problem hiding this comment.
OK. Shall I make this static?
There was a problem hiding this comment.
I think ABI would be maintained if all the new fields (and method) were appended to the class rather than inserted.
However, IMO this is not worth it for the loss in source readability— there are unlikely to be external packages linking to this class.
There was a problem hiding this comment.
OK, I can go either way. Let me know what you'd all prefer.
tools/rosbag/src/player.cpp
Outdated
| } | ||
| else | ||
| { | ||
| ros::WallDuration shift = ros::WallTime::now() - paused_time_; |
|
Looks great— thanks Tom! |
* Adding pause service to rosbag Player class * Adding std_srvs dependency * Making response more informative * Using private node handle to advertise service * Removing private namespace from node handle * PR feedback: changing response message to past tense and advertising service using a private node handle. * PR feedback: changing service name and placing pause handling logic in a method
We've recently required the ability to pause playback in
rosbag playvia service calls within code. The changes include the addition of aspinOnce()call withindoPublish()so that we can process the service request. I'm not sure if having callbacks in thePlayerclass is acceptable, or if this functionality would be useful for anyone else, but I thought it worth a PR.