iOS Tutorial Monitor the device attitude (orientation) and acceleration with Motion object

Erel

Administrator
Staff member
Licensed User
iPhone library v1.30 includes a new type named Motion. With this object you can monitor the device orientation and acceleration (similar to B4A PhoneSensors).

The Motion object doesn't raise events. Instead you should use a timer to get the current values.

upload_2015-1-12_17-3-32.png


The values returned from Motion.GetAttitude are measured in radians.
The values returned from Motion.GetUserAcceleration are measured in G units (9.81 m / s^2).
 

Attachments

ilan

Expert
Licensed User
try the motion example but get this error while complie:

Parsing code. 0.00
Compiling code. 0.05
Compiling layouts code. 0.02
Compiling debugger engine code. 0.78
Building Xcode project 0.03
Sending data to remote compiler. Error
B4i line: 33
mot.Initialize
no visible @interface for 'B4ICommon' declares the selector 'Initialize'

Out: Build settings from command line:
ARCHS = armv7
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload
OTHER_CODE_SIGN_FLAGS = --keychain ilan
PRODUCT_NAME = motion
PROVISIONING_PROFILE = 2d6b68bf-8fe8-47c1-93ba-072557c5cee5

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-target-headers.hmap
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion.hmap
/bin/mkdir -p /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/motion.LinkFileList
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-non-framework-target-headers.hmap
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-project-headers.hmap
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-own-target-headers.hmap
write-file /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-generated-files.hmap

Create product structure
/bin/mkdir -p /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/motion.app

ProcessInfoPlistFile Payload/motion.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/B4iProject-Info.plist -genpkginfo /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/motion.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -o /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/motion.app/Info.plist

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o B4iProject/b4i_main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-generated-files.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-own-target-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-target-headers.hmap -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-project-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload -F../../Libs -MMD -MT dependencies -MF /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.d --serialize-diagnostics /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.dia -c /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m -o /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:2:
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.h:12:22: error: unknown type name 'B4IMotion'; did you mean 'B4ICommon'?
@property (nonatomic)B4IMotion* _mot;
^~~~~~~~~
B4ICommon
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:2:
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.h:1:
/Users/eliezerilantetruashvili/Downloads/macserver/Libs/iCore.h:348:12: note: 'B4ICommon' declared here
@interface B4ICommon: NSObject
^
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:41:12: error: no visible @interface for 'B4ICommon' declares the selector 'Initialize'
[self._mot Initialize];
~~~~~~~~~ ^~~~~~~~~~
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:67:12: error: no visible @interface for 'B4ICommon' declares the selector 'Start'
[self._mot Start];
~~~~~~~~~ ^~~~~
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:74:12: error: no visible @interface for 'B4ICommon' declares the selector 'Stop'
[self._mot Stop];
~~~~~~~~~ ^~~~
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:105:24: error: no visible @interface for 'B4ICommon' declares the selector 'GetAttitude'
_attitude = [self._mot GetAttitude];
~~~~~~~~~ ^~~~~~~~~~~
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.m:108:28: error: no visible @interface for 'B4ICommon' declares the selector 'GetUserAcceleration'
_acceleration = [self._mot GetUserAcceleration];
~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
6 errors generated.

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o B4iProject/main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-generated-files.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-own-target-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-target-headers.hmap -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-project-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload -F../../Libs -MMD -MT dependencies -MF /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.d --serialize-diagnostics /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.dia -c /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/main.m -o /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_class1.o B4iProject/b4i_class1.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-generated-files.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-own-target-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-target-headers.hmap -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-project-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload -F../../Libs -MMD -MT dependencies -MF /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_class1.d --serialize-diagnostics /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_class1.dia -c /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_class1.m -o /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_class1.o
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_class1.m:3:
/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_main.h:12:22: error: unknown type name 'B4IMotion'; did you mean 'B4ICommon'?
@property (nonatomic)B4IMotion* _mot;
^~~~~~~~~
B4ICommon
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_class1.m:2:
In file included from /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/b4i_class1.h:1:
/Users/eliezerilantetruashvili/Downloads/macserver/Libs/iCore.h:348:12: note: 'B4ICommon' declared here
@interface B4ICommon: NSObject
^
1 error generated.

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_1.o B4iProject/LS_1.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-generated-files.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-own-target-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-all-target-headers.hmap -iquote /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/motion-project-headers.hmap -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/Payload -F../../Libs -MMD -MT dependencies -MF /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_1.d --serialize-diagnostics /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_1.dia -c /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/B4iProject/LS_1.m -o /Users/eliezerilantetruashvili/Downloads/macserver/UploadedProjects/ilan/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_1.o


