go_away

Author Topic: Minimising Output String from Razor 9DOF AHRS Firmware  (Read 1212 times)

0 Members and 1 Guest are viewing this topic.

Offline InvictaTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 1
Minimising Output String from Razor 9DOF AHRS Firmware
« on: November 04, 2011, 05:00:11 PM »
I wish to make the output string from the AHRS firmware as small as possible to reduce the processing required by my Axon2. At the start of the string is "!ANG" that gets removed by the Python code. I know that the "ANG" is nothing special but why is the "!" used? Is it a character used somehow to identify the start of the string? If so, by what?

Can I just output: role,pitch,yaw values separated by commas?

Thanks

Offline InvictaTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 1
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #1 on: November 05, 2011, 02:57:39 PM »
@Admin
@Webbot

Could you spare me your penny-worth please.

Thanks

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #2 on: November 05, 2011, 04:42:39 PM »
I'm not Admin nor Webbot, but:

The ! is used as a universal start-of-packet indicator, since the data is printed out as ASCII and the packet length is unknown. The mechanism for its detection is fairly simple--any and all '!' in the string are treated as a new packet. The == operator is useful here.

If you want to reduce processing, you'd be best off changing it to use binary numbers (2-byte signed integers would give you plenty of precision) instead of ASCII, thereby eliminating the need to reconstruct the numbers. You should always have a start of packet marker of some sort--it is highly unlikely that both systems will start out at the exact same time, and packet markers serve as simple ways to synchronize communications. Of course, you could just use newlines as the end of packet marker and write your code to use those instead, since it's basically the same process.

Just outputing roll/pitch/yaw values in CSV format wouldn't save you much of any processing, if that's your concern.

Offline InvictaTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 1
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #3 on: November 07, 2011, 04:13:23 PM »
@rbtying

Thank you for your reply.

I understand what you are saying about start and end packet indicators but would not the use of serial.print("!") place the '!' as part of the payload inside the packet? String.print would appear to come from the Arduino Language http://arduino.cc/en/Reference/HomePage and I can find no reference to the use of '!' in conjunction with serial.print as a special character therein!

If you know of a specific reference that defines the use of '!' as a universal start-of-packet indicator I would be most keen to see it.

Regards

Invicta

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #4 on: November 07, 2011, 04:31:45 PM »
The firmware used always prints '!' before starting a new data string; thus, checking for '!' in your code works as a start of packet indicator. This functionality will NOT be handled for you in library functions; it is a property of the communications protocol you are using, not the underlying UART transmission.

Serial.print("!") is used in the protocol to mark the start of the packet; therefore, when reading,

char c = Serial.read();
if (c == '!') // then start of packet

Offline InvictaTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 1
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #5 on: November 08, 2011, 10:50:56 AM »
@rbtying

Once again thanks.

Would you know of any examples of this; other than the DiyDrones AHRS code for the Razor 9DoF?

Cheers

Invicta

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Minimising Output String from Razor 9DOF AHRS Firmware
« Reply #6 on: November 08, 2011, 07:28:49 PM »
Whether its universal or not makes no difference. Its really there as a 'start of line' character. So that when the receiver reads a line of characters it can tell if it is 'well formed' - ie starts with a ! and ends with a CR.
If the AHRS was just sending out sequences of numbers then the receiver would not be able to detect which was the yaw, pitch, roll etc. If the receiver was using the wrong baud rate then it could completely misinterpret the received garbage. So by check that the line starts with '!ANG' means: a) your using the correct baud and b)that this lines contains angular data.

Why '!ANG' well you may also see that some AHRS output also sends out error messages and these start with '!ERR'

So its a parsing thing - to make sure the receiver is correctly interpreting the data sent by the host.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here