go away spammer

Author Topic: Struggling to get started with Webbotlib C++  (Read 2405 times)

0 Members and 1 Guest are viewing this topic.

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Struggling to get started with Webbotlib C++
« on: July 25, 2012, 12:23:56 PM »
I am really struggling to get started with the C++ webbot library.

I started a project in PD, selected my board (328P)

went through the My First Program Hello World example.

When I connect to hyperterminal, I am getting gibberish characters, cannot get it to work.

So I decide to try to simply play with the statusLED.

I go to the documentation, I see LED has on, off, set

so I try:

statusLED.on()

Build, and I get an error message: HelloWorld.cpp:20: error: 'struct LED' has no member named 'on'

When I go into the LED class, I see the wrapper, and I see on, off....

so I try set, I try:

statusLED.set(TRUE);

I get:
HelloWorld.cpp:18: error: 'struct LED' has no member named 'set'


So I look at the code for LED, and in the C code I see it should be:

LED_Set(LED* LED,boolean);

so I try, LED_Set(statusLED,TRUE);

and I get:

HelloWorld.cpp:16: error: cannot convert 'LED' to 'LED*' for argument '1' to 'void LED_set(LED*, boolean)'


so now I am at a complete loss, because I thought statusLED was setup via project designer.

I am a software architect, I have worked with Java, c#, objective C, all higher level language, but I live and breathe OOP.

Is this an AVRstudio issue, am I missing something obvious here?

I really could use some help getting this going. Some C++ examples or something would be GREAT!


This library is insanely awesome, and I so badly want to start using it, I just cannot get going.

If I can get going, I fully plan to support Webbot financially for making this great library.

Any help would be much appreciated.


Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Struggling to get started with Webbotlib C++
« Reply #1 on: July 25, 2012, 01:38:38 PM »
I think this might be it... Try
Code: [Select]
LED_Set(&statusLED,TRUE);The documentation is telling you that LED_Set takes a pointer (the asterisk is the clue), so you use the & to pass the variable's location, rather than passing by value.

Also you can use [code ] [ / code] tags to make code snippets more readable.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Struggling to get started with Webbotlib C++
« Reply #2 on: July 25, 2012, 02:19:11 PM »
I think this might be it... Try
Code: [Select]
LED_Set(&statusLED,TRUE);The documentation is telling you that LED_Set takes a pointer (the asterisk is the clue), so you use the & to pass the variable's location, rather than passing by value.

Also you can use [code ] [ / code] tags to make code snippets more readable.

Gotcha, will do that from now on, sorry about that.

So I tried that and I got: LED_Set was not declared in this scope.


I found an old version of the photovore_v1 using c++ from webbot before he built this library, and I know there are plenty of c examples, does anyone know of any good examples using c++?

I feel like if I can just look at some code I would be OK.


Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Struggling to get started with Webbotlib C++
« Reply #3 on: July 25, 2012, 02:32:25 PM »
I still use C, admittedly.

Is HelloWorld.cpp initially being generated by Project Designer?

Though this is not the issue, I recommend using AVR Studio 4.18 or 4.19 (not 5 or 6) if you aren't already.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Struggling to get started with Webbotlib C++
« Reply #4 on: July 25, 2012, 02:41:17 PM »
I still use C, admittedly.

Is HelloWorld.cpp initially being generated by Project Designer?

Though this is not the issue, I recommend using AVR Studio 4.18 or 4.19 (not 5 or 6) if you aren't already.

I am using 4.15, for some crazy reason, it is the only version I was able to get to work with my avrisp mkII, and I am afraid to mess with it, I never went to 5.

Yes, I started with the Project Designer, it is creating the cpp, the avr project, everything.

That is what creates the UART that I could not get to work in the electronics thread that you were helping me with.

I still cannot get that to work either.

Are most people using the c version of the webbotlib?


Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Struggling to get started with Webbotlib C++
« Reply #5 on: July 25, 2012, 03:06:31 PM »
I'm out of ideas that I can draw from my own experiences. I never built a board; I just use the Axon. :-X

Are most people using the c version of the webbotlib?
I think the only person who knows is Webbot, and even he might not. I have no idea how many people use Webbotlib, even. He probably at least knows how many people are downloading his project.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Struggling to get started with Webbotlib C++
« Reply #6 on: July 25, 2012, 03:15:59 PM »
Thanks for trying, if anyone else can help me out it would be greatly appreciated.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Struggling to get started with Webbotlib C++
« Reply #7 on: July 25, 2012, 04:24:55 PM »
The status LED is a strange beast - for a number of reasons....
1. WebbotLib wants to own it - to flash out error messages. Seems easier to grad a single I/O pin to do this than grab a resource like a UART of which there may only be one.
2. Some boards share the status LED with one of the UART pins. Gives a nice flashiness when the UART is working but makes it difficult to control independently.
3. If the user, ie you, try to control it then it makes things even harder - ie WebbotLib is trying to flash an error but your code is turning it on and off as well.

That said - if you want to control it then try using:
statusLED_on();
statusLED_off();

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Struggling to get started with Webbotlib C++
« Reply #8 on: July 25, 2012, 05:53:23 PM »
The status LED is a strange beast - for a number of reasons....
1. WebbotLib wants to own it - to flash out error messages. Seems easier to grad a single I/O pin to do this than grab a resource like a UART of which there may only be one.
2. Some boards share the status LED with one of the UART pins. Gives a nice flashiness when the UART is working but makes it difficult to control independently.
3. If the user, ie you, try to control it then it makes things even harder - ie WebbotLib is trying to flash an error but your code is turning it on and off as well.

That said - if you want to control it then try using:
statusLED_on();
statusLED_off();

This is very helpful, thank you.

 


Get Your Ad Here