Skip to content

Commit 6c0f60a

Browse files
committed
Fixed crash when both displaying and publishing robot camera.
1 parent 72f70ac commit 6c0f60a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Assets/Scripts/IGVCConfigLoader.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ void Awake()
3636
{
3737
imagePublisher.Topic = RobotOptions.GetValue(robotName + "Camera Topic");
3838
}
39-
if (RobotOptions.GetValue(robotName + "Publish Camera").Equals("True")) {
40-
imagePublisher.enabled = true;
41-
robotCamera.enabled = true;
42-
}
4339
if (RobotOptions.Exists(robotName + "Show Camera View") && RobotOptions.GetValue(robotName + "Show Camera View").Equals("True")) {
40+
robotCamera.targetDisplay = 0;
41+
robotCamera.enabled = true;
4442
mainCamera.enabled = false;
43+
44+
// If we are publishing the camera, we need to duplicate it because the publishing script
45+
// will override the camera output.
46+
if(RobotOptions.GetValue(robotName + "Publish Camera").Equals("True")) {
47+
GameObject robotCameraDupe = Instantiate(robotCamera.gameObject, robotCamera.gameObject.transform.parent);
48+
}
49+
}
50+
if (RobotOptions.GetValue(robotName + "Publish Camera").Equals("True")) {
51+
imagePublisher.enabled = true;
4552
robotCamera.enabled = true;
46-
robotCamera.targetDisplay = 0;
4753
}
4854
laserScanPublisher.Topic = RobotOptions.GetValue(robotName + "Laser Scan Topic");
4955
iMUPublisher.Topic = RobotOptions.GetValue(robotName + "IMU Topic");

0 commit comments

Comments
 (0)