@@ -58,4 +58,91 @@ convert_2_to_1(
5858 ros1_type.nsec = ros2_msg.nanosec ;
5959}
6060
61+
62+ template <>
63+ void
64+ convert_1_to_2 (
65+ const rosgraph_msgs::Log & ros1_msg,
66+ rcl_interfaces::msg::Log & ros2_msg)
67+ {
68+ ros1_bridge::convert_1_to_2 (ros1_msg.header .stamp , ros2_msg.stamp );
69+
70+ // Explicitly map the values of the log level as they differ between
71+ // ROS1 and ROS2.
72+ switch (ros1_msg.level ) {
73+ case rosgraph_msgs::Log::DEBUG:
74+ ros2_msg.level = rcl_interfaces::msg::Log::DEBUG;
75+ break ;
76+
77+ case rosgraph_msgs::Log::INFO:
78+ ros2_msg.level = rcl_interfaces::msg::Log::INFO;
79+ break ;
80+
81+ case rosgraph_msgs::Log::WARN:
82+ ros2_msg.level = rcl_interfaces::msg::Log::WARN;
83+ break ;
84+
85+ case rosgraph_msgs::Log::ERROR:
86+ ros2_msg.level = rcl_interfaces::msg::Log::ERROR;
87+ break ;
88+
89+ case rosgraph_msgs::Log::FATAL:
90+ ros2_msg.level = rcl_interfaces::msg::Log::FATAL;
91+ break ;
92+
93+ default :
94+ ros2_msg.level = ros1_msg.level ;
95+ break ;
96+ }
97+
98+ ros2_msg.name = ros1_msg.name ;
99+ ros2_msg.msg = ros1_msg.msg ;
100+ ros2_msg.file = ros1_msg.file ;
101+ ros2_msg.function = ros1_msg.function ;
102+ ros2_msg.line = ros1_msg.line ;
103+ }
104+
105+ template <>
106+ void
107+ convert_2_to_1 (
108+ const rcl_interfaces::msg::Log & ros2_msg,
109+ rosgraph_msgs::Log & ros1_msg)
110+ {
111+ ros1_bridge::convert_2_to_1 (ros2_msg.stamp , ros1_msg.header .stamp );
112+
113+ // Explicitly map the values of the log level as they differ between
114+ // ROS1 and ROS2.
115+ switch (ros2_msg.level ) {
116+ case rcl_interfaces::msg::Log::DEBUG:
117+ ros1_msg.level = rosgraph_msgs::Log::DEBUG;
118+ break ;
119+
120+ case rcl_interfaces::msg::Log::INFO:
121+ ros1_msg.level = rosgraph_msgs::Log::INFO;
122+ break ;
123+
124+ case rcl_interfaces::msg::Log::WARN:
125+ ros1_msg.level = rosgraph_msgs::Log::WARN;
126+ break ;
127+
128+ case rcl_interfaces::msg::Log::ERROR:
129+ ros1_msg.level = rosgraph_msgs::Log::ERROR;
130+ break ;
131+
132+ case rcl_interfaces::msg::Log::FATAL:
133+ ros1_msg.level = rosgraph_msgs::Log::FATAL;
134+ break ;
135+
136+ default :
137+ ros1_msg.level = ros1_msg.level ;
138+ break ;
139+ }
140+
141+ ros1_msg.name = ros2_msg.name ;
142+ ros1_msg.msg = ros2_msg.msg ;
143+ ros1_msg.file = ros2_msg.file ;
144+ ros1_msg.function = ros2_msg.function ;
145+ ros1_msg.line = ros2_msg.line ;
146+ }
147+
61148} // namespace ros1_bridge
0 commit comments