![]() |
Hardware integration of sensors?
Hi everyone,
I am trying to integrate the readings from an accelerometer to get velocity. When I tried to do this in software, it was laughingly inaccurate. So I looked at Gyro.cpp in WPILib to see how they integrate angular velocity to get heading. They use a hardware accumulator (integrator). I tried to copy their code and adapt it for use with an accelerometer (see accelerometer.cpp). I came up with this class: Accel2Vel.h: Code:
#pragma onceCode:
#include "Accel2Vel.h"Thanks, -Kevin |
Re: Hardware integration of sensors?
Thats a really neat idea.. try inheriting from SensorBase, that might do it (thats what Gyro inherits from).
Also.. #pragma once is MSVC only... it won't work here. Use the standard #ifndef .. #define .. #endif clauses. :) |
Re: Hardware integration of sensors?
Oh, I see. Thats not it at all. If you look at AnalogChannel.cpp, there appear to be two accumulator channels:
Code:
const UINT32 AnalogChannel::kAccumulatorChannels[] = {1, 2}; |
Re: Hardware integration of sensors?
I am looking into the same thing, post any progress if you could.
Take note of the following as well: In Gyro.cpp Code:
if (!m_analog->IsAccumulatorChannel())Code:
S(GyroNotAccumulatorChannel, -6, "Gyro can only be used with Analog Channel 1 on either module"); |
Re: Hardware integration of sensors?
Odd, I wonder why the code seems to indicate that channel 2 can be used as well. I haven't messed with it yet.
|
Re: Hardware integration of sensors?
Yeah I was just wondering the same thing. Hopefully 1 and 2 work, then I can take out the 2nd analog thing and save some weight.
I remember getting that one fatal error, I had my gyro in slot 3, I guess one quick way to test it is to see if it gives that error in slot 2. |
Re: Hardware integration of sensors?
During the beta period, the FPGA had 1 accumulator on channel 1 of module 1 and 1 accumulator on channel 1 of module 2. It was decided that it made more sense to have them both on the same module, to lessen the chance that people would have to use module 2.
The const in AnalogChannel.cpp is correct, the text of the assertion is not. As noted in the documentation, bugs should be on the forums at forums.usfirst.org. Patches are also welcome there. |
Re: Hardware integration of sensors?
Thanks for the help! When I put it on Channel 1, it (sort of) works. It works in the sense that it now gets values, but they are all bad (they're always increasing, and at a VERY high rate). Does anyone know what might be wrong?
Thanks. |
Re: Hardware integration of sensors?
I kind of have the same issue. It spits out numbers, it doesn't really go up at a really high rate, but the data is still completly unuseable as it is right now... How can I increase the useablility of this sensor...
|
| All times are GMT -5. The time now is 10:34 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi