完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,转换加速度计和磁力计的输出与俯仰,滚转和偏航角度有关。我正在尝试使用DT0058的方程式。我写了下面的函数。
void newPitchRollYaw(float * const acc,float * const mag) { float roll = atan2(acc [LSM303AGR_Y],acc [LSM303AGR_Z] + acc [LSM303AGR_X] * 0.01); float pitch = atan(-acc [LSM303AGR_X] /(acc [LSM303AGR_Y] * sin(roll)+ acc [LSM303AGR_Z] * cos(roll))); float By2 = mag [LSM303AGR_Z] * sin(roll) - mag [LSM303AGR_Y ] * cos(roll); float Bz2 = mag [LSM303AGR_Y] * sin(roll)+ mag [LSM303AGR_Z] * cos(roll); float Bx3 = mag [LSM303AGR_X] * cos(pitch)+ Bz2 * sin(pitch); float yaw = atan2(By2,Bx3); float factor = LSM303AGR_180_DEGREES / LSM303AGR_PI; log_PushLine(e_logLevel_Info,'pitch:%f,roll:%f,yaw:%f',pitch * factor,roll * factor,yaw * factor); float Qw = cos(roll / 2)* cos(pitch / 2)* cos(roll / 2)+ sin(roll / 2)* sin(pitch / 2)* sin(roll / 2); float Qx = sin(roll / 2)* cos(pitch / 2)* cos(roll / 2) - cos(roll / 2)* sin(pitch / 2)* sin(roll / 2); float Qy = cos(roll / 2)* sin(pitch / 2)* cos(roll / 2)+ sin(roll / 2)* cos(pitch / 2)* sin(roll / 2); float Qz = cos(roll / 2)* cos(pitch / 2)* sin(roll / 2) - sin(roll / 2)* sin(pitch / 2)* cos(roll / 2); log_PushLine(e_logLevel_Info,' qw:%f,qx:%f,qy:%f,qz:%f',Qw * factor,Qx * factor,Qy * factor,Qz * factor); } 当罗盘围绕z轴旋转时,它会改变偏航值但非常不规则,例如从130到40然后形成-100到-30等。当我仅改变俯仰或滚转值时,偏航也会改变。我认为这不正确,因为设备的方向没有改变。例如,如果俯仰是1,则偏航是-50,如果俯仰是14偏航= -120。我不明白这些结果。我认为俯仰和滚动是正确的。 我在正常模式下使用加速度计,满量程默认值(+ - 2g),odr = 400 Hz,连续模式下的magetometer,100Hz。我不使用中断,只检查可用的数据。 谢谢你的所有答案。 以上来自于谷歌翻译 以下为原文 Hello, I have a problem with conversion accelerometer's and magnetometer's output to pitch, roll and yaw angles. I am trying to use equations from DT0058. I wrote function like below. void newPitchRollYaw(float* const acc, float* const mag) { float roll = atan2(acc[LSM303AGR_Y], acc[LSM303AGR_Z] + acc[LSM303AGR_X] * 0.01); float pitch = atan(-acc[LSM303AGR_X] / (acc[LSM303AGR_Y] * sin(roll) + acc[LSM303AGR_Z] * cos(roll)));float By2 = mag[LSM303AGR_Z] * sin(roll) - mag[LSM303AGR_Y] * cos(roll); float Bz2 = mag[LSM303AGR_Y] * sin(roll) + mag[LSM303AGR_Z] * cos(roll); float Bx3 = mag[LSM303AGR_X] * cos(pitch) + Bz2 * sin(pitch);float yaw = atan2( By2 , Bx3); float factor = LSM303AGR_180_DEGREES / LSM303AGR_PI;log_PushLine(e_logLevel_Info, 'pitch: %f , roll: %f , yaw: %f', pitch * factor , roll * factor , yaw * factor); float Qw = cos(roll/2)*cos(pitch/2)*cos(roll/2) + sin(roll/2)*sin(pitch/2)*sin(roll/2); float Qx = sin(roll/2)*cos(pitch/2)*cos(roll/2) - cos(roll/2)*sin(pitch/2)*sin(roll/2); float Qy = cos(roll/2)*sin(pitch/2)*cos(roll/2) + sin(roll/2)*cos(pitch/2)*sin(roll/2); float Qz = cos(roll/2)*cos(pitch/2)*sin(roll/2) - sin(roll/2)*sin(pitch/2)*cos(roll/2);log_PushLine(e_logLevel_Info, 'qw: %f , qx: %f , qy: %f , qz: %f', Qw * factor, Qx * factor, Qy * factor, Qz * factor); } When compass rotates around z-axis it changes yaw value but very irregularly, for example from 130 to 40 and then form -100 to - 30 etc. When I change only pitch or roll value, yaw is also changed. I think that it's not correct, because device's direction is no changed. For example if pitch is 1, yaw is -50, if pitch is 14 yaw = -120. I don't understand these results. I think that pitch and roll are correct. I use accelerometer in normal mode, full scale default ( +- 2g), odr = 400 Hz, magetometer in continuous mode, 100Hz. I don't use interrupts, only check data available. Thanks for all answers. |
|
相关推荐
3个回答
|
|
HI,
我可以根据我对LSM303D和LSM303DLHC的经验告诉你一些建议。 1)您是否在开始测量之前进行磁力计校准? 2)似乎你没有对三角函数的应用笔记中解释的边界限制进行全部测试。 你写道:'当罗盘围绕z轴旋转时,它会改变偏航值但非常不规则' 答:这不正确。我确认这必须改变偏航。 我个人从原始数据移动Scilab或Matlab上的处理,以检查数据是否适合偏航,俯仰滚动计算。 我建议搜索discovery-stm32f3,其中有一个源代码可以从LSM303DLHC计算Heading = Yaw,这是一个相同的过程。 问候 毛里齐奥 以上来自于谷歌翻译 以下为原文 HI, I can tell you some suggestion based on my experience with LSM303D and LSM303DLHC. 1) Have you make the magnetometer calibration before start with measures? 2) seem you haven't make all the test for border limit explained in application note for trigonometric functions. You wrote: 'When compass rotates around z-axis it changes yaw value but very irregularly' Answer: this is not correct. I confirm that this must change only yaw. I personally move the processing on Scilab or Matlab from raw data to examine if data are good for yaw, pitch roll calculations. I suggest to search for discovery-stm32f3 where there is a source code to calculate Heading=Yaw from LSM303DLHC that is the same procedure. Regards Maurizio |
|
|
|
如果您不想花时间进行算法开发,可以使用我们提供的现有eCompass库
http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-packages/x-cube-mems1.html package.Here是的用户手册 http://www.st.com/content/ccc/resource/technical/document/user_manual/group0/3e/50/50/0b/9d/3f/47/2d/DM00396079/files/DM00396079.pdf/jcr:内容/翻译/ en.DM00396079.pdf libary。 以上来自于谷歌翻译 以下为原文 If you don't want to spend time with the algorithm development you can use already existing eCompass library which we provide in http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-packages/x-cube-mems1.html package.Here is the user manual for the http://www.st.com/content/ccc/resource/technical/document/user_manual/group0/3e/50/50/0b/9d/3f/47/2d/DM00396079/files/DM00396079.pdf/jcr:content/translations/en.DM00396079.pdf libary. |
|
|
|
你好,
我从磁力计中收集了2次原始数据(第一次使用我自己的库,然后使用此示例中的XNucleoIKS01A2库) https://os.mbed.com/teams/ST/code/HelloWorld_IKS01A2/ )。数据在两种情况下都非常相似(以高斯表示)。指南针绕Z轴旋转,逐步旋转几度。指南针处于水平位置,具有0倾角。它看起来像正弦和余弦函数,但具有运动。我试图删除这些动作,并在我有以下数据之后。 然后我试着改造它 椭圆 图中有以下公式: 因为我想达到结果,这与此类似: 这些图片来自这份文件: https://aerospace.honeywell.com/en/~/media/aerospace/files/technical-articles/applicationsofmagnetoresistivesensorsinnavigationsystems_ta.pdf 我需要椭圆来补偿“硬铁”(寄存器的偏移)和“软铁”(将椭圆转换成圆形的因素)。这些步骤为MotionEC库提供了清晰的校准数据,该库将为我计算必要的数据。 在我看来,校准基于原始数据收集,处理椭圆形式,计算偏移(硬铁)和计算椭圆的工厂(用于制作圆圈)。以下步骤是否正确?磁力计的校准是否需要进行自检? 在API MotionEC库中,在MEC_input_t结构描述中,我读到了'' Mag [3]是ENU惯例中的磁力计校准数据阵列,以?T / 50''测量,因此我需要手动转换数据。为什么需要数据读取时间? 我描述了我的推理和怀疑。需要解释一步一步,如何获得高级库的正确原始数据,例如MotionEC。以前,我实现了我的加速度计库,没有任何问题,没有校准等。 谢谢 Maurizio和Miroslav B.为您之前的回复。 最好的祝福。 Wojciech Jasiewicz。 以上来自于谷歌翻译 以下为原文 Hello, I collected raw data from magnetometer 2 times ( first time with my own library and then with XNucleoIKS01A2 library from this example https://os.mbed.com/teams/ST/code/HelloWorld_IKS01A2/ ). Datas are very similar in both cases (expressed in gauss). Compass was rotated around Z axis, step by step, by several degrees. Compass was at horizontal position with 0 titl angle.It looks like sine and cosine functions, but with movements. I tried to remove these movements and after I had following data. And then I tried to transform it in ellipse figure with following equations: because I want to reached result, which is similar to this: These pictures origin from this document: https://aerospace.honeywell.com/en/~/media/aerospace/files/technical-articles/applicationsofmagnetoresistivesensorsinnavigationsystems_ta.pdf I need ellipse to compensate ''hard iron'' (offsets for register) and ''soft iron''(factors for converting ellipse to circle). These steps provide clear calibrate data for MotionEC library and this library will counts necessary data for me. In my opinion, calibration based on raw data collecting, processing it's to ellipse form, counting offsets (hard iron) and counting ellipse's factories (for making circle). Are followings steps correct? Is self test necessary to magnetometer's calibrating? In API MotionEC library, in MEC_input_t structure description, I read that '' Mag[3] is an array of magnetometer calibrated data in ENU convention, measured in ?T/50'', hence I need to convert data manually. Why period of data reading is required? I described my reasoning and my doubts. In need explanations, step by step, how to get correct raw data for high level library, for example MotionEC. Previously, I implemented my library for accelerometer, without any problems, without calibration, etc. Thanks Maurizio and Miroslav B. for your's previous replies. Best regards. Wojciech Jasiewicz. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2718 浏览 1 评论
3235 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3645 浏览 6 评论
6033 浏览 21 评论
1334浏览 4评论
208浏览 3评论
196浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
440浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 13:22 , Processed in 1.072921 second(s), Total 51, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号