Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
  • Loading branch information
maxime-clem committed May 31, 2024
1 parent bf0a4b0 commit d1dd300
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
4 changes: 2 additions & 2 deletions simulator/carla_autoware/src/carla_autoware/carla_autoware.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import carla

from .carla_ros import carla_interface
from .carla_ros import carla_ros2_interface
from .modules.carla_data_provider import CarlaDataProvider
from .modules.carla_data_provider import GameTime
from .modules.carla_wrapper import SensorReceivedNoData
Expand Down Expand Up @@ -54,7 +54,7 @@ def _tick_sensor(self, timestamp):

class InitializeInterface(object):
def __init__(self):
self.interface = carla_interface()
self.interface = carla_ros2_interface()
self.param_ = self.interface.get_param()
self.world = None
self.sensor_wrapper = None
Expand Down
25 changes: 9 additions & 16 deletions simulator/carla_autoware/src/carla_autoware/carla_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.sr/bin/env python

import json
import logging
import math
import threading

Expand All @@ -40,7 +39,6 @@
from tier4_vehicle_msgs.msg import ActuationStatusStamped
from transforms3d.euler import euler2quat

from .modules.carla_data_provider import CarlaDataProvider
from .modules.carla_data_provider import GameTime
from .modules.carla_data_provider import datetime
from .modules.carla_utils import carla_location_to_ros_point
Expand All @@ -50,7 +48,7 @@
from .modules.carla_wrapper import SensorInterface


class carla_interface(object):
class carla_ros2_interface(object):
def __init__(self):
self.sensor_interface = SensorInterface()
self.timestamp = None
Expand All @@ -77,8 +75,7 @@ def __init__(self):

# initialize ros2 node
rclpy.init(args=None)
self.ros2_node = rclpy.create_node("carla_interface")
self.logger = logging.getLogger("log")
self.ros2_node = rclpy.create_node("carla_ros2_interface")
self.parameters = {
"host": rclpy.Parameter.Type.STRING,
"port": rclpy.Parameter.Type.INTEGER,
Expand Down Expand Up @@ -157,13 +154,15 @@ def __init__(self):
PointCloud2, f'/sensing/lidar/{sensor["id"]}/pointcloud', 10
)
else:
self.logger.info("Please use Top, Right, or Left as the LIDAR ID")
self.ros2_node.get_logger().info(
"Please use Top, Right, or Left as the LIDAR ID"
)
elif sensor["type"] == "sensor.other.imu":
self.pub_imu = self.ros2_node.create_publisher(
Imu, "/sensing/imu/tamagawa/imu_raw", 1
)
else:
self.logger.info("No Publisher for this Sensor")
self.ros2_node.get_logger().info("No Publisher for this Sensor")
pass

self.spin_thread = threading.Thread(target=rclpy.spin, args=(self.ros2_node,))
Expand Down Expand Up @@ -245,15 +244,9 @@ def pose(self):
header = self.get_msg_header(frame_id="map")
out_pose_with_cov = PoseWithCovarianceStamped()
pose_carla = Pose()
pose_carla.position = carla_location_to_ros_point(
CarlaDataProvider.get_transform(
CarlaDataProvider.get_actor_by_name(self.param_values["ego_vehicle_role_name"])
).location
)
pose_carla.position = carla_location_to_ros_point(self.ego_actor.get_transform().location)
pose_carla.orientation = carla_rotation_to_ros_quaternion(
CarlaDataProvider.get_transform(
CarlaDataProvider.get_actor_by_name(self.param_values["ego_vehicle_role_name"])
).rotation
self.ego_actor.get_transform().rotation
)
out_pose_with_cov.header = header
out_pose_with_cov.pose.pose = pose_carla
Expand Down Expand Up @@ -461,7 +454,7 @@ def run_step(self, input_data, timestamp):
elif sensor_type == "sensor.other.imu":
self.imu(data[1])
else:
self.logger.info("No Publisher for [{key}] Sensor")
self.ros2_node.get_logger().info("No Publisher for [{key}] Sensor")

# Publish ego vehicle status
self.ego_status()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import carla
from geometry_msgs.msg import Point
from geometry_msgs.msg import Quaternion
import numpy as np
from sensor_msgs.msg import PointCloud2
from sensor_msgs.msg import PointField
from transforms3d.euler import euler2quat
Expand Down

0 comments on commit d1dd300

Please sign in to comment.