- branched out from initial branch to keep the branch given to Romain untouched
- changed things so that the only available mode is "render all frames", no more "renderOnlyCapturedFrames" flag.
- Added simulation timing ability for manual camera
- more work on multi cam coordination
- changed tests to reflect new changes
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)),newGUIContent("Save Camera Output to Disk","For each captured frame, save an RGB image of the perception camera's output to disk."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureTriggerMode)),newGUIContent("Capture Trigger Mode",$"The method of triggering captures for this camera. In {nameof(PerceptionCamera.CaptureTriggerMode.Scheduled)} mode, captures happen automatically based on a start time/frame and time/frame interval. In {nameof(PerceptionCamera.CaptureTriggerMode.Manual)} mode, captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)),newGUIContent("Save Camera RGB Output to Disk","For each captured frame, save an RGB image of the perception camera's output to disk."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureTriggerMode)),newGUIContent("Capture Trigger Mode",$"The method of triggering captures for this camera. In {nameof(PerceptionCamera.CaptureTriggerMode.Scheduled)} mode, captures happen automatically based on a start frame and frame delta time. In {nameof(PerceptionCamera.CaptureTriggerMode.Manual)} mode, captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}."));
GUILayout.Space(5);
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.onlyRenderCapturedFrames)),newGUIContent(onlyRenderCaptTitle,$"If this checkbox is enabled, the attached camera will only render those frames that it needs to capture. In addition, the global frame delta time will be altered to match this camera's capture period, thus, the scene will not be visually updated in-between captures (physics simulation is unaffected). Therefore, if you have more than one {nameof(PerceptionCamera)} active, this flag should be either disabled or enabled for all of them, otherwise the cameras will not capture and synchronize properly."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.simulationDeltaTime)),newGUIContent(k_FrametimeTitle,$"Sets Unity's Time.{nameof(Time.captureDeltaTime)} to the specified number, causing a fixed number of frames to be simulated for each second of elapsed simulation time regardless of the capabilities of the underlying hardware. Thus, simulation time and real time will not be synchronized."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.firstCaptureFrame)),newGUIContent("Start at Frame",$"Frame number at which this camera starts capturing."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.framesBetweenCaptures)),newGUIContent("Frames Between Captures","The number of frames to simulate and render between the camera's scheduled captures. Setting this to 0 makes the camera capture every frame."));
if(perceptionCamera.onlyRenderCapturedFrames)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startTime)),newGUIContent("Start Time","Time at which this perception camera starts rendering and capturing (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.period)),newGUIContent(periodTilte,"The interval at which the perception camera should render and capture (seconds)."));
EditorGUILayout.HelpBox($"First capture at {startTime} seconds and consecutive captures every {interval} seconds of simulation time.",MessageType.None);
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {perceptionCamera.period} seconds of simulation time.",MessageType.None);
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.renderingDeltaTime)),newGUIContent(frametimeTitle,"The rendering delta time (seconds of simulation time). E.g. 0.0166 translates to roughly 60 frames per second. Note that if the hardware is not capable of rendering, capturing, and saving the required number of frames per second, the simulation will slow down in real time in order to produce the exact number of required frames per each second of simulation time. Thus, the results will always be correct with regard to simulation time but may look slow in real time."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startFrame)),newGUIContent("Start at Frame",$"Frame number at which this camera starts capturing."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.framesBetweenCaptures)),newGUIContent("Frames Between Captures","The number of frames to render between the camera's scheduled captures. Setting this to 0 makes the camera capture every rendered frame."));
//Because start time only needs to be calculated once, we can do it here. But for scheduling consecutive captures,
//we calculate the time of the next capture every time based on the values given for captureEveryXFrames and renderingDeltaTime, in order to preserve accuracy.
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.manualSensorAffectSimulationTiming)),newGUIContent("Affect Simulation Timing",$"Have this camera affect simulation timings (similar to a scheduled camera) by requesting a specific frame delta time."));
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {interval} seconds of simulation time.",MessageType.None);
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.simulationDeltaTime)),newGUIContent(k_FrametimeTitle,$"Sets Unity's Time.{nameof(Time.captureDeltaTime)} to the specified number, causing a fixed number of frames to be generated for each second of elapsed simulation time regardless of the capabilities of the underlying hardware. Thus, simulation time and real time will not be synchronized."));
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}.",MessageType.None);
else
{
perceptionCamera.onlyRenderCapturedFrames=false;
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}. Framerate or simulation timings will not be modified by this camera.",MessageType.None);
/// <param name="egoHandle">The ego container for the sensor. Sensor orientation will be reported in the context of the given ego.</param>
/// <param name="modality">The kind of the sensor (ex. "camera", "lidar")</param>
/// <param name="description">A human-readable description of the sensor (ex. "front-left rgb camera")</param>
/// <param name="period">The period, in seconds, on which the sensor should capture. Frames will be scheduled in the simulation such that each sensor is triggered every _period_ seconds.</param>
/// <param name="firstCaptureTime">The time, in seconds, from the start of the sequence on which this sensor should first be scheduled.</param>
/// <param name="firstCaptureFrame">The time, in seconds, from the start of the sequence on which this sensor should first be scheduled.</param>
// throw new InvalidOperationException("Annotation reported on SensorHandle in frame when its ShouldCaptureThisFrame is false.");
if(!ShouldCaptureThisFrame)
thrownewInvalidOperationException("Annotation reported on SensorHandle in frame when its ShouldCaptureThisFrame is false.");
if(!annotationDefinition.IsValid)
thrownewArgumentException("The given annotationDefinition is invalid",nameof(annotationDefinition));
/// <exception cref="InvalidOperationException">Thrown if ReportCapture is being called when ShouldCaptureThisFrame is false or it has already been called this frame.</exception>
/// The interval in seconds at which the camera should render and capture.
/// </summary>
publicfloatperiod=.0166f;
/// <summary>
/// The start time in seconds of the first frame in the simulation.
/// </summary>
publicfloatstartTime;
/// <summary>
/// Whether camera output should be captured to disk
/// </summary>
/// <summary>
/// Frame number at which this camera starts capturing.
/// </summary>
publicintstartFrame;
publicintfirstCaptureFrame=0;
/// <summary>
/// The method of triggering captures for this camera. In <see cref="PerceptionCamera.CaptureTriggerMode.Scheduled"/> mode, captures happen automatically based on a start time/frame and time/frame interval. In <see cref="PerceptionCamera.CaptureTriggerMode.Scheduled"/> mode, captures should be triggered manually through calling the <see cref="PerceptionCamera.CaptureOnNextUpdate"/> method of <see cref="PerceptionCamera"/>."
/// When enabled, the camera will only render those frames that it needs to capture. In addition, the global frame delta time (<see cref="Time.captureDeltaTime"/>) will be altered to match this camera's capture period, thus, the scene will not be visually updated in-between captures (physics simulation is unaffected). If there is more than one <see cref="PerceptionCamera"/> active, this flag should be either disabled or enabled for all of them, otherwise the cameras will not capture and synchronize properly.
/// Have this unscheduled (manual capture) camera affect simulation timings (similar to a scheduled camera) by requesting a specific frame delta time
/// The rendering frame time (seconds). E.g. 0.0166 translates to 60 frames per second.
/// The simulation frame time (seconds) for this camera. E.g. 0.0166 translates to 60 frames per second. This will be used as Unity's <see cref="Time.captureDeltaTime"/>, causing a fixed number of frames to be generated for each second of elapsed simulation time regardless of the capabilities of the underlying hardware.
publicfloatrenderingDeltaTime=0.0166f;
publicfloatsimulationDeltaTime=0.0166f;
/// "The number of frames to render between the camera's scheduled captures when the rendering delta time is not controlled by this camera (i.e. <see cref="onlyRenderCapturedFrames"/> is false). Setting this to 0 makes the camera capture every rendered frame.
/// "The number of frames to simulate and render between the camera's scheduled captures. Setting this to 0 makes the camera capture frame.
//In this case, the simulation timing is controlled by this and other sensors that have this flag enabled, so we can precisely jump to the next frame using a specific delta (capture period) provided by the user
//if the sensor is not scheduled, it does not need to force the simulation to produce frames at a specific rate, so we will not need to touch Time.captureDeltaTime.