Error: ** BUILD FAILED **


The following build commands failed:
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o B4iProject/b4i_main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_class1.o B4iProject/b4i_class1.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
 

ilan

Expert
Licensed User
this is what i get:

B4i Build Server
Build server is running.
Version: 1.5
Server time: 09:57:42
Mac SSL Key
Key IP: 192.168.2.1
SSL port: 51042
h files
  • iAd: 1.00
  • iAdMob: 1.10
  • iArchiver: 1.01
  • iBarcode: 1.03
  • iBLE: 1.10
  • iCore: 1.78
  • iDebug: 1.60
  • iDesigner: 1.20
  • iDropboxSync: 1.00
  • iEncryption: 1.02
  • iGoogleMaps: 1.00
  • iHttp: 1.01
  • iHUD: 1.00
  • iJSON: 1.0
  • iLeadbolt: 1.00
  • iLocation: 1.00
  • iMedia: 1.10
  • iNet: 1.01
  • iNetwork: 1.10
  • iPhone: 1.20
  • iRandomAccessFile: 1.20
  • iSideMenu: 1.00
  • iSQL: 1.01
  • iStringUtils: 1.00
  • iWebSocket: 1.00
  • iXmlBuilder: 1.00
  • iXmlSax: 1.00
a files
  • libCore, size=2206664, modified=01/07/2015 14:01:42
  • libGoogleAdMobAds, size=13302324, modified=09/16/2014 16:57:50
  • libiAd, size=25928, modified=01/19/2015 08:24:36
  • libiAdMob, size=46464, modified=11/23/2014 14:44:32
  • libiArchiver, size=155824, modified=12/15/2014 15:21:18
  • libiBarcode, size=103200, modified=12/11/2014 07:12:00
  • libiBLE, size=82288, modified=11/23/2014 15:16:40
  • libiDebug, size=705024, modified=01/05/2015 15:05:50
  • libiDesigner, size=570768, modified=01/06/2015 14:26:56
  • libiDropboxSync, size=56408, modified=11/17/2014 08:07:32
  • libiEncryption, size=46664, modified=01/06/2015 10:33:32
  • libiGoogleMaps, size=107240, modified=10/30/2014 13:42:54
  • libiHttp, size=84712, modified=01/07/2015 07:56:56
  • libiHUD, size=192376, modified=10/30/2014 13:44:26
  • libiJSON, size=36576, modified=10/30/2014 13:44:56
  • libiLeadbolt, size=7744, modified=12/01/2014 12:35:54
  • libiLocation, size=50384, modified=11/16/2014 06:44:00
  • libiMedia, size=155752, modified=12/28/2014 13:50:12
  • libiNet, size=139072, modified=12/30/2014 09:24:42
  • libiNetwork, size=179168, modified=12/15/2014 09:16:38
  • libiPhone, size=138080, modified=12/30/2014 10:53:52
  • libiRandomAccessFile, size=249928, modified=12/16/2014 15:21:22
  • libiSideMenu, size=338504, modified=10/30/2014 13:50:00
  • libiSQL, size=243848, modified=12/23/2014 13:47:28
  • libiStringUtils, size=38168, modified=10/30/2014 13:50:50
  • libiWebSocket, size=265616, modified=01/06/2015 07:49:40
  • libiXmlBuilder, size=103920, modified=12/28/2014 14:46:22
  • libiXmlSax, size=42528, modified=10/30/2014 13:51:04
iphonv.png


so i guess i need to update all libs on my macserver...
thank you erel...
 

MikeGilligan

New Member
Licensed User
iPhone library v1.30 includes a new type named Motion. With this object you can monitor the device orientation and acceleration (similar to B4A PhoneSensors).

The Motion object doesn't raise events. Instead you should use a timer to get the current values.

View attachment 31112

The values returned from Motion.GetAttitude are measured in radians.
The values returned from Motion.GetUserAcceleration are measured in G units (9.81 m / s^2).
Is it possible to get the GravityAcceleration? UserAcceleration plus the gravity component.
 

mouhaddab

Member
Licensed User
Hi erel,

i have a problem with motion GetAttitude my code is :

Sub Timer1_Tick
Dim attitude() As Double = tel_or.GetAttitude
X=NumberFormat(attitude(0) * 180 / cPI, 1, 2) & Chr(0xB0)
Log(X)
End Sub

but x cross indefinitely, although I not move my iphone !!!!

tnks
 

Erel

