def test_get_racecar_names(racecar_num, racer_names): """This function checks the functionality of get_racecar_names function in markov/utils.py Args: racecar_num (int): The number of racecars racer_names (List): Returned list of racecar names """ assert utils.get_racecar_names(racecar_num) == racer_names
Arguments: racecar_names (str): The name of the racecar """ pub_list = list() bridge = CvBridge() for racecar_name in racecar_names: camera_topics = get_racecar_camera_topics(racecar_name) for topic in camera_topics: pub_list.append(rospy.Publisher(topic, ROSImg, queue_size=1)) # Publishing frames at 15Hz rate = rospy.Rate(15) img_id = 0 while not rospy.is_shutdown(): img = get_next_img(img_id) img_id = (img_id + 1) % TOTAL_IMAGES frame = bridge.cv2_to_imgmsg(img, "bgr8") for pub in pub_list: pub.publish(frame) rate.sleep() if __name__ == '__main__': try: rospy.init_node('mock_camera_topic_nodes', anonymous=True) RACER_NUM = int(sys.argv[1]) RACECAR_NAMES = get_racecar_names(RACER_NUM) main(RACECAR_NAMES) except rospy.ROSInterruptException: pass
racecar_name.split("_")) == 1 else "agent_{}".format( racecar_name.split("_")[1]) camera_info = utils.get_cameratype_params(racecar_name, agent_name) save_to_mp4_obj = SaveToMp4( camera_infos=[ camera_info[CameraTypeParams.CAMERA_PIP_PARAMS], camera_info[CameraTypeParams.CAMERA_45DEGREE_PARAMS], camera_info[CameraTypeParams.CAMERA_TOPVIEW_PARAMS] ], fourcc=Mp4Parameter.FOURCC.value, fps=Mp4Parameter.FPS.value, frame_size=Mp4Parameter.FRAME_SIZE.value) rospy.Service( '/{}/save_mp4/subscribe_to_save_mp4'.format(racecar_name), Empty, save_to_mp4_obj.subscribe_to_save_mp4) rospy.Service( '/{}/save_mp4/unsubscribe_from_save_mp4'.format(racecar_name), Empty, save_to_mp4_obj.unsubscribe_to_save_mp4) except Exception as err_msg: log_and_exit("Exception in save_mp4 ros node: {}".format(err_msg), SIMAPP_SIMULATION_SAVE_TO_MP4_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500) if __name__ == '__main__': rospy.init_node('save_to_mp4', anonymous=True) RACER_NUM = int(sys.argv[1]) racecar_names = get_racecar_names(RACER_NUM) main(racecar_names) rospy.spin()
car_model_pose = lane.interpolate_pose( distance=self.start_positions[racecar_idx], normalized=False, finite_difference=FiniteDifference.FORWARD_DIFFERENCE) # Construct the model state and send to Gazebo car_model_state = ModelState() car_model_state.model_name = racecar_name car_model_state.pose = car_model_pose car_model_state.twist.linear.x = 0 car_model_state.twist.linear.y = 0 car_model_state.twist.linear.z = 0 car_model_state.twist.angular.x = 0 car_model_state.twist.angular.y = 0 car_model_state.twist.angular.z = 0 self.model_state_client(car_model_state) return car_model_state if __name__ == '__main__': rospy.init_node('car_reset_node', anonymous=True) try: # comma separated racecar names passed as an argument to the node RACER_NUM = int(sys.argv[1]) racecar_names = utils.get_racecar_names(RACER_NUM) DeepRacer(racecar_names) except Exception as ex: log_and_exit("Exception in car node: {}".format(ex), SIMAPP_CAR_NODE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500) rospy.spin()