Quantcast

Blackboard Data Storage

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Blackboard Data Storage

kparvate
Hi all,

I have tried to set up a communication system for multiple robots, but I am facing some issues with the Blackboard Proxy associated with the localbb driver.

Here is my code thus far:

#include <stdio.h>

#include <string.h>
#include <iostream>
#include <libplayerc++/playerc++.h>
#include <sstream>
using namespace std;
using namespace PlayerCc;
int main(int argc, char **argv) {
        PlayerClient robot("localhost", 6665);
        BlackBoardProxy bb(&robot, 0);
        char *key = (char *) "myKey";
        char *group = (char *) "myGroup";

                        player_blackboard_entry_t data,* output;


                data.data = new uint8_t[1];
                data.data_count = 1;
                data.data[0] = 3;
                data.key = key;
                data.key_count = strlen((const char*) key) + 1;
                data.group = group;
                data.group_count = strlen((const char*) group) + 1;
                time_t rawtime;
                time(&rawtime);
                data.timestamp_sec = rawtime;

                try {
                        //updating the key
                        bb.SetEntry(data);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }

                try {

                        output = bb.GetEntry(key,group);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }
                int datacount = output->data_count;
                for(int i=0; i<datacount; i++){
                        cout << "Data value at " << i<< " is: " << output->data[i];
                }
                cout << endl;
}

Here is the relevant portion of the cfg file just in case:
 driver
 (
  name "localbb"
  provides ["blackboard:0"]
 )

However, I am getting a very weird out put from  output->data[i]. It doesn't seem to be a normal character. I have attached a picture of it.. Could someone explain why this is happening, and how to fix it?

Furthermore, I am unfamiliar with the type uint8_t, and I am unsure as to how I am supposed to store strings or doubles. Any help would be greatly appreciated.

Cheers.

Kanaad

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blackboard Data Storage

Toby Collett-10
The character you are getting is a 3 just as you wrote into the data array. If you want the character 3 you need to write '3', or cast the output to an int before you print it.

uint8_t is just an unsigned char in a portable way (from stdint.h)

The array is just opaque data, you can put anything you like in there. There are some helper methods like playerc_pack_blackboard_entry_double to help with floating point etc.


Regards,
Toby


On 16 February 2013 20:57, kparvate <[hidden email]> wrote:
Hi all,

I have tried to set up a communication system for multiple robots, but I am
facing some issues with the Blackboard Proxy associated with the localbb
driver.

Here is my code thus far:

#include <stdio.h>

#include <string.h>
#include <iostream>
#include <libplayerc++/playerc++.h>
#include <sstream>
using namespace std;
using namespace PlayerCc;
int main(int argc, char **argv) {
        PlayerClient robot("localhost", 6665);
        BlackBoardProxy bb(&robot, 0);
        char *key = (char *) "myKey";
        char *group = (char *) "myGroup";

                        player_blackboard_entry_t data,* output;


                data.data = new uint8_t[1];
                data.data_count = 1;
                data.data[0] = 3;
                data.key = key;
                data.key_count = strlen((const char*) key) + 1;
                data.group = group;
                data.group_count = strlen((const char*) group) + 1;
                time_t rawtime;
                time(&rawtime);
                data.timestamp_sec = rawtime;

                try {
                        //updating the key
                        bb.SetEntry(data);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }

                try {

                        output = bb.GetEntry(key,group);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }
                int datacount = output->data_count;
                for(int i=0; i<datacount; i++){
                        cout &lt;&lt; &quot;Data value at &quot; &lt;&lt; i&lt;&lt; &quot; is:
&quot; &lt;&lt; output->data[i];
                }
                cout << endl;
}

Here is the relevant portion of the cfg file just in case:
 driver
 (
  name "localbb"
  provides ["blackboard:0"]
 )

However, I am getting a very weird out put from  output->data[i].         It
doesn't seem to be a normal character. I have attached a picture of it.
<http://player-stage-gazebo.10965.n7.nabble.com/file/n18590/05.png> . Could
someone explain why this is happening, and how to fix it?

Furthermore, I am unfamiliar with the type uint8_t, and I am unsure as to
how I am supposed to store strings or doubles. Any help would be greatly
appreciated.

Cheers.

Kanaad





--
View this message in context: http://player-stage-gazebo.10965.n7.nabble.com/Blackboard-Data-Storage-tp18590.html
Sent from the playerstage-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users


------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Blackboard Data Storage

kparvate
Hi Toby,

Thanks for your help. That made sense. I solved the issue with the character by using printf and "%u".



On Sat, Feb 16, 2013 at 3:55 PM, Toby Collett-10 [via Player/Stage/Gazebo] <[hidden email]> wrote:
The character you are getting is a 3 just as you wrote into the data array. If you want the character 3 you need to write '3', or cast the output to an int before you print it.

uint8_t is just an unsigned char in a portable way (from stdint.h)

The array is just opaque data, you can put anything you like in there. There are some helper methods like playerc_pack_blackboard_entry_double to help with floating point etc.


Regards,
Toby


On 16 February 2013 20:57, kparvate <[hidden email]> wrote:
Hi all,

I have tried to set up a communication system for multiple robots, but I am
facing some issues with the Blackboard Proxy associated with the localbb
driver.

Here is my code thus far:

#include <stdio.h>

#include <string.h>
#include <iostream>
#include <libplayerc++/playerc++.h>
#include <sstream>
using namespace std;
using namespace PlayerCc;
int main(int argc, char **argv) {
        PlayerClient robot("localhost", 6665);
        BlackBoardProxy bb(&robot, 0);
        char *key = (char *) "myKey";
        char *group = (char *) "myGroup";

                        player_blackboard_entry_t data,* output;


                data.data = new uint8_t[1];
                data.data_count = 1;
                data.data[0] = 3;
                data.key = key;
                data.key_count = strlen((const char*) key) + 1;
                data.group = group;
                data.group_count = strlen((const char*) group) + 1;
                time_t rawtime;
                time(&rawtime);
                data.timestamp_sec = rawtime;

                try {
                        //updating the key
                        bb.SetEntry(data);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }

                try {

                        output = bb.GetEntry(key,group);
                } catch (PlayerError pe) {
                        cout << "Error: " << pe.GetErrorStr() << endl;
                        return (-1);
                }
                int datacount = output->data_count;
                for(int i=0; i<datacount; i++){
                        cout &lt;&lt; &quot;Data value at &quot; &lt;&lt; i&lt;&lt; &quot; is:
&quot; &lt;&lt; output->data[i];
                }
                cout << endl;
}

Here is the relevant portion of the cfg file just in case:
 driver
 (
  name "localbb"
  provides ["blackboard:0"]
 )

However, I am getting a very weird out put from  output->data[i].         It
doesn't seem to be a normal character. I have attached a picture of it.
<http://player-stage-gazebo.10965.n7.nabble.com/file/n18590/05.png> . Could
someone explain why this is happening, and how to fix it?

Furthermore, I am unfamiliar with the type uint8_t, and I am unsure as to
how I am supposed to store strings or doubles. Any help would be greatly
appreciated.

Cheers.

Kanaad





--
View this message in context: http://player-stage-gazebo.10965.n7.nabble.com/Blackboard-Data-Storage-tp18590.html
Sent from the playerstage-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users


------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users



If you reply to this email, your message will be added to the discussion below:
http://player-stage-gazebo.10965.n7.nabble.com/Blackboard-Data-Storage-tp18590p18591.html
To unsubscribe from Blackboard Data Storage, click here.
NAML

Loading...