Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • danc/MicroCART
  • snawerdt/MicroCART_17-18
  • bbartels/MicroCART_17-18
  • jonahu/MicroCART
4 results
Show changes
Showing
with 48067 additions and 72 deletions
File added
File added
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Model {
Name "IMU_prototype"
Version 8.8
SavedCharacterEncoding "windows-1252"
GraphicalInterface {
NumRootInports 0
NumRootOutports 0
ParameterArgumentNames ""
ComputedModelVersion "1.9"
NumModelReferences 0
NumTestPointedSignals 0
NumProvidedFunctions 0
NumRequiredFunctions 0
NumResetEvents 0
HasInitializeEvent 0
HasTerminateEvent 0
IsExportFunctionModel 0
}
LogicAnalyzerGraphicalSettings ""
LogicAnalyzerPlugin "on"
LogicAnalyzerSignalOrdering ""
DiagnosticSuppressor "on"
SuppressorTable "22 serialization::archive 11 0 3 0 0 0 8 0"
ScopeRefreshTime 0.035000
OverrideScopeRefreshTime on
DisableAllScopes on
DataTypeOverride "UseLocalSettings"
DataTypeOverrideAppliesTo "AllNumericTypes"
MinMaxOverflowLogging "UseLocalSettings"
MinMaxOverflowArchiveMode "Overwrite"
FPTRunName "Run 1"
MaxMDLFileLineLength 120
LastSavedArchitecture "win64"
Object {
$PropName "BdWindowsInfo"
$ObjectID 1
$ClassName "Simulink.BDWindowsInfo"
Object {
$PropName "WindowsInfo"
$ObjectID 2
$ClassName "Simulink.WindowInfo"
IsActive [1]
Location [-8.0, -8.0, 1936.0, 1056.0]
Object {
$PropName "ModelBrowserInfo"
$ObjectID 3
$ClassName "Simulink.ModelBrowserInfo"
Visible [0]
DockPosition "Left"
Width [50]
Height [50]
Filter [9]
}
Object {
$PropName "ExplorerBarInfo"
$ObjectID 4
$ClassName "Simulink.ExplorerBarInfo"
Visible [1]
}
Object {
$PropName "EditorsInfo"
$ObjectID 5
$ClassName "Simulink.EditorInfo"
IsActive [1]
ViewObjType "SimulinkSubsys"
LoadSaveID "20"
Extents [1755.0, 876.0]
ZoomFactor [1.5]
Offset [-45.247619047619196, -6.2261904761904816]
}
Object {
$PropName "DockComponentsInfo"
$ObjectID 6
$ClassName "Simulink.DockComponentInfo"
Type "GLUE2:PropertyInspector"
ID "Property Inspector"
Visible [0]
CreateCallback ""
UserData ""
Floating [0]
DockPosition "Right"
Width [640]
Height [480]
}
WindowState "AAAA/wAAAAD9AAAAAgAAAAAAAAC9AAAB+PwCAAAAA/sAAAAWAEQAbwBjAGsAVwBpAGQAZwBlAHQAMwEAAAAxAAAB+AAAA"
"AAAAAAA+wAAABYARABvAGMAawBXAGkAZABnAGUAdAA0AAAAAAD/////AAAAAAAAAAD7AAAAUgBHAEwAVQBFADIAIAB0AHIAZQBlACAAYwBvAG0Ac"
"ABvAG4AZQBuAHQALwBHAEwAVQBFADIAIAB0AHIAZQBlACAAYwBvAG0AcABvAG4AZQBuAHQAAAAAAP////8AAABfAP///wAAAAEAAAAAAAAAAPwCA"
"AAAAfsAAABUAEcATABVAEUAMgA6AFAAcgBvAHAAZQByAHQAeQBJAG4AcwBwAGUAYwB0AG8AcgAvAFAAcgBvAHAAZQByAHQAeQAgAEkAbgBzAHAAZ"
"QBjAHQAbwByAAAAAAD/////AAAAJwD///8AAAeAAAADogAAAAEAAAACAAAAAQAAAAL8AAAAAQAAAAIAAAAP/////wAAAAAA/////wAAAAAAAAAA/"
"////wEAAAAA/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/"
"////wEAAAB5/////wAAAAAAAAAA/////wEAAADa/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/////wEAAAFT/////wAAAAAAAAAA/"
"////wAAAAAA/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA/////wEAAAMr/////wAAAAAAAAAA/"
"////wEAAANa/////wAAAAAAAAAA/////wAAAAAA/////wAAAAAAAAAA"
}
}
Created "Wed Nov 16 14:00:52 2016"
Creator "m87rich"
UpdateHistory "UpdateHistoryNever"
ModifiedByFormat "%<Auto>"
LastModifiedBy "Andy"
ModifiedDateFormat "%<Auto>"
LastModifiedDate "Fri Nov 18 17:01:30 2016"
RTWModifiedTimeStamp 401389289
ModelVersionFormat "1.%<AutoIncrement:9>"
ConfigurationManager "none"
SampleTimeColors off
SampleTimeAnnotations off
LibraryLinkDisplay "disabled"
WideLines off
ShowLineDimensions off
ShowPortDataTypes off
ShowEditTimeErrors on
ShowEditTimeWarnings on
ShowEditTimeAdvisorChecks off
ShowPortUnits off
ShowDesignRanges off
ShowLoopsOnError on
IgnoreBidirectionalLines off
ShowStorageClass off
ShowTestPointIcons on
ShowSignalResolutionIcons on
ShowViewerIcons on
SortedOrder off
VariantCondition off
ExecutionContextIcon off
ShowLinearizationAnnotations on
ShowVisualizeInsertedRTB on
ShowMarkup on
BlockNameDataTip off
BlockParametersDataTip off
BlockDescriptionStringDataTip off
ToolBar on
StatusBar on
BrowserShowLibraryLinks off
FunctionConnectors off
BrowserLookUnderMasks off
SimulationMode "normal"
PauseTimes "5"
NumberOfSteps 1
SnapshotBufferSize 10
SnapshotInterval 10
NumberOfLastSnapshots 0
LinearizationMsg "none"
Profile off
ParamWorkspaceSource "MATLABWorkspace"
AccelSystemTargetFile "accel.tlc"
AccelTemplateMakefile "accel_default_tmf"
AccelMakeCommand "make_rtw"
TryForcingSFcnDF off
Object {
$PropName "DataLoggingOverride"
$ObjectID 7
$ClassName "Simulink.SimulationData.ModelLoggingInfo"
model_ "IMU_prototype"
overrideMode_ [0.0]
Array {
Type "Cell"
Dimension 1
Cell "IMU_prototype"
PropName "logAsSpecifiedByModels_"
}
Array {
Type "Cell"
Dimension 1
Cell []
PropName "logAsSpecifiedByModelsSSIDs_"
}
}
ExtModeBatchMode off
ExtModeEnableFloating on
ExtModeTrigType "manual"
ExtModeTrigMode "normal"
ExtModeTrigPort "1"
ExtModeTrigElement "any"
ExtModeTrigDuration 1000
ExtModeTrigDurationFloating "auto"
ExtModeTrigHoldOff 0
ExtModeTrigDelay 0
ExtModeTrigDirection "rising"
ExtModeTrigLevel 0
ExtModeArchiveMode "off"
ExtModeAutoIncOneShot off
ExtModeIncDirWhenArm off
ExtModeAddSuffixToVar off
ExtModeWriteAllDataToWs off
ExtModeArmWhenConnect on
ExtModeSkipDownloadWhenConnect off
ExtModeLogAll on
ExtModeAutoUpdateStatusClock on
ShowModelReferenceBlockVersion off
ShowModelReferenceBlockIO off
Array {
Type "Handle"
Dimension 1
Simulink.ConfigSet {
$ObjectID 8
Version "1.16.5"
DisabledProps []
Description ""
Array {
Type "Handle"
Dimension 9
Simulink.SolverCC {
$ObjectID 9
Version "1.16.5"
DisabledProps []
Description ""
StartTime "0.0"
StopTime "1"
AbsTol "auto"
FixedStep "auto"
InitialStep "auto"
MaxNumMinSteps "-1"
MaxOrder 5
ZcThreshold "auto"
ConsecutiveZCsStepRelTol "10*128*eps"
MaxConsecutiveZCs "1000"
ExtrapolationOrder 4
NumberNewtonIterations 1
MaxStep "auto"
MinStep "auto"
MaxConsecutiveMinStep "1"
RelTol "1e-3"
EnableMultiTasking on
EnableConcurrentExecution off
ConcurrentTasks off
Solver "ode45"
SolverName "ode45"
SolverJacobianMethodControl "auto"
ShapePreserveControl "DisableAll"
ZeroCrossControl "UseLocalSettings"
ZeroCrossAlgorithm "Nonadaptive"
AlgebraicLoopSolver "TrustRegion"
SolverInfoToggleStatus off
IsAutoAppliedInSIP off
SolverResetMethod "Fast"
PositivePriorityOrder off
AutoInsertRateTranBlk off
SampleTimeConstraint "Unconstrained"
InsertRTBMode "Whenever possible"
SampleTimeProperty []
}
Simulink.DataIOCC {
$ObjectID 10
Version "1.16.5"
DisabledProps []
Description ""
Decimation "1"
ExternalInput "[t, u]"
FinalStateName "xFinal"
InitialState "xInitial"
LimitDataPoints on
MaxDataPoints "1000"
LoadExternalInput off
LoadInitialState off
SaveFinalState off
SaveCompleteFinalSimState off
SaveFormat "Array"
SignalLoggingSaveFormat "Dataset"
SaveOutput on
SaveState off
SignalLogging on
DSMLogging on
InspectSignalLogs off
VisualizeSimOutput on
StreamToWorkspace off
StreamVariableName "streamout"
SaveTime on
ReturnWorkspaceOutputs off
StateSaveName "xout"
TimeSaveName "tout"
OutputSaveName "yout"
SignalLoggingName "logsout"
DSMLoggingName "dsmout"
OutputOption "RefineOutputTimes"
OutputTimes "[]"
ReturnWorkspaceOutputsName "out"
Refine "1"
LoggingToFile off
LoggingFileName "out.mat"
LoggingIntervals "[-inf, inf]"
}
Simulink.OptimizationCC {
$ObjectID 11
Version "1.16.5"
Array {
Type "Cell"
Dimension 8
Cell "BooleansAsBitfields"
Cell "PassReuseOutputArgsAs"
Cell "PassReuseOutputArgsThreshold"
Cell "ZeroExternalMemoryAtStartup"
Cell "ZeroInternalMemoryAtStartup"
Cell "OptimizeModelRefInitCode"
Cell "NoFixptDivByZeroProtection"
Cell "UseSpecifiedMinMax"
PropName "DisabledProps"
}
Description ""
BlockReduction on
BooleanDataType on
ConditionallyExecuteInputs on
DefaultParameterBehavior "Tunable"
UseDivisionForNetSlopeComputation "off"
UseFloatMulNetSlope off
DefaultUnderspecifiedDataType "double"
UseSpecifiedMinMax off
InlineInvariantSignals off
OptimizeBlockIOStorage on
BufferReuse on
EnhancedBackFolding off
CachingGlobalReferences off
GlobalBufferReuse on
StrengthReduction off
AdvancedOptControl ""
ExpressionFolding on
BooleansAsBitfields off
BitfieldContainerType "uint_T"
EnableMemcpy on
MemcpyThreshold 64
PassReuseOutputArgsAs "Structure reference"
PassReuseOutputArgsThreshold 12
ExpressionDepthLimit 128
LocalBlockOutputs on
RollThreshold 5
StateBitsets off
DataBitsets off
ActiveStateOutputEnumStorageType "Native Integer"
ZeroExternalMemoryAtStartup on
ZeroInternalMemoryAtStartup on
InitFltsAndDblsToZero off
NoFixptDivByZeroProtection off
EfficientFloat2IntCast off
EfficientMapNaN2IntZero on
LifeSpan "inf"
MaxStackSize "Inherit from target"
BufferReusableBoundary on
SimCompilerOptimization "off"
AccelVerboseBuild off
}
Simulink.DebuggingCC {
$ObjectID 12
Version "1.16.5"
Array {
Type "Cell"
Dimension 1
Cell "UseOnlyExistingSharedCode"
PropName "DisabledProps"
}
Description ""
RTPrefix "error"
ConsistencyChecking "none"
ArrayBoundsChecking "none"
SignalInfNanChecking "none"
SignalRangeChecking "none"
ReadBeforeWriteMsg "UseLocalSettings"
WriteAfterWriteMsg "UseLocalSettings"
WriteAfterReadMsg "UseLocalSettings"
AlgebraicLoopMsg "warning"
ArtificialAlgebraicLoopMsg "warning"
SaveWithDisabledLinksMsg "warning"
SaveWithParameterizedLinksMsg "warning"
CheckSSInitialOutputMsg on
UnderspecifiedInitializationDetection "Simplified"
MergeDetectMultiDrivingBlocksExec "error"
CheckExecutionContextPreStartOutputMsg off
CheckExecutionContextRuntimeOutputMsg off
SignalResolutionControl "UseLocalSettings"
BlockPriorityViolationMsg "warning"
MinStepSizeMsg "warning"
TimeAdjustmentMsg "none"
MaxConsecutiveZCsMsg "error"
MaskedZcDiagnostic "warning"
IgnoredZcDiagnostic "warning"
SolverPrmCheckMsg "none"
InheritedTsInSrcMsg "warning"
MultiTaskDSMMsg "error"
MultiTaskCondExecSysMsg "error"
MultiTaskRateTransMsg "error"
SingleTaskRateTransMsg "none"
TasksWithSamePriorityMsg "warning"
SigSpecEnsureSampleTimeMsg "warning"
CheckMatrixSingularityMsg "none"
IntegerOverflowMsg "warning"
Int32ToFloatConvMsg "warning"
ParameterDowncastMsg "error"
ParameterOverflowMsg "error"
ParameterUnderflowMsg "none"
ParameterPrecisionLossMsg "warning"
ParameterTunabilityLossMsg "warning"
FixptConstUnderflowMsg "none"
FixptConstOverflowMsg "none"
FixptConstPrecisionLossMsg "none"
UnderSpecifiedDataTypeMsg "none"
UnnecessaryDatatypeConvMsg "none"
VectorMatrixConversionMsg "none"
InvalidFcnCallConnMsg "error"
FcnCallInpInsideContextMsg "error"
SignalLabelMismatchMsg "none"
UnconnectedInputMsg "warning"
UnconnectedOutputMsg "warning"
UnconnectedLineMsg "warning"
UseOnlyExistingSharedCode "error"
SFcnCompatibilityMsg "none"
FrameProcessingCompatibilityMsg "error"
UniqueDataStoreMsg "none"
BusObjectLabelMismatch "warning"
RootOutportRequireBusObject "warning"
AssertControl "UseLocalSettings"
AllowSymbolicDim on
RowMajorDimensionSupport off
ModelReferenceIOMsg "none"
ModelReferenceMultiInstanceNormalModeStructChecksumCheck "error"
ModelReferenceVersionMismatchMessage "none"
ModelReferenceIOMismatchMessage "none"
UnknownTsInhSupMsg "warning"
ModelReferenceDataLoggingMessage "warning"
ModelReferenceSymbolNameMessage "warning"
ModelReferenceExtraNoncontSigs "error"
StateNameClashWarn "none"
SimStateInterfaceChecksumMismatchMsg "warning"
SimStateOlderReleaseMsg "error"
InitInArrayFormatMsg "warning"
StrictBusMsg "ErrorLevel1"
BusNameAdapt "WarnAndRepair"
NonBusSignalsTreatedAsBus "none"
SymbolicDimMinMaxWarning "warning"
LossOfSymbolicDimsSimulationWarning "warning"
LossOfSymbolicDimsCodeGenerationWarning "error"
BlockIODiagnostic "none"
SFUnusedDataAndEventsDiag "warning"
SFUnexpectedBacktrackingDiag "warning"
SFInvalidInputDataAccessInChartInitDiag "warning"
SFNoUnconditionalDefaultTransitionDiag "warning"
SFTransitionOutsideNaturalParentDiag "warning"
SFUnreachableExecutionPathDiag "warning"
SFUndirectedBroadcastEventsDiag "warning"
SFTransitionActionBeforeConditionDiag "warning"
SFOutputUsedAsStateInMooreChartDiag "error"
SFTemporalDelaySmallerThanSampleTimeDiag "warning"
SFSelfTransitionDiag "warning"
SFExecutionAtInitializationDiag "none"
SFMachineParentedDataDiag "warning"
IntegerSaturationMsg "warning"
AllowedUnitSystems "all"
UnitsInconsistencyMsg "warning"
AllowAutomaticUnitConversions on
}
Simulink.HardwareCC {
$ObjectID 13
Version "1.16.5"
DisabledProps []
Description ""
ProdBitPerChar 8
ProdBitPerShort 16
ProdBitPerInt 32
ProdBitPerLong 32
ProdBitPerLongLong 64
ProdBitPerFloat 32
ProdBitPerDouble 64
ProdBitPerPointer 32
ProdBitPerSizeT 32
ProdBitPerPtrDiffT 32
ProdLargestAtomicInteger "Char"
ProdLargestAtomicFloat "None"
ProdIntDivRoundTo "Undefined"
ProdEndianess "Unspecified"
ProdWordSize 32
ProdShiftRightIntArith on
ProdLongLongMode off
ProdHWDeviceType "32-bit Generic"
TargetBitPerChar 8
TargetBitPerShort 16
TargetBitPerInt 32
TargetBitPerLong 32
TargetBitPerLongLong 64
TargetBitPerFloat 32
TargetBitPerDouble 64
TargetBitPerPointer 32
TargetBitPerSizeT 32
TargetBitPerPtrDiffT 32
TargetLargestAtomicInteger "Char"
TargetLargestAtomicFloat "None"
TargetShiftRightIntArith on
TargetLongLongMode off
TargetIntDivRoundTo "Undefined"
TargetEndianess "Unspecified"
TargetWordSize 32
TargetPreprocMaxBitsSint 32
TargetPreprocMaxBitsUint 32
TargetHWDeviceType "Specified"
TargetUnknown off
ProdEqTarget on
UseEmbeddedCoderFeatures on
UseSimulinkCoderFeatures on
}
Simulink.ModelReferenceCC {
$ObjectID 14
Version "1.16.5"
DisabledProps []
Description ""
UpdateModelReferenceTargets "IfOutOfDateOrStructuralChange"
EnableRefExpFcnMdlSchedulingChecks on
CheckModelReferenceTargetMessage "error"
EnableParallelModelReferenceBuilds off
ParallelModelReferenceErrorOnInvalidPool on
ParallelModelReferenceMATLABWorkerInit "None"
ModelReferenceNumInstancesAllowed "Multi"
PropagateVarSize "Infer from blocks in model"
ModelDependencies ""
ModelReferencePassRootInputsByReference on
ModelReferenceMinAlgLoopOccurrences off
PropagateSignalLabelsOutOfModel off
SupportModelReferenceSimTargetCustomCode off
}
Simulink.SFSimCC {
$ObjectID 15
Version "1.16.5"
DisabledProps []
Description ""
SimCustomSourceCode ""
SimCustomHeaderCode ""
SimCustomInitializer ""
SimCustomTerminator ""
SimReservedNameArray []
SimUserSources ""
SimUserIncludeDirs ""
SimUserLibraries ""
SimUserDefines ""
SimCustomCompilerFlags ""
SimCustomLinkerFlags ""
SFSimEcho on
SimCtrlC on
SimIntegrity on
SimUseLocalCustomCode off
SimParseCustomCode on
SimBuildMode "sf_incremental_build"
SimGenImportedTypeDefs off
ModelFunctionsGlobalVisibility "on"
CompileTimeRecursionLimit 50
EnableRuntimeRecursion on
}
Simulink.RTWCC {
$BackupClass "Simulink.RTWCC"
$ObjectID 16
Version "1.16.5"
Array {
Type "Cell"
Dimension 16
Cell "IncludeHyperlinkInReport"
Cell "GenerateTraceInfo"
Cell "GenerateTraceReport"
Cell "GenerateTraceReportSl"
Cell "GenerateTraceReportSf"
Cell "GenerateTraceReportEml"
Cell "PortableWordSizes"
Cell "GenerateWebview"
Cell "GenerateCodeMetricsReport"
Cell "GenerateCodeReplacementReport"
Cell "GenerateMissedCodeReplacementReport"
Cell "GenerateErtSFunction"
Cell "CreateSILPILBlock"
Cell "CodeExecutionProfiling"
Cell "CodeProfilingSaveOptions"
Cell "CodeProfilingInstrumentation"
PropName "DisabledProps"
}
SystemTargetFile "grt.tlc"
HardwareBoard "None"
TLCOptions ""
GenCodeOnly off
MakeCommand "make_rtw"
GenerateMakefile on
PackageGeneratedCodeAndArtifacts off
PackageName ""
TemplateMakefile "grt_default_tmf"
PostCodeGenCommand ""
Description ""
GenerateReport off
SaveLog off
RTWVerbose on
RetainRTWFile off
RTWBuildHooks []
ProfileTLC off
TLCDebug off
TLCCoverage off
TLCAssert off
RTWUseLocalCustomCode off
RTWUseSimCustomCode off
CustomSourceCode ""
CustomHeaderCode ""
CustomInclude ""
CustomSource ""
CustomLibrary ""
CustomDefine ""
CustomLAPACKCallback ""
CustomInitializer ""
CustomTerminator ""
Toolchain "Automatically locate an installed toolchain"
BuildConfiguration "Faster Builds"
CustomToolchainOptions []
IncludeHyperlinkInReport off
LaunchReport off
PortableWordSizes off
CreateSILPILBlock "None"
CodeExecutionProfiling off
CodeExecutionProfileVariable "executionProfile"
CodeProfilingSaveOptions "SummaryOnly"
CodeProfilingInstrumentation off
SILDebugging off
TargetLang "C"
IncludeBusHierarchyInRTWFileBlockHierarchyMap off
GenerateTraceInfo off
GenerateTraceReport off
GenerateTraceReportSl off
GenerateTraceReportSf off
GenerateTraceReportEml off
GenerateWebview off
GenerateCodeMetricsReport off
GenerateCodeReplacementReport off
GenerateMissedCodeReplacementReport off
RTWCompilerOptimization "off"
ObjectivePriorities []
RTWCustomCompilerOptimizations ""
CheckMdlBeforeBuild "Off"
SharedConstantsCachingThreshold 1024
Array {
Type "Handle"
Dimension 2
Simulink.CodeAppCC {
$ObjectID 17
Version "1.16.5"
Array {
Type "Cell"
Dimension 26
Cell "IgnoreCustomStorageClasses"
Cell "ParameterTuningSideEffectCode"
Cell "IgnoreTestpoints"
Cell "InsertBlockDesc"
Cell "InsertPolySpaceComments"
Cell "SFDataObjDesc"
Cell "MATLABFcnDesc"
Cell "SimulinkDataObjDesc"
Cell "DefineNamingRule"
Cell "SignalNamingRule"
Cell "ParamNamingRule"
Cell "InternalIdentifier"
Cell "InlinedPrmAccess"
Cell "CustomSymbolStr"
Cell "CustomSymbolStrGlobalVar"
Cell "CustomSymbolStrType"
Cell "CustomSymbolStrField"
Cell "CustomSymbolStrFcn"
Cell "CustomSymbolStrFcnArg"
Cell "CustomSymbolStrBlkIO"
Cell "CustomSymbolStrTmpVar"
Cell "CustomSymbolStrMacro"
Cell "CustomSymbolStrUtil"
Cell "ReqsInCode"
Cell "CustomSymbolStrModelFcn"
Cell "CustomUserTokenString"
PropName "DisabledProps"
}
Description ""
Comment ""
ForceParamTrailComments off
GenerateComments on
CommentStyle "Auto"
IgnoreCustomStorageClasses on
IgnoreTestpoints off
IncHierarchyInIds off
MaxIdLength 31
PreserveName off
PreserveNameWithParent off
ShowEliminatedStatement off
OperatorAnnotations off
IncAutoGenComments off
SimulinkDataObjDesc off
SFDataObjDesc off
MATLABFcnDesc off
IncDataTypeInIds off
MangleLength 1
CustomSymbolStrGlobalVar "$R$N$M"
CustomSymbolStrType "$N$R$M_T"
CustomSymbolStrField "$N$M"
CustomSymbolStrFcn "$R$N$M$F"
CustomSymbolStrModelFcn "$R$N"
CustomSymbolStrFcnArg "rt$I$N$M"
CustomSymbolStrBlkIO "rtb_$N$M"
CustomSymbolStrTmpVar "$N$M"
CustomSymbolStrMacro "$R$N$M"
CustomSymbolStrUtil "$N$C"
CustomUserTokenString ""
CustomCommentsFcn ""
DefineNamingRule "None"
DefineNamingFcn ""
ParamNamingRule "None"
ParamNamingFcn ""
SignalNamingRule "None"
SignalNamingFcn ""
InsertBlockDesc off
InsertPolySpaceComments off
SimulinkBlockComments on
MATLABSourceComments off
EnableCustomComments off
InternalIdentifierFile ""
InternalIdentifier "Shortened"
InlinedPrmAccess "Literals"
ReqsInCode off
UseSimReservedNames off
ReservedNameArray []
}
Simulink.GRTTargetCC {
$BackupClass "Simulink.TargetCC"
$ObjectID 18
Version "1.16.5"
Array {
Type "Cell"
Dimension 16
Cell "GeneratePreprocessorConditionals"
Cell "IncludeMdlTerminateFcn"
Cell "SuppressErrorStatus"
Cell "ERTCustomFileBanners"
Cell "GenerateSampleERTMain"
Cell "GenerateTestInterfaces"
Cell "ModelStepFunctionPrototypeControlCompliant"
Cell "GenerateAllocFcn"
Cell "PurelyIntegerCode"
Cell "SupportComplex"
Cell "SupportAbsoluteTime"
Cell "SupportContinuousTime"
Cell "SupportNonInlinedSFcns"
Cell "ExistingSharedCode"
Cell "RemoveDisableFunc"
Cell "RemoveResetFunc"
PropName "DisabledProps"
}
Description ""
TargetFcnLib "ansi_tfl_table_tmw.mat"
TargetLibSuffix ""
TargetPreCompLibLocation ""
GenFloatMathFcnCalls "NOT IN USE"
TargetLangStandard "C89/C90 (ANSI)"
CodeReplacementLibrary "None"
UtilityFuncGeneration "Auto"
ERTMultiwordTypeDef "System defined"
ERTMultiwordLength 256
MultiwordLength 2048
GenerateFullHeader on
InferredTypesCompatibility off
ExistingSharedCode ""
GenerateSampleERTMain off
GenerateTestInterfaces off
ModelReferenceCompliant on
ParMdlRefBuildCompliant on
CompOptLevelCompliant on
ConcurrentExecutionCompliant on
IncludeMdlTerminateFcn on
GeneratePreprocessorConditionals "Disable all"
CombineOutputUpdateFcns on
CombineSignalStateStructs off
SuppressErrorStatus off
ERTFirstTimeCompliant off
IncludeFileDelimiter "Auto"
ERTCustomFileBanners off
SupportAbsoluteTime on
LogVarNameModifier "rt_"
MatFileLogging on
MultiInstanceERTCode off
CodeInterfacePackaging "Nonreusable function"
SupportNonFinite on
SupportComplex on
PurelyIntegerCode off
SupportContinuousTime on
SupportNonInlinedSFcns on
RemoveDisableFunc off
RemoveResetFunc off
SupportVariableSizeSignals off
ParenthesesLevel "Nominal"
CastingMode "Nominal"
MATLABClassNameForMDSCustomization "Simulink.SoftwareTarget.GRTCustomization"
ModelStepFunctionPrototypeControlCompliant off
CPPClassGenCompliant on
AutosarCompliant off
MDXCompliant off
GRTInterface off
GenerateAllocFcn off
UseToolchainInfoCompliant on
GenerateSharedConstants on
CoderGroups []
UseMalloc off
ExtMode off
ExtModeStaticAlloc off
ExtModeTesting off
ExtModeStaticAllocSize 1000000
ExtModeTransport 0
ExtModeMexFile "ext_comm"
ExtModeMexArgs ""
ExtModeIntrfLevel "Level1"
RTWCAPISignals off
RTWCAPIParams off
RTWCAPIStates off
RTWCAPIRootIO off
GenerateASAP2 off
MultiInstanceErrorCode "Error"
}
PropName "Components"
}
}
SlCovCC.ConfigComp {
$ObjectID 19
Version "1.16.5"
DisabledProps []
Description "Simulink Coverage Configuration Component"
Name "Simulink Coverage"
CovEnable off
CovScope "EntireSystem"
CovIncludeTopModel on
RecordCoverage off
CovPath "/"
CovSaveName "covdata"
CovCompData ""
CovMetricSettings "dw"
CovFilter ""
CovHTMLOptions ""
CovNameIncrementing off
CovHtmlReporting on
CovForceBlockReductionOff on
CovEnableCumulative on
CovSaveCumulativeToWorkspaceVar on
CovSaveSingleToWorkspaceVar on
CovCumulativeVarName "covCumulativeData"
CovCumulativeReport off
CovSaveOutputData on
CovOutputDir "slcov_output/$ModelName$"
CovDataFileName "$ModelName$_cvdata"
CovShowResultsExplorer on
CovReportOnPause on
CovModelRefEnable "off"
CovModelRefExcluded ""
CovExternalEMLEnable off
CovSFcnEnable on
CovBoundaryAbsTol 1e-05
CovBoundaryRelTol 0.01
CovUseTimeInterval off
CovStartTime 0
CovStopTime 0
}
PropName "Components"
}
Name "Configuration"
ExtraOptions ""
CurrentDlgPage "Solver"
ConfigPrmDlgPosition [ 228, 112, 1308, 752 ]
}
PropName "ConfigurationSets"
}
Simulink.ConfigSet {
$PropName "ActiveConfigurationSet"
$ObjectID 8
}
Object {
$PropName "DataTransfer"
$ObjectID 20
$ClassName "Simulink.GlobalDataTransfer"
DefaultTransitionBetweenSyncTasks "Ensure deterministic transfer (maximum delay)"
DefaultTransitionBetweenAsyncTasks "Ensure data integrity only"
DefaultTransitionBetweenContTasks "Ensure deterministic transfer (minimum delay)"
DefaultExtrapolationMethodBetweenContTasks "None"
AutoInsertRateTranBlk [0]
}
ExplicitPartitioning off
BlockDefaults {
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
NamePlacement "normal"
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
ShowName on
BlockRotation 0
BlockMirror off
}
AnnotationDefaults {
HorizontalAlignment "center"
VerticalAlignment "middle"
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
UseDisplayTextAsClickCallback off
}
LineDefaults {
FontName "Helvetica"
FontSize 9
FontWeight "normal"
FontAngle "normal"
}
MaskDefaults {
SelfModifiable "off"
IconFrame "on"
IconOpaque "opaque"
RunInitForIconRedraw "off"
IconRotate "none"
PortRotate "default"
IconUnits "autoscale"
}
MaskParameterDefaults {
Evaluate "on"
Tunable "on"
NeverSave "off"
Internal "off"
ReadOnly "off"
Enabled "on"
Visible "on"
ToolTip "on"
}
BlockParameterDefaults {
Block {
BlockType Constant
Value "1"
VectorParams1D on
SamplingMode "Sample based"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Inherit from 'Constant value'"
LockScale off
SampleTime "inf"
FramePeriod "inf"
PreserveConstantTs off
}
Block {
BlockType Demux
Outputs "4"
DisplayOption "none"
BusSelectionMode off
}
Block {
BlockType Ground
}
Block {
BlockType Inport
Port "1"
OutputFunctionCall off
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: auto"
LockScale off
BusOutputAsStruct off
Unit "inherit"
PortDimensions "-1"
VarSizeSig "Inherit"
SampleTime "-1"
SignalType "auto"
SamplingMode "auto"
LatchByDelayingOutsideSignal off
LatchInputForFeedbackSignals off
Interpolate on
}
Block {
BlockType Outport
Port "1"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: auto"
LockScale off
BusOutputAsStruct off
Unit "inherit"
PortDimensions "-1"
VarSizeSig "Inherit"
SampleTime "-1"
SignalType "auto"
SamplingMode "auto"
EnsureOutportIsVirtual off
SourceOfInitialOutputValue "Dialog"
OutputWhenDisabled "held"
InitialOutput "[]"
}
Block {
BlockType Quantizer
QuantizationInterval "0.5"
LinearizeAsGain on
SampleTime "-1"
}
Block {
BlockType RandomNumber
Mean "0"
Variance "1"
Seed "0"
SampleTime "-1"
VectorParams1D on
}
Block {
BlockType S-Function
FunctionName "system"
SFunctionModules "''"
PortCounts "[]"
}
Block {
BlockType Scope
DefaultConfigurationName "Simulink.scopes.TimeScopeBlockCfg"
Floating off
}
Block {
BlockType SubSystem
ShowPortLabels "FromPortIcon"
Permissions "ReadWrite"
PermitHierarchicalResolution "All"
TreatAsAtomicUnit off
MinAlgLoopOccurrences off
PropExecContextOutsideSubsystem off
SystemSampleTime "-1"
RTWSystemCode "Auto"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
FunctionInterfaceSpec "void_void"
FunctionWithSeparateData off
RTWMemSecFuncInitTerm "Inherit from model"
RTWMemSecFuncExecute "Inherit from model"
RTWMemSecDataConstants "Inherit from model"
RTWMemSecDataInternal "Inherit from model"
RTWMemSecDataParameters "Inherit from model"
SimViewingDevice off
DataTypeOverride "UseLocalSettings"
DataTypeOverrideAppliesTo "AllNumericTypes"
MinMaxOverflowLogging "UseLocalSettings"
Opaque off
MaskHideContents off
SFBlockType "NONE"
GeneratePreprocessorConditionals off
PropagateVariantConditions off
TreatAsGroupedWhenPropagatingVariantConditions on
ContentPreviewEnabled off
IsWebBlock off
}
Block {
BlockType Sum
IconShape "rectangular"
Inputs "++"
CollapseMode "All dimensions"
CollapseDim "1"
InputSameDT on
AccumDataTypeStr "Inherit: Inherit via internal rule"
OutMin "[]"
OutMax "[]"
OutDataTypeStr "Inherit: Same as first input"
LockScale off
RndMeth "Floor"
SaturateOnIntegerOverflow on
SampleTime "-1"
}
Block {
BlockType Terminator
}
Block {
BlockType ZeroOrderHold
SampleTime "1"
}
}
System {
Name "IMU_prototype"
Location [-8, -8, 1928, 1048]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "250"
ReportName "simulink-default.rpt"
SIDHighWatermark "33"
Block {
BlockType Constant
Name "Constant"
SID "5"
Position [20, 75, 50, 105]
ZOrder 5
Value "zeros(3,1)"
SampleTime "0"
}
Block {
BlockType SubSystem
Name "IMU"
SID "20"
Ports [4, 2]
Position [365, 81, 550, 174]
ZOrder 20
RequestExecContextInheritance off
Variant off
System {
Name "IMU"
Location [-8, -8, 1928, 1048]
Open on
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "150"
Block {
BlockType Inport
Name "B_vo_dot"
SID "21"
Position [110, 173, 140, 187]
ZOrder 17
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_vo"
SID "29"
Position [110, 208, 140, 222]
ZOrder 25
Port "2"
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_Omega"
SID "30"
Position [110, 243, 140, 257]
ZOrder 26
Port "3"
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_Fg"
SID "31"
Position [110, 278, 140, 292]
ZOrder 27
Port "4"
IconDisplay "Port number"
}
Block {
BlockType Ground
Name "Ground"
SID "27"
Position [500, 365, 520, 385]
ZOrder 23
}
Block {
BlockType Ground
Name "Ground1"
SID "28"
Position [500, 120, 520, 140]
ZOrder 24
}
Block {
BlockType SubSystem
Name "MATLAB Function"
SID "1"
Ports [5, 2]
Position [250, 165, 445, 335]
ZOrder 1
LibraryVersion "1.32"
ErrorFcn "Stateflow.Translate.translate"
PermitHierarchicalResolution "ExplicitOnly"
TreatAsAtomicUnit on
RequestExecContextInheritance off
SFBlockType "MATLAB Function"
Variant off
System {
Name "MATLAB Function"
Location [223, 338, 826, 833]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
SIDHighWatermark "26"
Block {
BlockType Inport
Name "B_vo_dot"
SID "1::1"
Position [20, 101, 40, 119]
ZOrder -1
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_vo"
SID "1::22"
Position [20, 136, 40, 154]
ZOrder 13
Port "2"
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_Omega"
SID "1::19"
Position [20, 171, 40, 189]
ZOrder 10
Port "3"
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "B_Fg"
SID "1::20"
Position [20, 206, 40, 224]
ZOrder 11
Port "4"
IconDisplay "Port number"
}
Block {
BlockType Inport
Name "r_oc"
SID "1::23"
Position [20, 246, 40, 264]
ZOrder 14
Port "5"
IconDisplay "Port number"
}
Block {
BlockType Demux
Name " Demux "
SID "1::25"
Ports [1, 1]
Position [270, 230, 320, 270]
ZOrder 16
Outputs "1"
}
Block {
BlockType S-Function
Name " SFunction "
SID "1::24"
Tag "Stateflow S-Function IMU_prototype 2"
Ports [5, 3]
Position [180, 100, 230, 220]
ZOrder 15
FunctionName "sf_sfun"
PortCounts "[5 3]"
SFunctionDeploymentMode off
EnableBusSupport off
SFcnIsStateOwnerBlock off
Port {
PortNumber 2
Name "accel_reading"
RTWStorageClass "Auto"
DataLoggingNameMode "SignalName"
}
Port {
PortNumber 3
Name "gyro_reading"
RTWStorageClass "Auto"
DataLoggingNameMode "SignalName"
}
}
Block {
BlockType Terminator
Name " Terminator "
SID "1::26"
Position [460, 241, 480, 259]
ZOrder 17
}
Block {
BlockType Outport
Name "accel_reading"
SID "1::5"
Position [460, 101, 480, 119]
ZOrder -5
IconDisplay "Port number"
}
Block {
BlockType Outport
Name "gyro_reading"
SID "1::21"
Position [460, 136, 480, 154]
ZOrder 12
Port "2"
IconDisplay "Port number"
}
Line {
ZOrder 52
SrcBlock "B_vo_dot"
SrcPort 1
DstBlock " SFunction "
DstPort 1
}
Line {
ZOrder 53
SrcBlock "B_vo"
SrcPort 1
DstBlock " SFunction "
DstPort 2
}
Line {
ZOrder 54
SrcBlock "B_Omega"
SrcPort 1
DstBlock " SFunction "
DstPort 3
}
Line {
ZOrder 55
SrcBlock "B_Fg"
SrcPort 1
DstBlock " SFunction "
DstPort 4
}
Line {
ZOrder 56
SrcBlock "r_oc"
SrcPort 1
DstBlock " SFunction "
DstPort 5
}
Line {
Name "accel_reading"
ZOrder 57
Labels [0, 0]
SrcBlock " SFunction "
SrcPort 2
DstBlock "accel_reading"
DstPort 1
}
Line {
Name "gyro_reading"
ZOrder 58
Labels [0, 0]
SrcBlock " SFunction "
SrcPort 3
DstBlock "gyro_reading"
DstPort 1
}
Line {
ZOrder 59
SrcBlock " Demux "
SrcPort 1
DstBlock " Terminator "
DstPort 1
}
Line {
ZOrder 60
SrcBlock " SFunction "
SrcPort 1
Points [20, 0]
DstBlock " Demux "
DstPort 1
}
}
}
Block {
BlockType Sum
Name "Sum"
SID "7"
Ports [2, 1]
Position [690, 285, 710, 305]
ZOrder 7
ShowName off
IconShape "round"
Inputs "|++"
InputSameDT off
OutDataTypeStr "Inherit: Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum1"
SID "8"
Ports [2, 1]
Position [690, 200, 710, 220]
ZOrder 8
ShowName off
IconShape "round"
Inputs "++|"
InputSameDT off
OutDataTypeStr "Inherit: Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum2"
SID "11"
Ports [2, 1]
Position [570, 285, 590, 305]
ZOrder 11
ShowName off
IconShape "round"
Inputs "|++"
InputSameDT off
OutDataTypeStr "Inherit: Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum3"
SID "12"
Ports [2, 1]
Position [570, 200, 590, 220]
ZOrder 12
ShowName off
IconShape "round"
Inputs "++|"
InputSameDT off
OutDataTypeStr "Inherit: Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType RandomNumber
Name "accelerometer_noise"
SID "2"
Position [630, 140, 660, 170]
ZOrder 2
Mean "zeros(3,1)"
Variance "[ 3e-7 ; 3.3e-7 ; 7.2e-7 ] "
Seed "[0,1,2]"
SampleTime "6.1e-3"
}
Block {
BlockType Quantizer
Name "accelerometer_quantizer"
SID "9"
Position [770, 195, 800, 225]
ZOrder 9
QuantizationInterval "2.4400e-04"
}
Block {
BlockType ZeroOrderHold
Name "accelerometer_sampling"
SID "15"
Position [495, 195, 530, 225]
ZOrder 15
SampleTime "6.1e-3"
}
Block {
BlockType RandomNumber
Name "gyroscope_noise"
SID "6"
Position [630, 315, 660, 345]
ZOrder 6
Mean "zeros(3,1)"
Variance "[ 2.2e-8 ; 1.1e-7 ; 2.4e-8 ]"
Seed "[0,1,2]"
SampleTime "6.1e-3"
}
Block {
BlockType Quantizer
Name "gyroscope_qunatizer"
SID "10"
Position [770, 280, 800, 310]
ZOrder 10
QuantizationInterval "1.1e-3"
}
Block {
BlockType ZeroOrderHold
Name "gyroscope_sampling"
SID "16"
Position [495, 280, 530, 310]
ZOrder 16
SampleTime "6.1e-3"
}
Block {
BlockType Constant
Name "r_oc"
SID "32"
Position [30, 307, 95, 333]
ZOrder 28
Value "zeros(3,1)"
}
Block {
BlockType Outport
Name "accelerometer"
SID "33"
Position [885, 203, 915, 217]
ZOrder 29
IconDisplay "Port number"
}
Block {
BlockType Outport
Name "gyroscope"
SID "25"
Position [885, 288, 915, 302]
ZOrder 21
Port "2"
IconDisplay "Port number"
}
Line {
ZOrder 51
SrcBlock "gyroscope_qunatizer"
SrcPort 1
DstBlock "gyroscope"
DstPort 1
}
Line {
ZOrder 61
SrcBlock "accelerometer_quantizer"
SrcPort 1
DstBlock "accelerometer"
DstPort 1
}
Line {
ZOrder 1
SrcBlock "accelerometer_noise"
SrcPort 1
Points [35, 0]
DstBlock "Sum1"
DstPort 1
}
Line {
ZOrder 22
SrcBlock "Sum"
SrcPort 1
DstBlock "gyroscope_qunatizer"
DstPort 1
}
Line {
ZOrder 24
SrcBlock "Sum2"
SrcPort 1
DstBlock "Sum"
DstPort 1
}
Line {
ZOrder 25
SrcBlock "Sum3"
SrcPort 1
DstBlock "Sum1"
DstPort 2
}
Line {
ZOrder 23
SrcBlock "MATLAB Function"
SrcPort 2
DstBlock "gyroscope_sampling"
DstPort 1
}
Line {
ZOrder 18
SrcBlock "gyroscope_noise"
SrcPort 1
Points [35, 0]
DstBlock "Sum"
DstPort 2
}
Line {
ZOrder 26
SrcBlock "MATLAB Function"
SrcPort 1
DstBlock "accelerometer_sampling"
DstPort 1
}
Line {
ZOrder 21
SrcBlock "Sum1"
SrcPort 1
DstBlock "accelerometer_quantizer"
DstPort 1
}
Line {
ZOrder 31
SrcBlock "gyroscope_sampling"
SrcPort 1
DstBlock "Sum2"
DstPort 1
}
Line {
ZOrder 30
SrcBlock "accelerometer_sampling"
SrcPort 1
DstBlock "Sum3"
DstPort 2
}
Line {
ZOrder 52
SrcBlock "Ground"
SrcPort 1
Points [55, 0]
DstBlock "Sum2"
DstPort 2
}
Line {
ZOrder 53
SrcBlock "Ground1"
SrcPort 1
Points [55, 0]
DstBlock "Sum3"
DstPort 1
}
Line {
ZOrder 56
SrcBlock "B_vo_dot"
SrcPort 1
DstBlock "MATLAB Function"
DstPort 1
}
Line {
ZOrder 57
SrcBlock "B_vo"
SrcPort 1
DstBlock "MATLAB Function"
DstPort 2
}
Line {
ZOrder 58
SrcBlock "B_Omega"
SrcPort 1
DstBlock "MATLAB Function"
DstPort 3
}
Line {
ZOrder 59
SrcBlock "B_Fg"
SrcPort 1
DstBlock "MATLAB Function"
DstPort 4
}
Line {
ZOrder 60
SrcBlock "r_oc"
SrcPort 1
DstBlock "MATLAB Function"
DstPort 5
}
}
}
Block {
BlockType Scope
Name "Scope"
SID "3"
Ports [1]
Position [635, 134, 665, 166]
ZOrder 3
ScopeSpecificationString "C++SS(StrPVP('Location','[1, 55, 1921, 1029]'),StrPVP('Open','off'),MxPVP('AxesTitles'"
",24,'struct(''axes1'',''%<SignalLabel>'')'),MxPVP('ScopeGraphics',28,'struct(''FigureColor'',''[0.5 0.5 0.5]'','"
"'AxesColor'',''[0 0 0]'',''AxesTickColor'',''[1 1 1]'',''LineColors'',''[1 1 0;1 0 1;0 1 1;1 0 0;0 1 0;0 0 1]'',"
"''LineStyles'',''-|-|-|-|-|-'',''LineWidths'',''[0.5 0.5 0.5 0.5 0.5 0.5]'',''MarkerStyles'',''none|none|none|no"
"ne|none|none'')'),StrPVP('LimitDataPoints','on'),StrPVP('DataFormat','Array'),StrPVP('Decimation','1'),StrPVP('B"
"lockParamSampleInput','off'))"
NumInputPorts "1"
}
Block {
BlockType Scope
Name "Scope1"
SID "13"
Ports [1]
Position [590, 89, 620, 121]
ZOrder 13
ScopeSpecificationString "C++SS(StrPVP('Location','[188, 365, 512, 604]'),StrPVP('Open','off'),MxPVP('AxesTitles"
"',24,'struct(''axes1'',''%<SignalLabel>'')'),MxPVP('ScopeGraphics',28,'struct(''FigureColor'',''[0.5 0.5 0.5]'',"
"''AxesColor'',''[0 0 0]'',''AxesTickColor'',''[1 1 1]'',''LineColors'',''[1 1 0;1 0 1;0 1 1;1 0 0;0 1 0;0 0 1]''"
",''LineStyles'',''-|-|-|-|-|-'',''LineWidths'',''[0.5 0.5 0.5 0.5 0.5 0.5]'',''MarkerStyles'',''none|none|none|n"
"one|none|none'')'),StrPVP('SaveName','ScopeData1'),StrPVP('LimitDataPoints','on'),StrPVP('DataFormat','Array'),S"
"trPVP('Decimation','1'),StrPVP('BlockParamSampleInput','off'))"
NumInputPorts "1"
}
Line {
ZOrder 55
SrcBlock "IMU"
SrcPort 1
DstBlock "Scope1"
DstPort 1
}
Line {
ZOrder 47
SrcBlock "Constant"
SrcPort 1
Points [261, 0]
Branch {
ZOrder 50
Points [0, 25; 1, 0]
Branch {
ZOrder 52
Points [0, 25; 3, 0]
Branch {
ZOrder 54
Points [0, 25]
DstBlock "IMU"
DstPort 4
}
Branch {
ZOrder 53
DstBlock "IMU"
DstPort 3
}
}
Branch {
ZOrder 51
DstBlock "IMU"
DstPort 2
}
}
Branch {
ZOrder 49
DstBlock "IMU"
DstPort 1
}
}
Line {
ZOrder 56
SrcBlock "IMU"
SrcPort 2
DstBlock "Scope"
DstPort 1
}
}
}
#Finite State Machines
#
# Stateflow 80000010
#
#
Stateflow {
machine {
id 1
name "IMU_prototype"
created "16-Nov-2016 14:11:28"
isLibrary 0
sfVersion 80000010
firstTarget 14
}
chart {
id 2
machine 1
name "IMU/MATLAB Function"
windowPosition [422 539.941 189 413]
viewLimits [0 156.75 0 153.75]
screen [1 1 3600 1200 1.180555555555556]
treeNode [0 3 0 0]
viewObj 2
visible 1
subviewS {
}
ssIdHighWaterMark 10
decomposition CLUSTER_CHART
type EML_CHART
chartFileNumber 2
disableImplicitCasting 1
eml {
name "fcn"
}
firstData 4
firstTransition 12
firstJunction 11
}
state {
id 3
labelString "eML_blk_kernel()"
position [18 64.5 118 66]
fontSize 12
chart 2
treeNode [2 0 0 0]
superState SUBCHART
subviewer 2
ssIdNumber 1
type FUNC_STATE
decomposition CLUSTER_STATE
eml {
isEML 1
script "function [accel_reading,gyro_reading] = fcn(B_vo_dot, B_vo, B_Omega, B_Fg, r_oc)\n%#codegen\n\na "
"= B_vo_dot + cross(B_Omega,B_vo) ; % body frame acceleration \n\naccel_reading = a - B_Fg ; % accelerometer read"
"ing (ideal)\n\ngyro_reading = B_Omega ; % gyroscope reading (ideal) \n\nend\n\n"
editorLayout "100 M4x1[10 5 700 500]"
}
}
data {
id 4
ssIdNumber 4
name "B_vo_dot"
scope INPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
}
complexity SF_COMPLEX_INHERITED
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 0 5]
}
data {
id 5
ssIdNumber 9
name "B_vo"
scope INPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
isSigned 1
wordLength "16"
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_INHERITED
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 4 6]
}
data {
id 6
ssIdNumber 5
name "accel_reading"
scope OUTPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_NO
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 5 7]
}
data {
id 7
ssIdNumber 6
name "B_Omega"
scope INPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
isSigned 1
wordLength "16"
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_INHERITED
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 6 8]
}
data {
id 8
ssIdNumber 7
name "B_Fg"
scope INPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
isSigned 1
wordLength "16"
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_INHERITED
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 7 9]
}
data {
id 9
ssIdNumber 8
name "gyro_reading"
scope OUTPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
isSigned 1
wordLength "16"
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_NO
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 8 10]
}
data {
id 10
ssIdNumber 10
name "r_oc"
scope INPUT_DATA
machine 1
props {
array {
size "-1"
}
type {
method SF_INHERITED_TYPE
primitive SF_DOUBLE_TYPE
isSigned 1
wordLength "16"
}
complexity SF_COMPLEX_INHERITED
frame SF_FRAME_INHERITED
unit {
name "inherit"
}
}
dataType "Inherit: Same as Simulink"
linkNode [2 9 0]
}
junction {
id 11
position [23.5747 49.5747 7]
chart 2
subviewer 2
ssIdNumber 3
type CONNECTIVE_JUNCTION
linkNode [2 0 0]
}
transition {
id 12
labelString "{eML_blk_kernel();}"
labelPosition [28.125 13.875 102.544 14.964]
fontSize 12
src {
intersection [0 0 1 0 23.5747 14.625 0 0]
}
dst {
id 11
intersection [1 0 -1 0 23.5747 42.5747 0 0]
}
midPoint [23.5747 24.9468]
chart 2
dataLimits [21.175 25.975 14.625 42.575]
subviewer 2
drawStyle SMART
slide {
sticky BOTH_STICK
}
executionOrder 1
ssIdNumber 2
linkNode [2 0 0]
}
instance {
id 13
machine 1
name "IMU/MATLAB Function"
chart 2
}
target {
id 14
machine 1
name "sfun"
description "Default Simulink S-Function Target."
linkNode [1 0 0]
}
}
File added
File added
% Model Parameters
m = 1.19; % Quadrotor + battery mass
g = 9.81; % Acceleration of gravity
Jxx = 0.0218; % Quadrotor and battery motor of inertia around bx (pitch)
Jyy = 0.0277; % Quadrotor and battery motor of inertia around by (roll)
Jzz = 0.0332; % Quadrotor and battery motor of inertia around bz (yaw)
Jreq = 4.2012e-05; % Rotor and motor moment of inertia around axis of rotation
Kt = 8.1558*10^-6; % Rotor thrust constant
Kh = 0; % Rotor in-plane drag constant
Kd = 1.8087e-07; % Rotor drag constant
rhx = 0.016; % X-axis distance from center of mass to a rotor hub
rhy = 0.016; % Y-axis distance from center of mass to a rotor hub
rhz = 0.003; % Z-axis distance from center of mass to a rotor hub
Rm = 0.2308; % Motor resistance
Kq = 96.3422; % Motor torque constant
Kv = 96.3422; % Motor back emf constant
If = 0.511; % Motor internal friction current
Pmin = 0.40; % Minimum zybo output duty cycle command
Pmax = 0.80; % Maximum zybo output duty cycle command
Tc = 0.01; % Camera system sampling period
tau_c = 0; % Camera system total latency
Vb = 11.1; % Nominal battery voltage (V)
\ No newline at end of file
File added
......@@ -38,4 +38,7 @@ src/vrpn/build*
src/vrpn/pc_linux64/*
#Exacutables
./BlueTooth
logs
BackEnd
obj
Cli
# Declaration of variables
# Generic Variables
GCC=gcc
GXX=g++
CFLAGS= -Wall -Wpedantic -Wextra -Werror -std=c99 -g -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable
CXXFLAGS= -Wall -Wpedantic -Wextra -Werror -Wno-reorder -Wno-unused-variable -std=c++0x -g
INCLUDES = $(foreach dir, $(INCDIR), -I$(dir))
INCDIR=inc src/vrpn src/vrpn/quat src/vrpn/build $(BESRCDIR) $(CLISRCDIR) $(FESRCDIR)
LIBS= -lpthread -lbluetooth -lvrpn -lquat -Lsrc/vrpn/build -Lsrc/vrpn/build/quat
OBJDIR=obj
# Backend Specific Variables
BEBINARY=BackEnd
BESRCDIR=src/backend
BECSOURCES := $(wildcard $(BESRCDIR)/*.c )
BECOBJECTS = $(BECSOURCES:$(BESRCDIR)/%.c=$(OBJDIR)/%.o)
BECPPSOURCES := $(wildcard $(BESRCDIR)/*.cpp )
BECPPOBJECTS = $(BECPPSOURCES:$(BESRCDIR)/%.cpp=$(OBJDIR)/%.o)
# CLI Specific Variables
CLIBINARY=Cli
CLISRCDIR=src/cli
CLISOURCES := $(wildcard $(CLISRCDIR)/*.c)
CLIOBJECTS = $(CLISOURCES:$(CLISRCDIR)/%.c=$(OBJDIR)/%.o)
# Frontend-common stuff
FESRCDIR=src/frontend
FECSOURCES := $(wildcard $(FESRCDIR)/*.c )
FECOBJECTS = $(FECSOURCES:$(FESRCDIR)/%.c=$(OBJDIR)/%.o)
OBJECTS= $(CLIOBJECTS) $(BECOBJECTS) $(BECPPOBJECTS) $(FECOBJECTS)
# Default target
all: logs objdir backend cli
vrpn: vrpn/build
cli: $(CLIOBJECTS) $(FECOBJECTS)
$(GCC) $(CFLAGS) $^ -o $(CLIBINARY) $(INCLUDES) $(LIBS)
$(CLIOBJECTS) : $(OBJDIR)/%.o : $(CLISRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS)
backend: $(BECPPOBJECTS) $(BECOBJECTS)
$(GXX) $(CXXFLAGS) $^ -o $(BEBINARY) $(INCLUDES) $(LIBS)
$(FECOBJECTS) : $(OBJDIR)/%.o : $(FESRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS)
$(BECOBJECTS) : $(OBJDIR)/%.o : $(BESRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS)
$(BECPPOBJECTS) : $(OBJDIR)/%.o : $(BESRCDIR)/%.cpp
$(GXX) $(CXXFLAGS) -c $^ -o $@ $(INCLUDES) $(LIBS)
vrpn/build:
mkdir -p src/vrpn/build
cd src/vrpn/build && cmake .. && make
logs:
mkdir -p logs
objdir:
mkdir -p obj
clean_logs:
rm -f logs/*
clean:
rm -rf $(OBJDIR)/ $(BEBINARY) $(CLIBINARY)
debug:
@echo $(OBJECTS)
# groundStation
## Make Process
First, if submodules were not recursevly added through git. Run this command if you have made any attempt to make vrpn manually.
run
'git submodule update --init --recursive'
Now that you have all of the files necissary.
cd into the groundstation folder.
cd groundStation
make vrpn
make
run the program with sudo privledges
sudo -E ./BackEnd
If you wish to change the way the backend communicates to the quad and vice versa, look at src/config.h.
This provides a list of environment variables which you can set and use for your computer or time of use.
Because the backend must be ran with sudo privledges, you will need to preserve the env. vars. with sudo rights.
Hence the "-E" flag.
/* Author: Kris Burney & Jake Drahos
*
* BlueTooth socket program for passing vrpn data to quad.
*/
#define _GNU_SOURCE
#define _BSD_SOURCE
//system includes
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <netinet/tcp.h>
//user created includes
#include "communication.h"
#include "commands.h"
#include "vrpn_tracker.hpp"
#include "type_def.h"
#include "logger.h"
#include "config.h"
#define QUAD_BT_ADDR "00:06:66:64:61:D6"
#define QUAD_BT_CHANNEL 0x01
#define CMD_MAX_LENGTH 1024
#define MAX_HASH_SIZE 50
// function prototypes
void readAndPrint(void);
void sendVrpnPacket(struct ucart_vrpn_TrackerData *);
void sendStartPacket(void);
void getVRPNPacket(struct ucart_vrpn_TrackerData *);
void printVrpnData(struct ucart_vrpn_TrackerData *);
int connectToZybo();
int safe_fd_set(int , fd_set* , int* );
int safe_fd_clr(int , fd_set* , int* );
static void safe_close_fd(int fd, pthread_mutex_t *mutexLock);
static void cb(struct ucart_vrpn_TrackerData *);
static int new_client(int fd);
/* Return index of client, or -1 */
static ssize_t get_client_index(int fd);
/* Returns pointer to client buffer, or -1 */
static char * get_client_buffer(int fd);
/* Return pointer to client pending responses, or -1*/
static int * get_client_pend_responses(int fd);
/* Return positive integer if successful, -1 otherwise */
static int clientAddPendResponses(int fd, unsigned char *packet);
/* Returns -1 on error */
static int remove_client(int fd);
/* Receive data from client */
static void client_recv(int fd);
/* Checks to see if socket has disconnected. Returns 1 on disconnect, else returns 0 */
static int wasDisconnected(int fd);
/* Thread-safe wrappers */
pthread_mutex_t quadSocketMutex;
static ssize_t writeQuad(const char * buf, size_t count);
static ssize_t readQuad(char * buf, size_t count);
/* Functions for recording Latencies */
void findTimeDiff(int respID);
int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
//time stamp checking
static unsigned int currMessageID = 0;
struct timeval timeArr[MAX_HASH_SIZE];
// global variables
static volatile int keepRunning = 1;
const char *TRACKER_IP = "UAV@192.168.0.120:3883";
static int zyboSocket;
static int backendSocket;
struct ucart_vrpn_tracker * tracker = NULL;
const char *logHeader = "";//"#\n#\tDefault log header\n#\tEverything after '#'`s will be printed as is in the processed logs.\n#\n\0";
#define MAX_CLIENTS 32
#define CLIENT_BUFFER_SIZE 1024
#define CLIENT_MAX_PENDING_RESPONSES 5
static char client_buffers[MAX_CLIENTS][CLIENT_BUFFER_SIZE];
static int client_fds[MAX_CLIENTS];
static int client_pending_responses[MAX_CLIENTS][CLIENT_MAX_PENDING_RESPONSES];
fd_set rfds_master;
int max_fd = 0;
pthread_mutex_t quadResponseMutex, cliInputMutex ;
char *respBuf, *commandBuf;
int newQuadResponse = 0, newCliInput = 0;
// Structures to be used throughout
modular_structs_t structs;
// Callback to be ran whenever the tracker receives data.
// Currently doing much more than it should. It will be slimmed down
// in the future.
static void cb(struct ucart_vrpn_TrackerData * td)
{
static int count = 0;
if(!(count % 10)) {
//sendVrpnPacket(td);
//updateLogFile(td);
}
count++;
}
int main(int argc, char **argv)
{
int activity;
FD_ZERO(&rfds_master);
/*
* Create backend listening socket
*/
/* Determine socket path */
char * backend_socket_path = DEFAULT_SOCKET;
if (getenv(SOCKET_ENV)) {
backend_socket_path = getenv(SOCKET_ENV);
}
/* Unlink if it exists */
unlink(backend_socket_path);
/* Create socket */
backendSocket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (backendSocket < 0) {
err(-1, "socket");
}
/* Create sockaddr and bind */
struct sockaddr_un sa;
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, backend_socket_path, 107);
sa.sun_path[107] = '\0';
if (bind(backendSocket, (struct sockaddr *) &sa, sizeof(sa))) {
err(-1, "bind");
}
/* Listen */
if (listen(backendSocket, 16)) {
err(-1, "listen");
}
/* Add to socket set */
safe_fd_set(backendSocket, &rfds_master, &max_fd);
/* Initialize client buffers */
for (int i = 0; i < MAX_CLIENTS; i++) {
client_fds[i] = -1;
client_buffers[i][0] = '\n';
for(int j = 0; j < CLIENT_MAX_PENDING_RESPONSES; j++) {
client_pending_responses[i][j] = -1;
}
}
if (pthread_mutex_lock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
if ((zyboSocket = connectToZybo()) < 0)
{
perror("Error connecting to Quad...");
free(respBuf);
free(commandBuf);
exit(1);
}
if (pthread_mutex_unlock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
// open the log file
if(createLogFile(argc, argv[1]))
{
perror("Error creating log file...");
exit(1);
}
// writeStringToLog(logHeader);
// watch for input from stdin (fd 0) to see when it has input
safe_fd_set(fileno(stdin), &rfds_master, &max_fd);
if (!getenv(NOQUAD_ENV)) {
// watch for input from the zybo socket
safe_fd_set(zyboSocket, &rfds_master, &max_fd);
}
// Tell the quad we are ready to send it vrpn data
sendStartPacket();
if(!getenv(NOVRPN_ENV)){
// create vrpnTracker instance
tracker = ucart_vrpn_tracker_createInstance(TRACKER_IP);
// this function will be called whenever tracker receives data
ucart_vrpn_tracker_addCallback(tracker, cb);
}
struct timeval timeout = {
.tv_sec = 1,
.tv_usec = 0
};
respBuf = calloc(CMD_MAX_LENGTH, sizeof(unsigned char));
sleep(3);
while(keepRunning)
{
fd_set rfds;
rfds = rfds_master;
activity = select(max_fd+1, &rfds, NULL, NULL, NULL);
if(activity == -1) {
perror("select() ");
} else if (activity) {
for(int fd = 0; fd <= max_fd; ++fd) {
if (FD_ISSET(fd, &rfds)) {
if(wasDisconnected(fd)){
break;
}
if (fd == fileno(stdin)) {
} else if (fd == zyboSocket) {
// Read the response from the control loop
int available;
ioctl(fd, FIONREAD, &available);
if (available < 12) {
continue;
}
int respLen = readQuad(respBuf, 12);
if(respLen <= 0) {
perror("ERROR reading from quad...\n");
}
int id = getInt((unsigned char *)respBuf, 7);
findTimeDiff(id);
// if(respLen == 11) {
// int id = getInt((unsigned char *)respBuf, 7);
// findTimeDiff(id);
// printf("respLen = %d : id = %d'\n", respLen, id);
// for(int i = 0; i <= respLen -1; ++i)
// printf("%x ", (unsigned char)respBuf[i]);
// printf("'\n");
// }
memset(respBuf, 0, respLen);
} else if (fd == backendSocket) {
int new_fd = 0;
new_fd = accept(backendSocket, NULL, NULL);
if (new_fd < 0) {
warn("accept");
} else {
printf("Connection\n");
if (new_client(new_fd)) {
printf("Added client\n");
safe_fd_set(new_fd, &rfds_master, &max_fd);
}
}
} else if (get_client_index(fd) > -1) {
client_recv(fd);
}
}
}
} else {
timeout.tv_sec = 1;
timeout.tv_usec = 0;
}
}
ucart_vrpn_tracker_freeInstance(tracker);
safe_close_fd(zyboSocket, &quadSocketMutex);
closeLogFile();
return 0;
}
void sendStartPacket() {
unsigned char packet[8] = {0};
currMessageID++;
metadata_t metadata =
{
(char) BEGIN_CHAR,
0x04,
0x01,
0x01,
0
};
packet[0] = metadata.begin_char; // BEGIN //PACKET_START_BYTE;
packet[1] = metadata.msg_type; // UPDATE //'U'; // U for vrpn camera update, C for command
packet[2] = metadata.msg_subtype; // BEGIN UPDATE
packet[3] = (currMessageID & 0x000000ff); // MSG ID(1)
packet[4] = ((currMessageID >> 8) & 0x000000ff); // MSG ID(2)
packet[5] = 0; // DATALEN(1)
packet[6] = 0; // DATALEN(2)
char checksum = 0;
int i;
for(i=0; i < metadata.data_len + 7; i++)
checksum ^= packet[i];
packet[metadata.data_len + 7] = checksum; //PACKET_END_BYTE;
int status = writeQuad((char * ) packet, metadata.data_len + 8);
if (status != 8)
{
perror("Error sending start packet...\n");
keepRunning = 0;
}else
{
printf("Start packet successfuly sent...\n");
}
}
void sendVrpnPacket(struct ucart_vrpn_TrackerData *info) {
int pSize = sizeof(struct ucart_vrpn_TrackerData) + 8;
int n;
unsigned char packet[pSize];
currMessageID++;
packet[0] = 0xBE; // BEGIN //PACKET_START_BYTE;
packet[1] = 0x04; // UPDATE //'U'; // U for vrpn camera update, C for command
packet[2] = 0x00; // N/A
//TODO Figure out Packet ID with this new ucar_vrpn_TrackerData struct
packet[3] = (currMessageID & 0x000000ff); // MSG ID(1)
packet[4] = ((currMessageID >> 8) & 0x000000ff); // MSG ID(2)
packet[5] = (sizeof(struct ucart_vrpn_TrackerData) & 0x000000ff); // DATALEN(1)
packet[6] = ((sizeof(struct ucart_vrpn_TrackerData) >> 8) & 0x00000ff); // DATALEN(2)
memcpy(&packet[7], &info, sizeof(struct ucart_vrpn_TrackerData));
char checksum = 0;
int i;
for(i=0; i < pSize - 1; i++)
checksum ^= packet[i];
packet[pSize - 1] = checksum; //PACKET_END_BYTE;
n = writeQuad((char *) packet, pSize);
if(n < 0) {
perror("vrpnhandler: ERROR writing to socket");
keepRunning = 0;
}
struct timeval tstart;
gettimeofday(&tstart, NULL);
timeArr[currMessageID%MAX_HASH_SIZE] = tstart;
}
void getVRPNPacket(struct ucart_vrpn_TrackerData *td) {
int status;
if((status = ucart_vrpn_tracker_getData(tracker, td)) < 0)
{
perror("Error receiving VRPN data from tracker...");
keepRunning = 0;
}
}
void printVrpnData(struct ucart_vrpn_TrackerData * td) {
printf("FPS: %lf Pos (xyz): (%lf %lf %lf) Att (pry): (%lf %lf %lf)\n",
td->fps, td->x, td->y, td->z, td->pitch, td->roll, td->yaw);
}
int connectToZybo() {
int sock;
int status = 0;
if (getenv(NOQUAD_ENV)) {
return 0;
}
/* Use bluetooth by default */
if (!getenv(QUAD_WIFI_ENV)) {
printf("Using BT Settings\n");
struct sockaddr_rc addr;
// allocate a socket
sock = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
//set the connection params ie. who to connect to
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = (uint8_t) QUAD_BT_CHANNEL;
str2ba( QUAD_BT_ADDR, &addr.rc_bdaddr );
printf("Attempting to connect to zybo. Please be patient...\n");
// blocking call to connect to socket sock ie. zybo board
status = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
} else {
printf("Using WIFI settings\n");
struct sockaddr_in addr;
addr.sin_family = AF_INET;
/* Quick and Dirty */
if (getenv(QUAD_IP_ENV)) {
if (!inet_aton(getenv(QUAD_IP_ENV), &addr.sin_addr)) {
printf("Env var %s invalid IP %s\n",
QUAD_IP_ENV, getenv(QUAD_IP_ENV));
return -1;
}
} else {
if (!inet_aton(QUAD_IP_DEFAULT, &addr.sin_addr)) {
printf("Default IP %s is invalid\n",
QUAD_IP_DEFAULT);
return -1;
}
}
if (getenv(QUAD_PORT_ENV)) {
/* Quick 'n dirty, oh yeah! */
addr.sin_port = htons(atoi(getenv(QUAD_PORT_ENV)));
} else {
addr.sin_port = htons(QUAD_PORT_DEFAULT);
}
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0) {
perror("socket");
return -1;
}
printf("Connecting to Quad @ %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
status = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
}
// connection failed
if(status < 0)
{
close(sock);
perror("connect");
return -1;
}
else
{
// int result = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (int[]){1}, sizeof(int));
// printf("result = %d\n", result);
printf("connection successful!...\n");
return sock;
}
}
/* add a fd to fd_set, and update max_fd */
int safe_fd_set(int fd, fd_set* fds, int* max_fd) {
assert(max_fd != NULL);
FD_SET(fd, fds);
if (fd > *max_fd) {
*max_fd = fd;
}
return 0;
}
/* clear fd from fds, update max fd if needed */
int safe_fd_clr(int fd, fd_set* fds, int* max_fd) {
assert(max_fd != NULL);
FD_CLR(fd, fds);
if (fd == *max_fd) {
(*max_fd)--;
}
return 0;
}
static ssize_t writeQuad(const char * buf, size_t count) {
ssize_t retval;
if (getenv(NOQUAD_ENV)) {
return count;
}
if (pthread_mutex_lock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
//setsockopt(zyboSocket, IPPROTO_TCP, TCP_QUICKACK, (int[]){1}, sizeof(int));
retval = write(zyboSocket, buf, count);
if (pthread_mutex_unlock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
return retval;
}
static ssize_t readQuad(char * buf, size_t count) {
ssize_t retval;
if (pthread_mutex_lock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
retval = read(zyboSocket, buf, count);
//int result = setsockopt(zyboSocket, IPPROTO_TCP, TCP_QUICKACK, (int[]){1}, sizeof(int));
//printf("result = %d\n", result);
if (pthread_mutex_unlock(&quadSocketMutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
return retval;
}
static int new_client(int fd) {
ssize_t new_slot = -1;
for (ssize_t i = 0; i < MAX_CLIENTS; i++) {
if (client_fds[i] < 0) {
new_slot = i;
break;
}
}
if (new_slot == -1) {
warnx("Ran out of room! Consider increasing MAX_CLIENTS!");
return 0;
}
client_fds[new_slot] = fd;
client_buffers[new_slot][0] = '\0';
return 1;
}
static ssize_t get_client_index(int fd) {
for (ssize_t i = 0; i < MAX_CLIENTS; i++) {
if (client_fds[i] == fd) {
return i;
}
}
return -1;
}
static char * get_client_buffer(int fd) {
ssize_t slot = get_client_index(fd);
if (slot == -1) {
return NULL;
} else {
return client_buffers[slot];
}
}
static int * get_client_pend_responses(int fd) {
ssize_t slot = get_client_index(fd);
if (slot == -1) {
return NULL;
} else {
return client_pending_responses[slot];
}
}
static int clientAddPendResponses(int fd, unsigned char *packet) {
int *pendingResponses = get_client_pend_responses(fd);
int packetID = (packet[4] << 8) | (packet[3]);
for(int i = 0; i < CLIENT_MAX_PENDING_RESPONSES; i++) {
if(pendingResponses[i] == -1) {
pendingResponses[i] = packetID;
return i;
}
}
return -1;
}
static int remove_client(int fd) {
ssize_t slot = get_client_index(fd);
if(slot == -1)
return -1;
char *clientBuffer = get_client_buffer(fd);
if(clientBuffer == NULL)
return -1;
clientBuffer[0] = '\0';
int *pendingResponses = get_client_pend_responses(fd);
if(pendingResponses == NULL)
return -1;
for(int i = 0; i < CLIENT_MAX_PENDING_RESPONSES; i++) {
pendingResponses[i] = -1;
}
client_fds[slot] = -1;
return 0;
}
static void safe_close_fd(int fd, pthread_mutex_t *mutexLock) {
if (pthread_mutex_lock(mutexLock)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
close(fd);
if (pthread_mutex_unlock(mutexLock)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
}
static void client_recv(int fd) {
char * buffer;
ssize_t len_pre;
buffer = get_client_buffer(fd);
len_pre = strlen(buffer);
char * cursor;
cursor = buffer + len_pre;
ssize_t r;
r = read(fd, cursor, CLIENT_BUFFER_SIZE - len_pre - 1);
if (r < 0) {
warn("read (fd: %d)", fd);
}
buffer[len_pre + r] = '\0';
int index = 0;
/* Parse buffer and handle commands */
while (1) {
/* not using strtok because reasons */
size_t len = strlen(buffer);
ssize_t newline = -1;
for (size_t i = 0; i < len; i++) {
if (buffer[i] == '\n') {
newline = i;
break;
}
}
/* No newline found. End parsing */
if (newline == -1) {
break;
}
buffer[newline] = '\0';
printf("Client(%d) : '%s'\n",fd, buffer);
unsigned char * packet;
if(formatCommand(buffer, &packet) == -1) {
printf("Could not recognize command '%s'\n", buffer);
} else {
if(clientAddPendResponses(fd, packet) == -1) {
warnx("Ran out of room! Consider increasing CLIENT_MAX_PENDING_RESPONSES!");
} else {
int datalen = (packet[6] << 8) | (packet[5]);
writeQuad((char *) packet, datalen +8);
}
}
char * rest = &buffer[newline] + 1;
size_t restLen = (strlen(rest) == 0) ? 1 : strlen(rest);
/* Delete parsed data and move the rest to the left */
memmove(buffer, rest, restLen +1);
}
}
static int wasDisconnected(int fd) {
char buff;
if(recv(fd, &buff, 1, MSG_PEEK | MSG_DONTWAIT) == 0)
{
remove_client(fd);
safe_fd_clr(fd, &rfds_master, &max_fd);
printf("fd %d has disconnect and was removed\n", fd);
return 1;
}
return 0;
}
int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y) {
/* Perform the carry for the later subtraction by updating y. */
if (x->tv_usec < y->tv_usec) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
y->tv_usec -= 1000000 * nsec;
y->tv_sec += nsec;
}
if (x->tv_usec - y->tv_usec > 1000000) {
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
y->tv_usec += 1000000 * nsec;
y->tv_sec -= nsec;
}
/* Compute the time remaining to wait.
tv_usec is certainly positive. */
result->tv_sec = x->tv_sec - y->tv_sec;
result->tv_usec = x->tv_usec - y->tv_usec;
/* Return 1 if result is negative. */
return x->tv_sec < y->tv_sec;
}
void findTimeDiff(int respID) {
struct timeval result, tend;
gettimeofday(&tend, NULL);
timeval_subtract(&result, &tend, &timeArr[respID%MAX_HASH_SIZE]);
printf("elapsed time = %ld ms\n", result.tv_usec/1000);
// char tmp[8];
// snprintf(tmp, 8, "%ld \tms\n", result.tv_usec/1000);
// writeStringToLog(tmp);
}
#include "commands.h"
// TAKE THESE OUT WHEN IMPLEMENTING ON THE QUAD SIDE
float getFloat(unsigned char* str, int pos) {
union {
float f;
int i;
} x;
x.i = ((str[pos+3] << 24) | (str[pos+2] << 16) | (str[pos+1] << 8) | (str[pos]));
return x.f;
}
int getInt(unsigned char* str, int pos) {
int i = ((str[pos+3] << 24) | (str[pos+2] << 16) | (str[pos+1] << 8) | (str[pos]));
return i;
}
//------------------------------------------------
struct MessageType MessageTypes[MAX_TYPE] =
{
// DEBUG
{
// Message Type ID
0x00,
// Debug Subtypes
{
// NONE subtype
{
// ID
0x00,
// Command text
"debug",
// Type of the command data
stringType,
// Function pointer
&debug
}
}
},
// CALIBRATION
{
// Message Type ID
0x01,
// Calibration Subtypes
{
// yaw setpoint subtype
{
// ID
0x00,
// Command text
"setyaw",
// Type of the command data
floatType,
// Function pointer
&setyaw
},
// yaw p constant subtype
{
// ID
0x01,
// Command text
"setyawp",
// Type of the command data
floatType,
// Function pointer
&setyawp
},
// yaw d constant subtype
{
// ID
0x02,
// Command text
"setyawd",
// Type of the command data
floatType,
// Function pointer
&setyawd
},
// roll setpoint subtype
{
// ID
0x03,
// Command text
"setroll",
// Type of the command data
floatType,
// Function pointer
&setroll
},
// roll p constant subtype
{
// ID
0x04,
// Command text
"setrollp",
// Type of the command data
floatType,
// Function pointer
&setrollp
},
// roll d constant subtype
{
// ID
0x05,
// Command text
"setrolld",
// Type of the command data
floatType,
// Function pointer
&setrolld
},
// pitch setpoint subtype
{
// ID
0x06,
// Command text
"setpitch",
// Type of the command data
floatType,
// Function pointer
&setpitch
},
// pitch p constant subtype
{
// ID
0x07,
// Command text
"setpitchp",
// Type of the command data
floatType,
// Function pointer
&setpitchp
},
// pitch d constant subtype
{
// ID
0x08,
// Command text
"setpitchd",
// Type of the command data
floatType,
// Function pointer
&setpitchd
},
// throttle setpoint subtype
{
// ID
0x09,
// Command text
"setthrottle",
// Type of the command data
floatType,
// Function pointer
&setthrottle
},
// throttle p constant subtype
{
// ID
0x0A,
// Command text
"setthrottlep",
// Type of the command data
floatType,
// Function pointer
&setthrottlep
},
// throttle i constant subtype
{
// ID
0x0B,
// Command text
"setthrottlei",
// Type of the command data
floatType,
// Function pointer
&setthrottlei
},
// throttle d constant subtype
{
// ID
0x0C,
// Command text
"setthrottled",
// Type of the command data
floatType,
// Function pointer
&getthrottled
}
}
},
// REQUEST
{
// Message Type ID
0x02,
// Request Subtypes
{
// accelerometer subtype
{
// ID
0x00,
// Command text
"getaccel",
// Type of the command data
floatType,
// Function pointer
&getaccel
},
// gyroscope subtype
{
// ID
0x01,
// Command text
"getgyro",
// Type of the command data
floatType,
// Function pointer
&getgyro
},
// pitch angle subtype
{
// ID
0x02,
// Command text
"getpitchangle",
// Type of the command data
floatType,
// Function pointer
&getpitchangle
},
// roll angle subtype
{
// ID
0x03,
// Command text
"getrollangle",
// Type of the command data
floatType,
// Function pointer
&getrollangle
},
// get yaw setpoint subtype
{
// ID
0x04,
// Command text
"getyaw",
// Type of the command data
floatType,
// Function pointer
&setyaw
},
// get yaw p constant subtype
{
// ID
0x05,
// Command text
"getyawp",
// Type of the command data
floatType,
// Function pointer
&getyawp
},
// get yaw d constant subtype
{
// ID
0x06,
// Command text
"getyawd",
// Type of the command data
floatType,
// Function pointer
&getyawd
},
// get roll setpoint subtype
{
// ID
0x07,
// Command text
"getroll",
// Type of the command data
floatType,
// Function pointer
&getroll
},
// get roll p constant subtype
{
// ID
0x08,
// Command text
"getrollp",
// Type of the command data
floatType,
// Function pointer
&getrollp
},
// getroll d constant subtype
{
// ID
0x09,
// Command text
"getrolld",
// Type of the command data
floatType,
// Function pointer
&getrolld
},
// get pitch setpoint subtype
{
// ID
0x0A,
// Command text
"getpitch",
// Type of the command data
floatType,
// Function pointer
&getpitch
},
// get pitch p constant subtype
{
// ID
0x0B,
// Command text
"getpitchp",
// Type of the command data
floatType,
// Function pointer
&getpitchp
},
// get pitch d constant subtype
{
// ID
0x0C,
// Command text
"getpitchd",
// Type of the command data
floatType,
// Function pointer
&getpitchd
},
// get throttle setpoint subtype
{
// ID
0x0D,
// Command text
"getthrottle",
// Type of the command data
floatType,
// Function pointer
&getthrottle
},
// get throttle p constant subtype
{
// ID
0x0E,
// Command text
"getthrottlep",
// Type of the command data
floatType,
// Function pointer
&getthrottlep
},
// get throttle i constant subtype
{
// ID
0x0F,
// Command text
"getthrottlei",
// Type of the command data
floatType,
// Function pointer
&getthrottlei
},
// get throttle d constant subtype
{
// ID
0x10,
// Command text
"getthrottled",
// Type of the command data
floatType,
// Function pointer
&getthrottled
}
}
},
// RESPONSE
{
// Message Type ID
0x03,
// Response Subtypes
{
// accelerometer subtype
{
// ID
0x00,
// Command text
"respaccel",
// Type of the command data
floatType,
// Function pointer
&respaccel
},
// gyroscope subtype
{
// ID
0x01,
// Command text
"respgyro",
// Type of the command data
floatType,
// Function pointer
&respgyro
},
// pitch angle subtype
{
// ID
0x02,
// Command text
"resppitchangle",
// Type of the command data
floatType,
// Function pointer
&resppitchangle
},
// roll angle subtype
{
// ID
0x03,
// Command text
"resprollangle",
// Type of the command data
floatType,
// Function pointer
&resprollangle
}
}
},
// UPDATE
{
// Message Type ID
0x04,
// Update Subtypes
{
// NONE subtype
{
// ID
0x00,
// Command text
"update",
// Type of the command data
stringType,
// Function pointer
&update
}
}
},
// LOG
{
// Message Type ID
0x05,
// Log Subtypes
{
// NONE subtype
{
// ID
0x00,
// Command text
"log",
// Type of the command data
stringType,
// Function pointer
&logdata
},
// Response subtype
{
// ID
0x01,
// Command text
"response",
// Type of the command data
stringType,
// Function pointer
&response
}
}
},
};
int debug(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for debug\n");
return 0;
}
int update(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
unsigned char update[28];
memcpy(update, ((float *)packet), 28);
int packetId = getInt(update, 0);
float y_pos = getFloat(update, 4);
float x_pos = getFloat(update, 8);
float alt_pos = getFloat(update, 12);
float roll = getFloat(update, 16);
float pitch = getFloat(update, 20);
float yaw = getFloat(update, 24);
structs->log_struct.currentQuadPosition.packetId = packetId;
structs->log_struct.currentQuadPosition.y_pos = y_pos;
structs->log_struct.currentQuadPosition.x_pos = x_pos;
structs->log_struct.currentQuadPosition.alt_pos = alt_pos;
structs->log_struct.currentQuadPosition.roll = roll;
structs->log_struct.currentQuadPosition.pitch = pitch;
structs->log_struct.currentQuadPosition.yaw = yaw;
printf("QUAD: VRPN Packet:");
printf("Packet ID: %d\n", packetId);
printf("Y Position: %f\n", y_pos);
printf("X Position: %f\n", x_pos);
printf("Altitude Position: %f\n", alt_pos);
printf("Roll: %f\n", roll);
printf("Pitch: %f\n", pitch);
printf("Yaw: %f\n", yaw);
printf("function for update\n");
return 0;
}
// Why is this here?
// This should be on the ground station side
int logdata(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("Logging: %s\n", packet);
return 0;
}
int response(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("This is the response: %s\n", packet);
return 0;
}
// ------------------------------------------------------------------
int setyaw(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
printf("%f\n", value);
structs->setpoint_struct.desiredQuadPosition.yaw = value;
printf("function for setyaw: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw);
return 0;
}
int setyawp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.yaw_angle_pid.Kp = value;
printf("function for setyawp: %f\n", structs->parameter_struct.yaw_angle_pid.Kp);
return 0;
}
int setyawd(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.yaw_angle_pid.Kd = value;
printf("function for setyawd: %f\n", structs->parameter_struct.yaw_angle_pid.Kd);
return 0;
}
int setroll(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.roll = value;
printf("function for setroll: %f\n", structs->setpoint_struct.desiredQuadPosition.roll);
return 0;
}
int setrollp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_y_pid.Kp = value;
printf("function for setrollp: %f\n", structs->parameter_struct.local_y_pid.Kp);
return 0;
}
int setrolld(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_y_pid.Kd = value;
printf("function for setrolld: %f\n", structs->parameter_struct.local_y_pid.Kd);
return 0;
}
int setpitch(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.pitch = value;
printf("function for setpitch: %f\n", structs->setpoint_struct.desiredQuadPosition.pitch);
return 0;
}
int setpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_x_pid.Kp = value;
printf("function for setpitchp: %f\n", structs->parameter_struct.local_x_pid.Kp);
return 0;
}
int setpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_x_pid.Kd = value;
printf("function for setpitchd: %f\n", structs->parameter_struct.local_x_pid.Kd);
return 0;
}
// ------------------------------------------------------------
// These should be renamed to altitude!
int setthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.alt_pos = value;
printf("function for setthrottle: %f\n", structs->setpoint_struct.desiredQuadPosition.alt_pos);
return 0;
}
int setthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Kp = value;
printf("function for setthrottlep: %f\n", structs->parameter_struct.alt_pid.Kp);
return 0;
}
int setthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Ki = value;
printf("function for setthrottlei: %f\n", structs->parameter_struct.alt_pid.Ki);
return 0;
}
int setthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
float value;
memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Kd = value;
printf("function for setthrottled: %f\n", structs->parameter_struct.alt_pid.Kd);
return 0;
}
int getyaw(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getyawp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getyawd(unsigned char *packet, int dataLen, modular_structs_t *structs) {
return 0;
}
int getroll(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getrollp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getrolld(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitch(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
// These should be renamed to altitude!
// ------------------------------------------------------------
int getaccel(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for getaccel\n");
return 0;
}
int respgyro(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for respgyro\n");
return 0;
}
int resppitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for resppitchangle\n");
return 0;
}
int resprollangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for resprollangle\n");
return 0;
}
int getgyro(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for getgyro\n");
return 0;
}
int getpitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for getpitchangle\n");
return 0;
}
int getrollangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for getrollangle\n");
return 0;
}
int respaccel(unsigned char *packet, int dataLen, modular_structs_t *structs)
{
printf("function for respaccel\n");
return 0;
}
\ No newline at end of file
#ifndef _COMMANDS_H
#define _COMMANDS_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "type_def.h"
// ----------------------
// Helper stuff
#define MAX_TYPE 6
#define MAX_SUBTYPE 100
enum Message{
BEGIN_CHAR = 0xBE,
END_CHAR = 0xED
};
// This should also have double to avoid confusion with float values.
enum DataType
{
floatType,
intType,
stringType
};
// MESSAGE SUBTYPES
struct MessageSubtype{
char ID;
char cmdText[100];
char cmdDataType;
int (*functionPtr)(unsigned char *command, int dataLen, modular_structs_t *structs);
};
// MESSAGE TYPES
struct MessageType{
char ID;
struct MessageSubtype subtypes[MAX_SUBTYPE];
};
int debug(unsigned char *c, int dataLen, modular_structs_t *structs);
int update(unsigned char *c, int dataLen, modular_structs_t *structs);
int logdata(unsigned char *c, int dataLen, modular_structs_t *structs);
int response(unsigned char *packet, int dataLen, modular_structs_t *structs);
int setyaw(unsigned char *c, int dataLen, modular_structs_t *structs);
int setyawp(unsigned char *c, int dataLen, modular_structs_t *structs);
int setyawd(unsigned char *c, int dataLen, modular_structs_t *structs);
int setroll(unsigned char *c, int dataLen, modular_structs_t *structs);
int setrollp(unsigned char *c, int dataLen, modular_structs_t *structs);
int setrolld(unsigned char *c, int dataLen, modular_structs_t *structs);
int setpitch(unsigned char *c, int dataLen, modular_structs_t *structs);
int setpitchp(unsigned char *c, int dataLen, modular_structs_t *structs);
int setpitchd(unsigned char *c, int dataLen, modular_structs_t *structs);
int setthrottle(unsigned char *c, int dataLen, modular_structs_t *structs);
int setthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs);
int setthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs);
int setthrottled(unsigned char *c, int dataLen, modular_structs_t *structs);
int getyaw(unsigned char *c, int dataLen, modular_structs_t *structs);
int getyawp(unsigned char *c, int dataLen, modular_structs_t *structs);
int getyawd(unsigned char *c, int dataLen, modular_structs_t *structs);
int getroll(unsigned char *c, int dataLen, modular_structs_t *structs);
int getrollp(unsigned char *c, int dataLen, modular_structs_t *structs);
int getrolld(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitch(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitchp(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitchd(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottled(unsigned char *c, int dataLen, modular_structs_t *structs);
int getaccel(unsigned char *c, int dataLen, modular_structs_t *structs);
int respgyro(unsigned char *c, int dataLen, modular_structs_t *structs);
int resppitchangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int resprollangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getgyro(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitchangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getrollangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int respaccel(unsigned char *c, int dataLen, modular_structs_t *structs);
float getFloat(unsigned char* str, int pos);
int getInt(unsigned char* str, int pos);
// TODO add in string to be read from the command line when sending a subtype of message
extern struct MessageType MessageTypes[MAX_TYPE];
#endif
\ No newline at end of file
......@@ -52,84 +52,95 @@ int checkInt(char *intString, int *value) {
//--------------------------------
// Formatting commands from ground station CLI
int formatCommand(unsigned char *command, unsigned char **formattedCommand) {
//command[strlen((char *)command) - 1] = 0;
tokenList_t tokens = tokenize((char *)command);
int formatCommand(char *command, unsigned char **formattedCommand) {
//fprintf(stderr, "length = %li , received '%s'\n", strlen(command), command);
char cmd[strlen(command)];
strncpy(cmd, command, strlen(command));
cmd[strlen(command)] = '\0';
tokenList_t tokens = tokenize(cmd);
float floatValue = 0.0;
int intValue = 0;
int valid;
metadata_t metadata = {};
metadata_t metadata;
// ----------------------------------------------
if(tokens.numTokens > 1) {
for(int cmdIndex = 0; cmdIndex < NUM_COMMANDS; ++cmdIndex)
if(tokens.numTokens > 0) {
for(int type = 0; type < MAX_TYPE; type++)
{
if(strcmp(tokens.tokens[0], registeredCommands[cmdIndex].commandText) == 0)
for(int subtype = 0; subtype < MAX_SUBTYPE; subtype++)
{
switch (registeredCommands[cmdIndex].dataType)
if(strcmp(tokens.tokens[0], MessageTypes[type].subtypes[subtype].cmdText) == 0)
{
// Validate the float input
case floatType:
valid = checkFloat(tokens.tokens[1], &floatValue);
if(!valid) {
return -1;
}
printf("%f, %s\n", floatValue, tokens.tokens[1]);
metadata.begin_char = BEGIN_CHAR;
metadata.msg_type = registeredCommands[cmdIndex].ID;
metadata.msg_subtype = registeredCommands[cmdIndex].subID;
metadata.msg_id = msgNum++;
metadata.data_len = sizeof(floatValue);
formatPacket(&metadata, &floatValue, formattedCommand);
break;
// Validate the integer input
case intType:
valid = checkInt(tokens.tokens[1], &intValue);
if(!valid) {
return -1;
}
metadata.begin_char = BEGIN_CHAR;
metadata.msg_type = registeredCommands[cmdIndex].ID;
metadata.msg_subtype = registeredCommands[cmdIndex].subID;
metadata.msg_id = msgNum++;
metadata.data_len = sizeof(intValue);
formatPacket(&metadata, &intValue, formattedCommand);
break;
printf("Sending\n\ttype: %d, \n\tsubtype: %d\n\tcommand: %s\n", type, subtype, MessageTypes[type].subtypes[subtype].cmdText);
// Validate the string input (doesn't need to happen)
case stringType:
metadata.begin_char = BEGIN_CHAR;
metadata.msg_type = registeredCommands[cmdIndex].ID;
metadata.msg_subtype = registeredCommands[cmdIndex].subID;
metadata.msg_id = msgNum++;
metadata.data_len = strlen(tokens.tokens[1]);
// Make sure the second token is the right type
switch (MessageTypes[type].subtypes[subtype].cmdDataType)
{
// Validate the float input
case floatType:
metadata.begin_char = (char) BEGIN_CHAR;
metadata.msg_type = MessageTypes[type].ID;
metadata.msg_subtype = MessageTypes[type].subtypes[subtype].ID;
if(MessageTypes[type].ID == 0x01) {
valid = checkFloat(tokens.tokens[1], &floatValue);
if(!valid) {
return -1;
}
metadata.data_len = sizeof(floatValue);
} else {
metadata.data_len = 0;
}
metadata.msg_id = msgNum++;
formatPacket(&metadata, &floatValue, formattedCommand);
break;
formatPacket(&metadata, &tokens.tokens[1], formattedCommand);
// Validate the integer input
case intType:
metadata.begin_char = (char) BEGIN_CHAR;
metadata.msg_type = MessageTypes[type].ID;
metadata.msg_subtype = MessageTypes[type].subtypes[subtype].ID;
if(MessageTypes[type].ID == 0x01) {
valid = checkInt(tokens.tokens[1], &intValue);
if(!valid) {
return -1;
}
metadata.data_len = sizeof(intValue);
} else {
metadata.data_len = 0;
}
metadata.msg_id = msgNum++;
formatPacket(&metadata, &intValue, formattedCommand);
break;
break;
default:
return -1;
// Validate the string input (doesn't need to happen)
case stringType:
metadata.begin_char = (char) BEGIN_CHAR;
metadata.msg_type = MessageTypes[type].ID;
metadata.msg_subtype = MessageTypes[type].subtypes[subtype].ID;
metadata.msg_id = msgNum++;
metadata.data_len = strlen(tokens.tokens[1]);
formatPacket(&metadata, &tokens.tokens[1], formattedCommand);
break;
default:
return -1;
}
return 0;
}
return 0;
}
}
}
// Only gets here if the command does not exist
return -1;
return -1;
}
// QUAD & Ground Station
// Format the log data from log_message
//int formatData(unsigned char *log_msg, unsigned char *formattedCommand)
......@@ -154,7 +165,8 @@ int formatPacket(metadata_t *metadata, void *data, unsigned char **formattedComm
(*formattedCommand)[2] = metadata->msg_subtype;
//Msg id (msgNum is 2 bytes)
(*formattedCommand)[3] = metadata->msg_id;
(*formattedCommand)[3] = (metadata->msg_id & 0x000000ff);
(*formattedCommand)[4] = ((metadata->msg_id >> 8) & 0x000000ff);
// Data length and data - bytes 5&6 for len, 7+ for data
(*formattedCommand)[5] = metadata->data_len & 0x000000ff;
......@@ -232,7 +244,7 @@ int parse_packet(unsigned char * packet, unsigned char ** data, metadata_t * met
// QUAD & Ground Station
// Process the command received
int processCommand(unsigned char *packet, unsigned int cmdIndex) {
int processCommand(unsigned char *packet, modular_structs_t *structs) {
int validPacket;
unsigned char *data;
metadata_t metadata;
......@@ -245,11 +257,11 @@ int processCommand(unsigned char *packet, unsigned int cmdIndex) {
if(metadata.data_len >= 0) {
// Call the appropriate subtype function
(* (registeredCommands[cmdIndex].functionPtr))(data, metadata.data_len);
(* (MessageTypes[(unsigned char)metadata.msg_type].subtypes[(unsigned char)metadata.msg_subtype].functionPtr))(data, metadata.data_len, structs);
return 0;
}
// Only gets here if there is an error
return -1;
}
}
\ No newline at end of file
......@@ -10,12 +10,10 @@
tokenList_t tokenize(char* cmd);
int checkFloat(char *floatString, float *value);
int checkInt(char *intString, int *value);
int formatCommand(unsigned char *command, unsigned char **formattedCommand);
int formatCommand(char *command, unsigned char **formattedCommand);
int formatPacket(metadata_t *metadata, void *data, unsigned char **formattedCommand);
int parse_packet(unsigned char * packet, unsigned char ** data, metadata_t * meta_data);
int processCommand(unsigned char *command, unsigned int cmdIndex);
int processCommand(unsigned char *command, modular_structs_t *structs);
int logData(unsigned char *log_msg, unsigned char *formattedCommand);
float getFloat(unsigned char* str, int pos);
int getInt(unsigned char* str, int pos);
#endif
#endif
\ No newline at end of file
#ifndef __CONFIG_H
#define __CONFIG_H
#define DEFAULT_SOCKET "/var/run/ucart.socket"
#define SOCKET_ENV "UCART_SOCKET"
#define NOQUAD_ENV "UCART_NO_QUAD"
#define NOVRPN_ENV "UCART_NO_VRPN"
// If you are planning on using any of these env vars and you have
// exported them with normal user rights. You will need to run the
// backend with sudo elevation and with the --preserve-env flag or -E
#define QUAD_WIFI_ENV "UCART_USE_WIFI"
#define QUAD_IP_ENV "UCART_QUAD_IP"
#define QUAD_IP_DEFAULT "192.168.4.1"
#define QUAD_PORT_ENV "UCART_QUAD_PORT"
#define QUAD_PORT_DEFAULT 8080
#endif
......@@ -4,21 +4,30 @@
*/
#include "logger.h"
#include <stdio.h>
#include <err.h>
#include <pthread.h>
int quadlog_file;
static FILE * quadlog_file = NULL;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int createLogFile(int argc, char* argv)
{
char log_file[300] = {'l', 'o', 'g','s', '/'};
if (quadlog_file != NULL) {
return -1;
}
if (pthread_mutex_lock(&mutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
char log_file[300];
strcpy(log_file, "logs/");
if(argc >= 2)
{
strcat(log_file, argv);
strncat(log_file, argv, 294);
printf("Creating log file '%s'...\n",log_file);
quadlog_file = open(log_file, O_WRONLY | O_CREAT, 0666);
return quadlog_file;
}
else
{
quadlog_file = fopen(log_file, "a");
} else {
time_t rawtime;
char timestr [30];
time(&rawtime);
......@@ -26,7 +35,7 @@ int createLogFile(int argc, char* argv)
// Lets convert space to _ in
char *p = timestr;
int i = 0;
size_t i = 0;
while(i < strlen(timestr))
{
if (*p == ' ')
......@@ -40,18 +49,60 @@ int createLogFile(int argc, char* argv)
strncat(log_file, timestr, strlen(timestr) -1 );
strcat(log_file, ".txt");
printf("Creating log file '%s'...\n",log_file);
quadlog_file = open(log_file, O_WRONLY | O_CREAT, 0666);
return quadlog_file;
quadlog_file = fopen(log_file, "a");
}
if (pthread_mutex_unlock(&mutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
return 0;
}
int updateLogFile(const struct ucart_vrpn_TrackerData * td)
{
return dprintf(quadlog_file, "FPS: %lf Pos (xyz): (%lf %lf %lf) Att (pry): (%lf %lf %lf)\n",
int retval;
if (pthread_mutex_lock(&mutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
retval = fprintf(quadlog_file,
"FPS: %lf Pos (xyz): (%lf %lf %lf) Att (pry): (%lf %lf %lf)\n",
td->fps, td->x, td->y, td->z, td->pitch, td->roll, td->yaw);
if (pthread_mutex_unlock(&mutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
return retval;
}
int writeStringToLog(const char * string)
{
return dprintf(quadlog_file, "%s", string);
int retval;
if (pthread_mutex_lock(&mutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
retval = fprintf(quadlog_file, "%s", string);
if (pthread_mutex_unlock(&mutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
return retval;
}
void closeLogFile(void)
{
if (pthread_mutex_lock(&mutex)) {
err(-2, "pthrtead_mutex_lock (%s:%d):", __FILE__, __LINE__);
}
fclose(quadlog_file);
if (pthread_mutex_unlock(&mutex)) {
err(-2, "pthrtead_mutex_unlock (%s:%d):", __FILE__, __LINE__);
}
}
......@@ -15,6 +15,7 @@
int createLogFile(int, char*);
int writeStringToLog(const char*);
int updateLogFile(const struct ucart_vrpn_TrackerData* );
void closeLogFile();
#endif
\ No newline at end of file
#endif