diff --git a/third_party/semi_physical_train/semi_physical_train.go b/third_party/semi_physical_train/semi_physical_train.go index 144ceba..a3a3d04 100644 --- a/third_party/semi_physical_train/semi_physical_train.go +++ b/third_party/semi_physical_train/semi_physical_train.go @@ -94,9 +94,12 @@ func (s *semiPhysicalTrainImpl) Stop() { } func (s *semiPhysicalTrainImpl) SendTrainControlMessage(info *message.DynamicsTrainInfo) { - sendMsg := &message.TrainSpeedMsg{} - sendMsg.DynamicsDecode(info) - s.trainSpeedInfoUdpClient.Send(sendMsg.Encode()) + if s.trainSpeedInfoUdpClient != nil { + sendMsg := &message.TrainSpeedMsg{} + sendMsg.DynamicsDecode(info) + s.trainSpeedInfoUdpClient.Send(sendMsg.Encode()) + } + } func (s *semiPhysicalTrainImpl) initSemiPhysical() {