Welcome, Guest

How does the JAUS Component/message work?
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: How does the JAUS Component/message work?
#164
How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Hey guys,
I'm working on a project for IGVC. We are building an autonomous ground vehicle using JAUS for an internal architecture. I've been working on the implementation of JAUS for quite some time now. I've read through all the architecture pdfs and other tutorials on the site. I have implemented my own JAUS message to transmit LIDAR data. I am building all of our system on the ojVehicleSim example provided with the libraries. There are almost no documentation for any of the functions. So here are my questions:

How does a component get the data from a device??
What function is responsible for updating the component with the newest data?
Do I update components data in rsensorQueryRangeSensorCallback before I send it back?
What does vssReadyState(OjCmpt vss) or any ***ReadyState function does??

Thank you for your time.
victort
OpenJAUS Contributor
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#165
Re: How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Victor, thanks for using OpenJAUS. I hope these responses help answer your questions:

A component can get data from a device any way the developer (that's you) wants. Typically this is done by calling some function in a device driver library.

Typically the newest data is updated in a component just before it is sent out as a Jaus Message. This means that it can be updated when the query message callback function is executed, or just before the service connection messages are sent out in a state callback (ex: readyState)

The state callbacks are simply there for you if you want your component to execute something on a steady periodic time basis. They can also be used to indicate the "mode" of a component. Example: if the component just started and it's waiting for device to boot up, then it can stay in the Initialize state. Then when it is ready to it can transition itself into the standby or whatever other state you want.
tgalluzzo
Admin
Posts: 83
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#166
Re: How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Thanks a lot tgalluzzo. I will post any other question I have here too since you have been pretty quick with an answer:)
victort
OpenJAUS Contributor
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#167
Re: How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Ok, so I was able to get my component to update its data when service connection message is received. Now, I would like to update components data upon my own request. What I thought would work is to create a Report message, set the new data and send it to the component. I implemented this logic but it does not seem to work. Here is my code for sending the message:

Code:


//Get the newest data from the file (temp method)
FILE *ret = fopen("lidarData.txt", "r");
char *lidarData = (char*) malloc(sizeof(char) *lidarDataSize);
lidarData = fgets(lidarData,lidarDataSize, ret);
cout << "Lidar data: " << lidarData << endl;
fclose(ret);

//creating a report message
ReportLidarDataMessage myReportMsg = reportLidarDataMessageCreate();
jausByteSetBit(&myReportMsg->presenceVector, JAUS_LIDAR_DATA_RANGES_BIT);
memcpy(&myReportMsg->ranges,lidarData, lidarDataSize);
txtMessage = reportLidarDataMessageToJausMessage(myReportMsg);
jausAddressCopy(txtMessage->destination,address);
ojCmptSendMessage(rsensor,txtMessage);
jausMessageDestroy(txtMessage);
reportLidarDataMessageDestroy(myReportMsg);



Should I do anything with my component like add a specific listener for the report message just like its done for the query message? Thanks.
victort
OpenJAUS Contributor
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#168
Re: How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Hey Victor,

Your code looks mostly correct for making a ReportLidarDataMessage. I'll assume for now that your definition of that message is correct (one gotcha is to make sure you are allocating memory for the ranges member which you are memcpy'ing into!). One thing that I see missing is that you are not setting the values of the message->source and message->destination fields. These JAUS address fields are necessary to properly route your message to the proper receiving component. You can see examples of how this is done in the Sending & Receiving Messages Tutorial.

With respect to your other question, you will need some function in your receiving component which is designed to receive your ReportLidarDataMessage. OpenJAUS provides two methodologies for this. The first is the callback function specifically attuned to a particular message command code. This is setup using the function:

Code:

void ojCmptSetMessageCallback(OjCmpt ojCmpt, unsigned short commandCode, void (*messageFunction)(OjCmpt, JausMessage));


The other method which can be used is to setup a single function which will be called whenever a callback function without the specified command code is found. This is setup using the function:

Code:

void ojCmptSetMessageProcessorCallback(OjCmpt ojCmpt, void (*processMessageFunction)(OjCmpt, JausMessage));


You can see a good example of this kind of callback function in the pd.c file which is included in the ojVehicleSim project. This function uses a large switch statement to determine behavior based on the message's command code.

Hopefully that information helps!
~Danny
kentd
Go Gators!
Admin
Posts: 61
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Draco098 Lights Out Photography Draco098 Draco098 Draco098 Location: Charlotte, NC Birthday: 09/20
The administrator has disabled public write access.
There's 10 types of people in the world; those that understand binary and those that don't.
 
#169
Re: How does the JAUS Component/message work? 6 Months, 2 Weeks ago  
Thanks a lot for your reply. I thought that lines
Code:


txtMessage = reportLidarDataMessageToJausMessage(myReportMsg);
jausAddressCopy(txtMessage->destination,address);



Sets the destination address and that a source address is automatically created when I create a txtMessage.
victort
OpenJAUS Contributor
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 12
Copyright © 2010 OpenJAUS. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.