MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / setup

Method setup

scenario_runner/srunner/autoagents/ros_agent.py:65–160  ·  view source on GitHub ↗

setup agent

(self, path_to_conf_file)

Source from the content-addressed store, hash-verified

63 global_plan_published = None
64
65 def setup(self, path_to_conf_file):
66 """
67 setup agent
68 """
69 self.stack_thread = None
70
71 # get start_script from environment
72 team_code_path = os.environ['TEAM_CODE_ROOT']
73 if not team_code_path or not os.path.exists(team_code_path):
74 raise IOError("Path '{}' defined by TEAM_CODE_ROOT invalid".format(team_code_path))
75 start_script = "{}/start.sh".format(team_code_path)
76 if not os.path.exists(start_script):
77 raise IOError("File '{}' defined by TEAM_CODE_ROOT invalid".format(start_script))
78
79 # set use_sim_time via commandline before init-node
80 process = subprocess.Popen(
81 "rosparam set use_sim_time true", shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
82 process.wait()
83 if process.returncode:
84 raise RuntimeError("Could not set use_sim_time")
85
86 # initialize ros node
87 rospy.init_node('ros_agent', anonymous=True)
88
89 # publish first clock value '0'
90 self.clock_publisher = rospy.Publisher('clock', Clock, queue_size=10, latch=True)
91 self.clock_publisher.publish(Clock(rospy.Time.from_sec(0)))
92
93 # execute script that starts the ad stack (remains running)
94 rospy.loginfo("Executing stack...")
95 self.stack_process = subprocess.Popen(start_script, shell=True, preexec_fn=os.setpgrp)
96
97 self.vehicle_control_event = threading.Event()
98 self.timestamp = None
99 self.speed = 0
100 self.global_plan_published = False
101
102 self.vehicle_info_publisher = None
103 self.vehicle_status_publisher = None
104 self.odometry_publisher = None
105 self.world_info_publisher = None
106 self.map_file_publisher = None
107 self.current_map_name = None
108 self.tf_broadcaster = None
109 self.step_mode_possible = False
110
111 self.vehicle_control_subscriber = rospy.Subscriber(
112 '/carla/ego_vehicle/vehicle_control_cmd', CarlaEgoVehicleControl, self.on_vehicle_control)
113
114 self.current_control = carla.VehicleControl()
115
116 self.waypoint_publisher = rospy.Publisher(
117 '/carla/ego_vehicle/waypoints', Path, queue_size=1, latch=True)
118
119 self.publisher_map = {}
120 self.id_to_sensor_type_map = {}
121 self.id_to_camera_info_map = {}
122 self.cv_bridge = CvBridge()

Callers

nothing calls this directly

Calls 2

sensorsMethod · 0.95
build_camera_infoMethod · 0.95

Tested by

no test coverage detected