Administrator
Staff member
Licensed User
1. Please use [code]code here...[/code] tags when posting code.
2. Don't limit your questions to a single member.
3. It is recommended to start a new thread for a new question.

When I test it here it eventually stabilizes.
Make sure that there are no electronic devices near the phone.
The values you see come directly from the device.
 

Yvon Steinthal

Active Member
Licensed User
Hello,

Trying to do this properly but all i see are 0 degrees in my logs... is there something to set before running the timer?

My code:

B4X:
mot.Initialize
   tmrAttitude.Initialize("tmrAttitude",500)
   tmrAttitude.Enabled = True

End Sub

Sub tmrAttitude_Tick
  
   Dim attitude() As Double = mot.GetAttitude
   Dim Acceleration() As Double = mot.GetUserAcceleration
   Log("yaw: " & NumberFormat(attitude(0) * 180 / cPI, 1, 2) & Chr(0xB0))
   Log("pitch: " &  NumberFormat(attitude(1) * 180 / cPI, 1, 2) & Chr(0xB0))
   Log("roll: " &  NumberFormat(attitude(2) * 180 / cPI, 1, 2) & Chr(0xB0))

End Sub
All i want is to catch if the phone is in landscape or portrait mode while the user takes a picture...

Thanks.

Y.


EDIT: Forgot the mot.start and mot.stop ... sorry bout that
 
Last edited:

Andris

Active Member
Licensed User
I'm running the first example on an iPhone 6 and I notice that whenever I Stop and then Start, whatever the Yaw value happens to be, it then gets reset to 0.0. Is this normal behavior for this example? If not, it might validate some some problems I suspect with this iPhone.
 

Yvon Steinthal

Active Member
Licensed User
I've had similar problems that i was never able to correct.
Apparently all values are compared to the position you have when "start" is launched.
I may be wrong but i've had exacly this issue and could not use the motion library because of it....
It may be just me and my comprehension of the library... but i can only agree with your statement so far....
 

Andris

Active Member
Licensed User
I've had similar problems that i was never able to correct.
Apparently all values are compared to the position you have when "start" is launched.
I may be wrong but i've had exacly this issue and could not use the motion library because of it....
It may be just me and my comprehension of the library... but i can only agree with your statement so far....
Thanks for responding. I've been going crazy trying to convert the compass code of a B4A app to B4i and simply used yaw just like it is in the example here, which is pretty much like it's done in B4A. Seeing erratic behavior, I came back to the basics here and discovered that it resets.

I have a feeling that our answer is contained here, in setting the CMAttitudeReferenceFrame. In iOS you can set a reference frame for the magnetic sensor and accelerometer. You can see that it can be set to one of four values:

CMAttitudeReferenceFrameXArbitraryZVertical
Describes a reference frame in which the Z axis is vertical and the X axis points in an arbitrary direction in the horizontal plane.

CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
Describes the same reference frame as CMAttitudeReferenceFrameXArbitraryZVertical except that the magnetometer, when available and calibrated, is used to improve long-term yaw accuracy. Using this constant instead of CMAttitudeReferenceFrameXArbitraryZVertical results in increased CPU usage.

CMAttitudeReferenceFrameXMagneticNorthZVertical
Describes a reference frame in which the Z axis is vertical and the X axis points toward magnetic north. Note that using this reference frame may require device movement to calibrate the magnetometer.

CMAttitudeReferenceFrameXTrueNorthZVertical
Describes a reference frame in which the Z axis is vertical and the X axis points toward true north. Note that using this reference frame may require device movement to calibrate the magnetometer. It also requires the location to be available in order to calculate the difference between magnetic and true north.
I'll bet we have to specifically set it to one of the last two settings and that will solve our problem. Do you know how to do that with OBJC? Maybe Erel will jump in .... ;)
 

Andris

Active Member
Licensed User
I have looked at that link and tried to do the same to get yaw, pitch and roll instead, and around the CMAttitudeReferenceFrameXMagneticNorthZVertical reference frame. My OBJC code fails (won't compile after upload) and I can't figure out why (not enough OBJC experience). Here it is:
B4X:
#if OBJC

- (void)startMotion:(CMMotionManager*)manager {
   [manager startDeviceMotionUpdatesUsingReferenceFrame: CMAttitudeReferenceFrameXMagneticNorthZVertical];
}

- (NSArray*) GetCorrectedAttitude:(CMMotionManager*)manager {
   CMAttitude catt = manager.deviceMotion.attitude;
   return @[@(catt.yaw), @(catt.roll), @(catt.pitch)];
}
#End If
Am I on the right track?
 
Top