MissouriMRDT / Autonomy_Software

Found redundant cloned branches CXX-W2041
Anti-pattern
Minor
34 occurrences in this check
body of if is identical to the body of else
175        // Check which frame we should copy.
176        switch (stContainer.eFrameType)
177        {
178            case PIXEL_FORMATS::eDepthDetection: *(stContainer.pFrame) = m_cvProcFrame; break;179            case PIXEL_FORMATS::eTensorflowDetection: *(stContainer.pFrame) = m_cvProcFrame; break;
180            default: *(stContainer.pFrame) = m_cvProcFrame;
181        }
body of if is identical to the body of else
157        // Determine which frame should be copied.
158        switch (stContainer.eFrameType)
159        {
160            case PIXEL_FORMATS::eBGRA: *(stContainer.pFrame) = m_cvFrame; break;161            case PIXEL_FORMATS::eDepthMeasure: *(stContainer.pFrame) = m_cvDepthMeasure; break;
162            case PIXEL_FORMATS::eDepthImage: *(stContainer.pFrame) = m_cvDepthImage; break;
163            case PIXEL_FORMATS::eXYZ: *(stContainer.pFrame) = m_cvPointCloud; break;
body of if is identical to the body of else
2186                                      }
2187
2188                                      // Check if the spatial map was exported successfully.
2189                                      if (m_slCamera.getSpatialMapRequestStatusAsync() == sl::ERROR_CODE::SUCCESS)2190                                      {
2191                                          // Get and store the spatial map.
2192                                          m_slCamera.retrieveSpatialMapAsync(slSpatialMap);
body of if is identical to the body of else
1480                {
1481                    // Covariance error.
1482                    if (slReturnCode == sl::FUSION_ERROR_CODE::GNSS_DATA_COVARIANCE_MUST_VARY || slReturnCode == sl::FUSION_ERROR_CODE::INVALID_COVARIANCE)
1483                    {1484                        // Submit logger message.
1485                        LOG_WARNING(logging::g_qSharedLogger,
1486                                    "Unable to ingest fusion GNSS data for camera {} ({})! sl::Fusion positional tracking may be inaccurate! sl::FUSION_ERROR_CODE "
body of if is identical to the body of else
1420                // Get the GNSS fix type status from the given GPS coordinate.
1421                switch (stNewGPSLocation.eCoordinateAccuracyFixType)
1422                {
1423                    case geoops::PositionFixType::eNoFix:1424                    {
1425                        slGNSSData.gnss_status = sl::GNSS_STATUS::SINGLE;
1426                        slGNSSData.gnss_mode   = sl::GNSS_MODE::NO_FIX;
body of if is identical to the body of else
1315    }
1316
1317    // Check if this camera was successfully subscribed to the Fusion instance.
1318    if (slReturnCode == sl::FUSION_ERROR_CODE::SUCCESS)1319    {
1320        // Submit logger message.
1321        LOG_DEBUG(logging::g_qSharedLogger,
body of if is identical to the body of else
 746            // Determine which frame should be copied.
 747            switch (stContainer.eFrameType)
 748            {
 749                case PIXEL_FORMATS::eBGRA: *(stContainer.pFrame) = imgops::ConvertSLMatToGPUMat(m_slFrame); break; 750                case PIXEL_FORMATS::eDepthMeasure: *(stContainer.pFrame) = imgops::ConvertSLMatToGPUMat(m_slDepthMeasure); break;
 751                case PIXEL_FORMATS::eDepthImage: *(stContainer.pFrame) = imgops::ConvertSLMatToGPUMat(m_slDepthImage); break;
 752                case PIXEL_FORMATS::eXYZBGRA: *(stContainer.pFrame) = imgops::ConvertSLMatToGPUMat(m_slPointCloud); break;
body of if is identical to the body of else
 707            // Determine which frame should be copied.
 708            switch (stContainer.eFrameType)
 709            {
 710                case PIXEL_FORMATS::eBGRA: *(stContainer.pFrame) = imgops::ConvertSLMatToCVMat(m_slFrame); break; 711                case PIXEL_FORMATS::eDepthMeasure: *(stContainer.pFrame) = imgops::ConvertSLMatToCVMat(m_slDepthMeasure); break;
 712                case PIXEL_FORMATS::eDepthImage: *(stContainer.pFrame) = imgops::ConvertSLMatToCVMat(m_slDepthImage); break;
 713                case PIXEL_FORMATS::eXYZBGRA: *(stContainer.pFrame) = imgops::ConvertSLMatToCVMat(m_slPointCloud); break;
body of if is identical to the body of else
 499                    sl::POSITIONAL_TRACKING_STATE slPoseTrackReturnCode;
 500
 501                    // Check if this camera has Fusion instance enabled.
 502                    if (m_bCameraIsFusionMaster) 503                    {
 504                        // Get tracking pose from Fusion.
 505                        slPoseTrackReturnCode = m_slFusionInstance.getPosition(m_slCameraPose, sl::REFERENCE_FRAME::WORLD);
body of if is identical to the body of else
 207            slReturnCode = m_slFusionInstance.subscribe(sl::CameraIdentifier(m_unCameraSerialNumber));
 208
 209            // Check if this camera was successfully subscribed to the Fusion instance.
 210            if (slReturnCode == sl::FUSION_ERROR_CODE::SUCCESS) 211            {
 212                // Submit logger message.
 213                LOG_DEBUG(logging::g_qSharedLogger, "Initialized FUSION instance for ZED camera {} ({})!", sl::toString(m_slCameraModel).get(), m_unCameraSerialNumber);
body of if is identical to the body of else
 112    m_slSpatialMappingParams.use_chunk_only    = constants::ZED_MAPPING_USE_CHUNK_ONLY;
 113    m_slSpatialMappingParams.stability_counter = constants::ZED_MAPPING_STABILITY_COUNTER;
 114    // Set or auto-set max depth range for mapping.
 115    if (constants::ZED_MAPPING_RANGE_METER <= 0) 116    {
 117        // Automatically guess the best mapping depth range.
 118        m_slSpatialMappingParams.range_meter = m_slSpatialMappingParams.getRecommendedRange(constants::ZED_MAPPING_RESOLUTION_METER, m_slCamera);
body of if is identical to the body of else
184            if (nTimeSinceEpoch % 5 == 0 && !bReopenAlreadyChecked)
185            {
186                // Check if camera was opened with an index or path.
187                if (m_nCameraIndex == -1)188                {
189                    // Attempt to reopen camera.
190                    bCameraReopened = m_cvCamera.open(m_szCameraPath);
body of if is identical to the body of else
787cv::Size TagDetector::GetProcessFrameResolution() const
788{
789    // Check if using a ZED camera.
790    if (m_bUsingZedCamera)791    {
792        // Concatenate camera model name and serial number.
793        return dynamic_cast<ZEDCam*>(m_pCamera)->GetPropResolution();
body of if is identical to the body of else
711    if (this->GetThreadState() == AutonomyThreadState::eRunning)
712    {
713        // Check if using ZEDCam or BasicCam.
714        if (m_bUsingZedCamera)715        {
716            // Check if camera is NOT open.
717            if (dynamic_cast<ZEDCam*>(m_pCamera)->GetCameraIsOpen())
body of if is identical to the body of else
158void TagDetector::ThreadedContinuousCode()
159{
160    // Check if using ZEDCam or BasicCam.
161    if (m_bUsingZedCamera)162    {
163        // Check if camera is NOT open.
164        if (!dynamic_cast<ZEDCam*>(m_pCamera)->GetCameraIsOpen())
body of if is identical to the body of else
182    {
183        // Initialize output color mat if necessary.
184        if (cvOutputColors.empty())
185        {186            // Fill mat with zeros, same size as input point cloud, but with 4 char values in third dimension.
187            cvOutputColors = cv::Mat(cvInputPointCloud.rows, cvInputPointCloud.cols, CV_8UC4, cv::Scalar(0));
188        }
body of if is identical to the body of else
182        double dTargetDistance;
183
184        if (bDetectedTagAR)
185        {186            dTargetHeading  = numops::InputAngleModulus<double>(dCurrHeading + m_stTargetTagAR.dYawAngle, 0, 360);
187            dTargetDistance = m_stTargetTagAR.dStraightLineDistance;
188        }
body of if is identical to the body of else
168            // Determine which device is going to be used for this model.
169            switch (eDeviceType)
170            {
171                case eAuto: m_tpuDevice.type = edgetpu::DeviceType(-1); break;172                case ePCIe: m_tpuDevice.type = edgetpu::DeviceType::kApexPci; break;
173                case eUSB: m_tpuDevice.type = edgetpu::DeviceType::kApexUsb; break;
174                default: m_tpuDevice.type = edgetpu::DeviceType(-1); break;
body of if is identical to the body of else
 97            }
 98
 99            // Determine if firmware should be loaded ever time code is started.
100            if (bUSBAlwaysDFU)101            {
102                // Always load firmware.
103                m_tpuDeviceOptions["Usb.AlwaysDfu"] = "True";
body of if is identical to the body of else
 89            // Determine which power mode should be set.
 90            switch (ePowerMode)
 91            {
 92                case eLow: m_tpuDeviceOptions["Performance"] = "Low"; break; 93                case eMedium: m_tpuDeviceOptions["Performance"] = "Medium"; break;
 94                case eHigh: m_tpuDeviceOptions["Performance"] = "High"; break;
 95                case eMax: m_tpuDeviceOptions["Performance"] = "Max"; break;
body of if is identical to the body of else
337        {
338            // Check if the pools need to be resized.
339            if (m_thPool.get_thread_count() != nNumThreads)
340            {341                // Pause queuing of new tasks to the threads, then purge them.
342                m_thPool.pause();
343                m_thPool.purge();
body of if is identical to the body of else
265        {
266            // Check if the pools need to be resized.
267            if (m_thPool.get_thread_count() != nNumThreads)
268            {269                // Pause queuing of new tasks to the threads, then purge them.
270                m_thPool.pause();
271                m_thPool.purge();
body of if is identical to the body of else
600    // Acquire a read lock on the path unordered map.
601    std::shared_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
602    // Check if the map contains the given key.
603    if (m_umStoredPaths.count(szPathName) > 0)604    {
605        // Return the path vector at the given key.
606        return m_umStoredPaths[szPathName];
body of if is identical to the body of else
130
131        // Check if the state exists in exitedStates
132        std::unordered_map<statemachine::States, std::shared_ptr<statemachine::State>>::iterator itState = m_umSavedStates.find(eNextState);
133        if (itState != m_umSavedStates.end())134        {
135            // Load the existing state
136            m_pCurrentState = itState->second;
body of if is identical to the body of else
513            {
514                // Check if this is a grayscale or color image.
515                if (m_vFrames[nIter].channels() == 1)
516                {517                    // Convert frame from 1 channel grayscale to 3 channel BGR.
518                    cv::cvtColor(m_vFrames[nIter], m_vFrames[nIter], cv::COLOR_GRAY2BGR);
519                }