Skip to content

Commit

Permalink
fix rosmsg show from bag
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Feb 28, 2017
1 parent 1246727 commit 75581e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions tools/rosmsg/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<run_depend version_gte="0.6.4">catkin</run_depend>
<run_depend>genmsg</run_depend>
<run_depend version_gte="0.6.5">genpy</run_depend>
<run_depend>python-rospkg</run_depend>
<run_depend>rosbag</run_depend>
<run_depend>roslib</run_depend>
Expand Down
12 changes: 10 additions & 2 deletions tools/rosmsg/src/rosmsg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

import rospkg
import genmsg
from genpy.dynamic import generate_dynamic

import roslib.message
import rosbag
Expand Down Expand Up @@ -596,17 +597,24 @@ def rosmsg_cmd_show(mode, full, alias='show'):
parser.error(cmd+" does not understand C++-style namespaces (i.e. '::').\nPlease refer to msg/srv types as 'package_name/Type'.")
elif '.' in arg:
parser.error("invalid message type '%s'.\nPlease refer to msg/srv types as 'package_name/Type'." % arg)
rospack = rospkg.RosPack()
if options.bag:
bag_file = options.bag
if not os.path.exists(bag_file):
raise ROSMsgException("ERROR: bag file [%s] does not exist"%bag_file)
for topic, msg, t in rosbag.Bag(bag_file).read_messages(raw=True):
datatype, _, _, _, pytype = msg
if datatype == arg:
print(get_msg_text(datatype, options.raw, pytype._full_text))
if options.raw:
print(pytype._full_text)
else:
context = genmsg.MsgContext.create_default()
msgs = generate_dynamic(datatype, pytype._full_text)
for t, msg in msgs.items():
context.register(t, msg._spec)
print(spec_to_str(context, msgs[datatype]._spec))
break
else:
rospack = rospkg.RosPack()
if '/' in arg: #package specified
rosmsg_debug(rospack, mode, arg, options.raw)
else:
Expand Down

0 comments on commit 75581e7

Please sign in to comment.