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

Rosbag windows port #189

Merged
merged 4 commits into from
Mar 21, 2013
Merged
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
2 changes: 1 addition & 1 deletion tools/rosbag/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.3)
project(rosbag)
find_package(catkin REQUIRED COMPONENTS rosconsole roscpp topic_tools xmlrpcpp)
find_package(Boost REQUIRED COMPONENTS regex program_options)
find_package(Boost REQUIRED COMPONENTS date_time regex program_options filesystem)
find_package(BZip2 REQUIRED)

catkin_python_setup()
Expand Down
3 changes: 2 additions & 1 deletion tools/rosbag/include/rosbag/bag.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifndef ROSBAG_BAG_H
#define ROSBAG_BAG_H

#include "rosbag/macros.h"
#include "rosbag/buffer.h"
#include "rosbag/chunked_file.h"
#include "rosbag/constants.h"
Expand Down Expand Up @@ -74,7 +75,7 @@ class MessageInstance;
class View;
class Query;

class Bag
class ROSBAG_DECL Bag
{
friend class MessageInstance;
friend class View;
Expand Down
3 changes: 2 additions & 1 deletion tools/rosbag/include/rosbag/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
#define ROSBAG_BUFFER_H

#include <stdint.h>
#include "macros.h"

namespace rosbag {

class Buffer
class ROSBAG_DECL Buffer
{
public:
Buffer();
Expand Down
4 changes: 2 additions & 2 deletions tools/rosbag/include/rosbag/chunked_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <ios>
#include <stdint.h>
#include <string>

#include "macros.h"
#include <boost/shared_ptr.hpp>

#include <bzlib.h>
Expand All @@ -48,7 +48,7 @@
namespace rosbag {

//! ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed data.
class ChunkedFile
class ROSBAG_DECL ChunkedFile
{
friend class Stream;

Expand Down
45 changes: 45 additions & 0 deletions tools/rosbag/include/rosbag/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ROSBAG_MACROS_H_
#define ROSBAG_MACROS_H_

#include <ros/macros.h> // for the DECL's

// Import/export for windows dll's and visibility for gcc shared libraries.

#ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
#ifdef rosbag_EXPORTS // we are building a shared lib/dll
#define ROSBAG_DECL ROS_HELPER_EXPORT
#else // we are using shared lib/dll
#define ROSBAG_DECL ROS_HELPER_IMPORT
#endif
#else // ros is being built around static libraries
#define ROSBAG_DECL
#endif

#endif /* ROSBAG_MACROS_H_ */
3 changes: 2 additions & 1 deletion tools/rosbag/include/rosbag/message_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <ros/time.h>

#include "rosbag/structures.h"
#include "macros.h"

namespace rosbag {

Expand All @@ -54,7 +55,7 @@ class Bag;
* It adheres to the necessary ros::message_traits to be directly
* serializable.
*/
class MessageInstance
class ROSBAG_DECL MessageInstance
{
friend class View;

Expand Down
18 changes: 13 additions & 5 deletions tools/rosbag/include/rosbag/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
#define ROSBAG_PLAYER_H

#include <sys/stat.h>
#include <termios.h>
#if !defined(_MSC_VER)
#include <termios.h>
#include <unistd.h>
#endif
#include <time.h>
#include <unistd.h>

#include <queue>
#include <string>
Expand All @@ -49,10 +51,11 @@
#include "rosbag/bag.h"

#include "rosbag/time_translator.h"
#include "macros.h"

namespace rosbag {

struct PlayerOptions
struct ROSBAG_DECL PlayerOptions
{
PlayerOptions();

Expand Down Expand Up @@ -81,7 +84,7 @@ struct PlayerOptions


//! PRIVATE. A helper class to track relevant state for publishing time
class TimePublisher {
class ROSBAG_DECL TimePublisher {
public:
/*! Create a time publisher
* A publish_frequency of < 0 indicates that time shouldn't actually be published
Expand Down Expand Up @@ -142,7 +145,7 @@ class TimePublisher {
* This API is currently considered private, but will be released in the
* future after view.
*/
class Player
class ROSBAG_DECL Player
{
public:
Player(PlayerOptions const& options);
Expand Down Expand Up @@ -177,8 +180,13 @@ class Player

// Terminal
bool terminal_modified_;
#if defined(_MSC_VER)
HANDLE input_handle;
DWORD stdin_set;
#else
termios orig_flags_;
fd_set stdin_fdset_;
#endif
int maxfd_;

TimeTranslator time_translator_;
Expand Down
19 changes: 10 additions & 9 deletions tools/rosbag/include/rosbag/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
#include <set>

#include <boost/function.hpp>
#include "macros.h"

namespace rosbag {

class Bag;
class ConnectionInfo;
class IndexEntry;
struct ConnectionInfo;
struct IndexEntry;

class Query
class ROSBAG_DECL Query
{
public:
//! The base query takes an optional time-range
Expand All @@ -72,7 +73,7 @@ class Query
ros::Time end_time_;
};

class TopicQuery
class ROSBAG_DECL TopicQuery
{
public:
TopicQuery(std::string const& topic);
Expand All @@ -84,7 +85,7 @@ class TopicQuery
std::vector<std::string> topics_;
};

class TypeQuery
class ROSBAG_DECL TypeQuery
{
public:
TypeQuery(std::string const& type);
Expand All @@ -97,7 +98,7 @@ class TypeQuery
};

//! Pairs of queries and the bags they come from (used internally by View)
struct BagQuery
struct ROSBAG_DECL BagQuery
{
BagQuery(Bag const* _bag, Query const& _query, uint32_t _bag_revision);

Expand All @@ -106,7 +107,7 @@ struct BagQuery
uint32_t bag_revision;
};

struct MessageRange
struct ROSBAG_DECL MessageRange
{
MessageRange(std::multiset<IndexEntry>::const_iterator const& _begin,
std::multiset<IndexEntry>::const_iterator const& _end,
Expand All @@ -120,15 +121,15 @@ struct MessageRange
};

//! The actual iterator data structure
struct ViewIterHelper
struct ROSBAG_DECL ViewIterHelper
{
ViewIterHelper(std::multiset<IndexEntry>::const_iterator _iter, MessageRange const* _range);

std::multiset<IndexEntry>::const_iterator iter;
MessageRange const* range; //!< pointer to vector of ranges in View
};

struct ViewIterHelperCompare
struct ROSBAG_DECL ViewIterHelperCompare
{
bool operator()(ViewIterHelper const& a, ViewIterHelper const& b);
};
Expand Down
15 changes: 9 additions & 6 deletions tools/rosbag/include/rosbag/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
#define ROSBAG_RECORDER_H

#include <sys/stat.h>
#include <termios.h>
#if !defined(_MSC_VER)
#include <termios.h>
#include <unistd.h>
#endif
#include <time.h>
#include <unistd.h>

#include <queue>
#include <string>
Expand All @@ -56,10 +58,11 @@

#include "rosbag/bag.h"
#include "rosbag/stream.h"
#include "rosbag/macros.h"

namespace rosbag {

class OutgoingMessage
class ROSBAG_DECL OutgoingMessage
{
public:
OutgoingMessage(std::string const& _topic, topic_tools::ShapeShifter::ConstPtr _msg, boost::shared_ptr<ros::M_string> _connection_header, ros::Time _time);
Expand All @@ -70,7 +73,7 @@ class OutgoingMessage
ros::Time time;
};

class OutgoingQueue
class ROSBAG_DECL OutgoingQueue
{
public:
OutgoingQueue(std::string const& _filename, std::queue<OutgoingMessage>* _queue, ros::Time _time);
Expand All @@ -80,7 +83,7 @@ class OutgoingQueue
ros::Time time;
};

struct RecorderOptions
struct ROSBAG_DECL RecorderOptions
{
RecorderOptions();

Expand All @@ -106,7 +109,7 @@ struct RecorderOptions
std::vector<std::string> topics;
};

class Recorder
class ROSBAG_DECL Recorder
{
public:
Recorder(RecorderOptions const& options);
Expand Down
9 changes: 5 additions & 4 deletions tools/rosbag/include/rosbag/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <bzlib.h>

#include "rosbag/exceptions.h"
#include "rosbag/macros.h"

namespace rosbag {

Expand All @@ -59,7 +60,7 @@ typedef compression::CompressionType CompressionType;

class ChunkedFile;

class Stream
class ROSBAG_DECL Stream
{
public:
Stream(ChunkedFile* file);
Expand Down Expand Up @@ -93,7 +94,7 @@ class Stream
ChunkedFile* file_;
};

class StreamFactory
class ROSBAG_DECL StreamFactory
{
public:
StreamFactory(ChunkedFile* file);
Expand All @@ -105,7 +106,7 @@ class StreamFactory
boost::shared_ptr<Stream> bz2_stream_;
};

class UncompressedStream : public Stream
class ROSBAG_DECL UncompressedStream : public Stream
{
public:
UncompressedStream(ChunkedFile* file);
Expand All @@ -121,7 +122,7 @@ class UncompressedStream : public Stream
/*!
* BZ2Stream uses libbzip2 (http://www.bzip.org) for reading/writing compressed data in the BZ2 format.
*/
class BZ2Stream : public Stream
class ROSBAG_DECL BZ2Stream : public Stream
{
public:
BZ2Stream(ChunkedFile* file);
Expand Down
11 changes: 6 additions & 5 deletions tools/rosbag/include/rosbag/structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@

#include "ros/time.h"
#include "ros/ros.h"
#include "macros.h"

namespace rosbag {

struct ConnectionInfo
struct ROSBAG_DECL ConnectionInfo
{
ConnectionInfo() : id(-1) { }

Expand All @@ -56,7 +57,7 @@ struct ConnectionInfo
boost::shared_ptr<ros::M_string> header;
};

ros::AdvertiseOptions createAdvertiseOptions(const ConnectionInfo* c, uint32_t queue_size);
ROSBAG_DECL ros::AdvertiseOptions createAdvertiseOptions(const ConnectionInfo* c, uint32_t queue_size);

struct ChunkInfo
{
Expand All @@ -67,14 +68,14 @@ struct ChunkInfo
std::map<uint32_t, uint32_t> connection_counts; //! number of messages in each connection stored in the chunk
};

struct ChunkHeader
struct ROSBAG_DECL ChunkHeader
{
std::string compression; //! chunk compression type, e.g. "none" or "bz2" (see constants.h)
uint32_t compressed_size; //! compressed size of the chunk in bytes
uint32_t uncompressed_size; //! uncompressed size of the chunk in bytes
};

struct IndexEntry
struct ROSBAG_DECL IndexEntry
{
ros::Time time; //! timestamp of the message
uint64_t chunk_pos; //! absolute byte offset of the chunk record containing the message
Expand All @@ -83,7 +84,7 @@ struct IndexEntry
bool operator<(IndexEntry const& b) const { return time < b.time; }
};

struct IndexEntryCompare
struct ROSBAG_DECL IndexEntryCompare
{
bool operator()(ros::Time const& a, IndexEntry const& b) const { return a < b.time; }
bool operator()(IndexEntry const& a, ros::Time const& b) const { return a.time < b; }
Expand Down
Loading