Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Bug Fix #74

Open
wants to merge 3 commits into
base: indigo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.UUID;

/**
* Threaded ROS-concert checker. Runs a thread which checks for a valid ROS
Expand Down Expand Up @@ -84,6 +85,9 @@ public interface FailureHandler {
private CheckerThread checkerThread;
private ConcertDescriptionReceiver foundConcertCallback;
private FailureHandler failureCallback;
private NodeMainExecutorService nodeMainExecutorService = null;
private MasterInfo masterInfo = null;
private RoconInteractions roconInteractions = null;

/**
* Constructor. Should not take any time.
Expand Down Expand Up @@ -153,28 +157,37 @@ public void run() {
String version = (String) paramClient.getParam(GraphName.of("/rosversion")).getResult();
Log.i("Remocon", "r ros master found [" + version + "]");

NodeMainExecutorService nodeMainExecutorService = new NodeMainExecutorService();
nodeMainExecutorService = new NodeMainExecutorService();
NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(
InetAddressFactory.newNonLoopback().getHostAddress(), concertUri);

// Check for the concert information topic
MasterInfo masterInfo = new MasterInfo();
RoconInteractions roconInteractions = new RoconInteractions(Constants.ANDROID_PLATFORM_INFO.getUri());
masterInfo = new MasterInfo();
roconInteractions = new RoconInteractions(Constants.ANDROID_PLATFORM_INFO.getUri());

String masterInfoNodeName = "master_info_node" + UUID.randomUUID().toString().replace("-", "_");
String roconInteractionsNodeName = "rocon_interactions_node" + UUID.randomUUID().toString().replace("-", "_");

Log.i("Remocon", "masterInfoNodeName: " + masterInfoNodeName);
Log.i("Remocon", "roconInteractionsNodeName: " + roconInteractionsNodeName);

nodeMainExecutorService.execute(
masterInfo,
nodeConfiguration.setNodeName("master_info_node")
nodeConfiguration.setNodeName(masterInfoNodeName)
);
masterInfo.waitForResponse(); // MasterInfoExc. on timeout, listener or ros runtime errors
Log.i("Remocon", "master info found");

nodeMainExecutorService.execute(
roconInteractions,
nodeConfiguration.setNodeName("rocon_interactions_node")
nodeConfiguration.setNodeName(roconInteractionsNodeName)
);
roconInteractions.waitForResponse(); // InteractionsExc. on timeout, service or ros runtime errors
Log.i("Remocon", "rocon interactions found");

// configure concert description


Date timeLastSeen = new Date();
RoconDescription description = new RoconDescription(
masterId,
Expand All @@ -184,6 +197,7 @@ public void run() {
roconInteractions.getNamespace(),
timeLastSeen);

Log.i("Remocon", "finish creation RoconDescription");
description.setConnectionStatus(RoconDescription.OK);
description.setUserRoles(roconInteractions.getRoles());
foundConcertCallback.receive(description);
Expand All @@ -207,6 +221,15 @@ public void run() {
} catch (Throwable e) {
Log.w("Remocon", "exception while creating node in concert checker for URI " + concertUri, e);
failureCallback.handleFailure("unknown exception in the rocon checker [" + e.toString() + "]");
}finally {
if (nodeMainExecutorService != null){
if (masterInfo != null){
nodeMainExecutorService.shutdownNodeMain(masterInfo);
}
if (roconInteractions != null){
nodeMainExecutorService.shutdownNodeMain(roconInteractions);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static private Result launchAndroidAppWithAppId(final Activity parent, final Roc
}
}
}
{
else{
result = Result.NOT_INSTALLED;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,20 @@ public void getAppsForRole(final MasterId masterId, final String role) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
getAppsForRole();
try {
getAppsForRole();
} catch (ServiceNotFoundException e) {
e.printStackTrace();
try {
throw new ServiceNotFoundException(e);
} catch (ServiceNotFoundException e1) {
e1.printStackTrace();
}
} catch (RosRuntimeException e){
e.printStackTrace();
throw new RosRuntimeException(e);

}
return null;
}
}.execute(); // TODO: can we use this to incorporate a timeout to service calls?
Expand Down Expand Up @@ -223,7 +236,7 @@ protected Void doInBackground(Void... params) {
}
}

private void getAppsForRole() {
private void getAppsForRole() throws ServiceNotFoundException, RosRuntimeException {
// call get_roles_and_apps concert service
ServiceClient<GetInteractionsRequest, GetInteractionsResponse> srvClient;
String serviceName = this.interactionsNamespace + "/get_interactions";
Expand All @@ -233,7 +246,10 @@ private void getAppsForRole() {
srvClient = connectedNode.newServiceClient(serviceName, GetInteractions._TYPE);
} catch (ServiceNotFoundException e) {
Log.i("InteractionsMng", "List interactions service not found [" + serviceName + "]");
throw new RosRuntimeException(e); // TODO we should recover from this calling onFailure on listener
throw new ServiceNotFoundException(e); // TODO we should recover from this calling onFailure on listener
} catch(RosRuntimeException e){
Log.i("InteractionsMng", "Getting interactions service is failure [" + serviceName + "]");
throw new RosRuntimeException(e);
}
final GetInteractionsRequest request = srvClient.newMessage();

Expand Down Expand Up @@ -363,7 +379,13 @@ public void onStart(final ConnectedNode connectedNode) {
requestAppUse();
break;
case GET_INTERACTIONS_FOR_ROLE:
getAppsForRole();
try {
getAppsForRole();
} catch (ServiceNotFoundException e) {
e.printStackTrace();
} catch(RosRuntimeException e){
e.printStackTrace();
}
break;
case GET_INTERACTION_INFO:
getAppInfo();
Expand Down
4 changes: 2 additions & 2 deletions rocon_remocon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
versionCode 6
versionName "1.2.2"
versionCode 7
versionName "1.2.3"
}
productFlavors {
indigo {
Expand Down