diff --git a/python/gz_service_info.py b/python/gz_service_info.py index 43a771c..a48ff3d 100755 --- a/python/gz_service_info.py +++ b/python/gz_service_info.py @@ -22,7 +22,7 @@ import argparse -from gz.transport import Node +from gz.python.transport import Node def main(): # process command line diff --git a/python/gz_service_list.py b/python/gz_service_list.py index b93d1ca..ba79303 100755 --- a/python/gz_service_list.py +++ b/python/gz_service_list.py @@ -20,7 +20,7 @@ $ gz service -l ''' -from gz.transport import Node +from gz.python.transport import Node def main(): # create a transport node diff --git a/python/gz_topic_echo.py b/python/gz_topic_echo.py index 0a55527..29baa0a 100755 --- a/python/gz_topic_echo.py +++ b/python/gz_topic_echo.py @@ -21,10 +21,20 @@ ''' import argparse +import os import time -from gz.transport import SubscribeOptions -from gz.transport import Node +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + +from gz.python.transport import SubscribeOptions +from gz.python.transport import Node + # callback - prints the raw message def cb(msg): diff --git a/python/gz_topic_info.py b/python/gz_topic_info.py index f3d1c59..480c1a2 100755 --- a/python/gz_topic_info.py +++ b/python/gz_topic_info.py @@ -22,7 +22,8 @@ import argparse -from gz.transport import Node +from gz.python.transport import Node + def main(): # process command line diff --git a/python/gz_topic_list.py b/python/gz_topic_list.py index 6e7ed43..e9d4979 100755 --- a/python/gz_topic_list.py +++ b/python/gz_topic_list.py @@ -19,8 +19,8 @@ $ gz topic -l ''' +from gz.python.transport import Node -from gz.transport import Node def main(): # create a transport node diff --git a/python/import_check.py b/python/import_check.py index a16aa8d..059e95e 100755 --- a/python/import_check.py +++ b/python/import_check.py @@ -14,21 +14,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys -import time +import os + +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") from gz.msgs.any_pb2 import Any from gz.msgs.header_pb2 import Header from gz.msgs.stringmsg_pb2 import StringMsg from gz.msgs.time_pb2 import Time -from gz.msgs.extras import make_time -from gz.msgs.extras import take_time -from gz.msgs.extras import take_topic_info -from gz.msgs.extras import take_wrench +from gz.python.msgs_extras import make_time +from gz.python.msgs_extras import take_time +from gz.python.msgs_extras import take_topic_info +from gz.python.msgs_extras import take_wrench -from gz.transport import AdvertiseMessageOptions -from gz.transport import Node +from gz.python.transport import AdvertiseMessageOptions +from gz.python.transport import Node def main(): @@ -39,9 +46,11 @@ def main(): msg = Any() msg = Header() msg = StringMsg() + msg = Time() # msgs functions msg = make_time() + take_time(msg) # transport types opts = AdvertiseMessageOptions() diff --git a/python/msgs_example.py b/python/msgs_example.py index e22ae61..289e7a4 100755 --- a/python/msgs_example.py +++ b/python/msgs_example.py @@ -14,6 +14,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.header_pb2 import Header from gz.msgs.double_pb2 import Double from gz.msgs.double_v_pb2 import Double_V diff --git a/python/pub_all_msg_types.py b/python/pub_all_msg_types.py index ff40ab3..b53d6e7 100755 --- a/python/pub_all_msg_types.py +++ b/python/pub_all_msg_types.py @@ -14,8 +14,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import time +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.cmd_vel2d_pb2 import CmdVel2D from gz.msgs.double_pb2 import Double from gz.msgs.double_v_pb2 import Double_V @@ -35,8 +44,9 @@ from gz.msgs.vector3d_pb2 import Vector3d from gz.msgs.wrench_pb2 import Wrench -from gz.transport import AdvertiseMessageOptions -from gz.transport import Node +from gz.python.transport import AdvertiseMessageOptions +from gz.python.transport import Node + def main(): # Create a transport node and advertise options diff --git a/python/publisher.py b/python/publisher.py index 74e8733..db11a4f 100755 --- a/python/publisher.py +++ b/python/publisher.py @@ -14,12 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import time +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.stringmsg_pb2 import StringMsg -from gz.transport import AdvertiseMessageOptions -from gz.transport import Node +from gz.python.transport import AdvertiseMessageOptions +from gz.python.transport import Node def main(): # Create a transport node and advertise a topic diff --git a/python/rover_publisher.py b/python/rover_publisher.py index 526fcd7..3196992 100755 --- a/python/rover_publisher.py +++ b/python/rover_publisher.py @@ -16,8 +16,17 @@ from scipy.spatial.transform import Rotation as Rotation import math +import os import time +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.header_pb2 import Header from gz.msgs.pose_pb2 import Pose from gz.msgs.quaternion_pb2 import Quaternion @@ -25,8 +34,8 @@ from gz.msgs.twist_pb2 import Twist from gz.msgs.vector3d_pb2 import Vector3d -from gz.transport import AdvertiseMessageOptions -from gz.transport import Node +from gz.python.transport import AdvertiseMessageOptions +from gz.python.transport import Node def main(): # Create a transport node and advertise a topic diff --git a/python/rover_subscriber.py b/python/rover_subscriber.py index 9f2287b..737542d 100755 --- a/python/rover_subscriber.py +++ b/python/rover_subscriber.py @@ -15,15 +15,24 @@ # limitations under the License. import time +import os import typing +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.pose_pb2 import Pose from gz.msgs.quaternion_pb2 import Quaternion from gz.msgs.twist_pb2 import Twist from gz.msgs.vector3d_pb2 import Vector3d -from gz.transport import Node -from gz.transport import SubscribeOptions +from gz.python.transport import Node +from gz.python.transport import SubscribeOptions def pose_cb(msg: Pose) -> None: diff --git a/python/subscriber.py b/python/subscriber.py index eb864bc..b0d7cad 100755 --- a/python/subscriber.py +++ b/python/subscriber.py @@ -15,12 +15,21 @@ # limitations under the License. import time +import os import typing +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.stringmsg_pb2 import StringMsg -from gz.transport import SubscribeOptions -from gz.transport import Node +from gz.python.transport import SubscribeOptions +from gz.python.transport import Node def cb(msg: StringMsg) -> None: print("Msg: [{}] from Python".format(msg.data)) diff --git a/python/transport_example.py b/python/transport_example.py index 3e74454..df20104 100755 --- a/python/transport_example.py +++ b/python/transport_example.py @@ -14,6 +14,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + +# alias gz.msgs{GZ_MSGS_VER} to gz.msgs +if os.environ["GZ_VERSION"] == "garden": + from gz import msgs9 as msgs +elif os.environ["GZ_VERSION"] == "harmonic": + from gz import msgs10 as msgs +else: + raise Exception(f"Invalid GZ_VERSION: {os.environ['GZ_VERSION']}") + from gz.msgs.header_pb2 import Header from gz.msgs.time_pb2 import Time from gz.msgs.quaternion_pb2 import Quaternion @@ -22,9 +32,9 @@ from gz.msgs.vector3d_pb2 import Vector3d from gz.msgs.wrench_pb2 import Wrench -from gz.transport import AdvertiseMessageOptions -from gz.transport import SubscribeOptions -from gz.transport import Node +from gz.python.transport import AdvertiseMessageOptions +from gz.python.transport import SubscribeOptions +from gz.python.transport import Node from google.protobuf.internal import api_implementation