-
Notifications
You must be signed in to change notification settings - Fork 261
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
Display bag summary using ros2 bag info
(reduced size)
#45
Merged
Karsten1987
merged 14 commits into
ros2:master
from
bosch-io:feature/ros2_bag_info_small
Oct 30, 2018
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
83ad0c2
Display bag summary using `ros2 bag info`
greimela-si 53f448e
Improve process execution helper to handle the working directory
greimela-si ff240aa
Use metadata filename in sqlite storage to determine database name
greimela-si 1b22db1
GH-109 Write metadata file on Windows by hand
Martin-Idel-SI fdb1c9b
Remove empty bag folder if record gets aborted and no files are created
botteroa-si 59f3558
Fail gracefully if a runtime error occurs when trying to record or play
botteroa-si 576097c
Log error in case of failing when loading metadata, and minor refacto…
botteroa-si c8a8c75
Add comment to version field
Martin-Idel-SI 5e09b5f
Allow rosbag2 info without yaml file
Martin-Idel-SI d5f74ee
GH-7 Don't try to read database name from metadata file when opening …
botteroa-si 9356463
GH-7 Rename 'storage format' into 'serialization format'
botteroa-si 7d26d6a
GH-7 Improve failure conditions
Martin-Idel-SI e6dacb3
GH-7 Cleanup of superfluous forward declarations
Martin-Idel-SI 4e4b46a
GH-7 Further improve exception handling
Martin-Idel-SI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2018, Bosch Software Innovations GmbH. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2__INFO_HPP_ | ||
#define ROSBAG2__INFO_HPP_ | ||
|
||
#include <string> | ||
|
||
#include "rosbag2/types.hpp" | ||
#include "visibility_control.hpp" | ||
|
||
namespace rosbag2 | ||
{ | ||
|
||
class ROSBAG2_PUBLIC Info | ||
{ | ||
public: | ||
virtual ~Info() = default; | ||
|
||
virtual rosbag2::BagMetadata read_metadata( | ||
const std::string & uri, const std::string & storage_id = ""); | ||
}; | ||
|
||
} // namespace rosbag2 | ||
|
||
#endif // ROSBAG2__INFO_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2018, Bosch Software Innovations GmbH. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "rosbag2/info.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "rosbag2_storage/filesystem_helper.hpp" | ||
#include "rosbag2_storage/metadata_io.hpp" | ||
#include "rosbag2_storage/storage_factory.hpp" | ||
|
||
namespace rosbag2 | ||
{ | ||
|
||
rosbag2::BagMetadata Info::read_metadata(const std::string & uri, const std::string & storage_id) | ||
{ | ||
rosbag2_storage::MetadataIo metadata_io; | ||
if (metadata_io.metadata_file_exists(uri)) { | ||
return metadata_io.read_metadata(uri); | ||
} | ||
if (!storage_id.empty()) { | ||
rosbag2_storage::StorageFactory factory; | ||
std::shared_ptr<rosbag2_storage::storage_interfaces::ReadOnlyInterface> storage; | ||
storage = factory.open_read_only(uri, storage_id); | ||
if (!storage) { | ||
throw std::runtime_error("The metadata.yaml file does not exist and the bag could not be " | ||
"opened."); | ||
} | ||
auto bag_metadata = storage->get_metadata(); | ||
bag_metadata.bag_size = rosbag2_storage::FilesystemHelper::calculate_directory_size(uri); | ||
return bag_metadata; | ||
} | ||
throw std::runtime_error("The metadata.yaml file does not exist. Please specify a the " | ||
"storage id of the bagfile to query it directly"); | ||
} | ||
} // namespace rosbag2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2018, Bosch Software Innovations GmbH. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2__MOCK_METADATA_IO_HPP_ | ||
#define ROSBAG2__MOCK_METADATA_IO_HPP_ | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "rosbag2_storage/bag_metadata.hpp" | ||
#include "rosbag2_storage/metadata_io.hpp" | ||
|
||
class MockMetadataIo : public rosbag2_storage::MetadataIo | ||
{ | ||
public: | ||
MOCK_METHOD2(write_metadata, void(const std::string &, rosbag2_storage::BagMetadata)); | ||
MOCK_METHOD1(read_metadata, rosbag2_storage::BagMetadata(const std::string &)); | ||
}; | ||
|
||
#endif // ROSBAG2__MOCK_METADATA_IO_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2018, Bosch Software Innovations GmbH. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2__MOCK_STORAGE_HPP_ | ||
#define ROSBAG2__MOCK_STORAGE_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "rosbag2_storage/bag_metadata.hpp" | ||
#include "rosbag2_storage/serialized_bag_message.hpp" | ||
#include "rosbag2_storage/topic_with_type.hpp" | ||
#include "rosbag2_storage/storage_interfaces/read_write_interface.hpp" | ||
|
||
class MockStorage : public rosbag2_storage::storage_interfaces::ReadWriteInterface | ||
{ | ||
public: | ||
~MockStorage() override = default; | ||
|
||
void open(const std::string & uri, rosbag2_storage::storage_interfaces::IOFlag flag) override | ||
{ | ||
(void) uri; | ||
(void) flag; | ||
} | ||
|
||
void create_topic(const rosbag2_storage::TopicWithType & topic) override | ||
{ | ||
(void) topic; | ||
} | ||
|
||
bool has_next() override {return true;} | ||
|
||
std::shared_ptr<rosbag2_storage::SerializedBagMessage> read_next() override {return nullptr;} | ||
|
||
void write(std::shared_ptr<const rosbag2_storage::SerializedBagMessage> msg) override | ||
{ | ||
(void) msg; | ||
} | ||
|
||
std::vector<rosbag2_storage::TopicWithType> get_all_topics_and_types() override | ||
{ | ||
return std::vector<rosbag2_storage::TopicWithType>(); | ||
} | ||
|
||
rosbag2_storage::BagMetadata get_metadata() override | ||
{ | ||
return rosbag2_storage::BagMetadata(); | ||
} | ||
}; | ||
|
||
#endif // ROSBAG2__MOCK_STORAGE_HPP_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be there is a design flaw here. I believe there should be a function (exposed) which can check whether the specified plugin is correct. That is, before calling straight up
record
, I think we should be able to initialize and setup the recorder at first and then call record. Having the recorder setup first allows for error checking.Then second, the code for removing the folder only works right now because record has to be cancelled by
ctrl-c
(because of the spin inside). I believe this should be handled by a signint handler, to cancel the record deliberately.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO the "design flaw" is that the directory creation happens already in the python layer before instead of having the storage taking care of that. The reason for this is that cross platform file handling is hard to do in C++ but much easier in Python.
Creating a separate
initialize
method would only solidify this workaround and would still leave some scenarios uncovered that cannot be detected beforehand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the second point I agree that we will need to do our own signal handling for that and then we also need to change this "failure detection". I would prefer to do this with another pull request.