diff --git a/tools/rosmsg/package.xml b/tools/rosmsg/package.xml
index d68244dfe0..2b686f2460 100644
--- a/tools/rosmsg/package.xml
+++ b/tools/rosmsg/package.xml
@@ -21,6 +21,7 @@
catkin
genmsg
+ genpy
python-rospkg
rosbag
roslib
diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py
index 9a1359fb8e..eff4b94a56 100644
--- a/tools/rosmsg/src/rosmsg/__init__.py
+++ b/tools/rosmsg/src/rosmsg/__init__.py
@@ -48,6 +48,7 @@
import rospkg
import genmsg
+from genpy.dynamic import generate_dynamic
import roslib.message
import rosbag
@@ -603,7 +604,14 @@ def rosmsg_cmd_show(mode, full, alias='show'):
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()