Skip to content

Commit

Permalink
Update Javadoc comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Nov 1, 2023
1 parent 9efc21d commit 0c08f66
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ else if (interaction.getTypeId().equals(DetectorRegistration.TYPE_ID)) {
}
}


/**
* Method to call XMLRPC method to create sensor on reception of DetectionRegistration interactions.
* @param interaction Interaction triggered by Ambassadors attempting to create sensors in CARLA.
*/
private void receiveInteraction(DetectorRegistration interaction) {
try {
carlaXmlRpcClient.createSensor(interaction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import com.google.gson.Gson;

/**
* This is a class uses xmlrpc to connect with CARLA CDASim adapter service
* This is a class uses xmlrpc to connect with CARLA CDASim Adapter. It includes calls
* to dynamically create senors and get detected objects from created sensors.
*/
public class CarlaXmlRpcClient{

Expand Down Expand Up @@ -61,7 +62,11 @@ public void initialize()
isConnected = true;
}


/**
* Calls CARLA CDA Sim Adapter create_sensor XMLRPC method and logs sensor ID of created sensor.
* @param registration DetectorRegistration interaction used to create sensor.
* @throws XmlRpcException if XMLRPC call fails or connection is lost.
*/
public void createSensor(DetectorRegistration registration) throws XmlRpcException{
List<Double> location = Arrays.asList(registration.getDetector().getLocation().getX(), registration.getDetector().getLocation().getY(), registration.getDetector().getLocation().getZ());
List<Double> orientation = Arrays.asList(registration.getDetector().getOrientation().getPitch(), registration.getDetector().getOrientation().getRoll(), registration.getDetector().getOrientation().getYaw());
Expand All @@ -75,7 +80,13 @@ public void createSensor(DetectorRegistration registration) throws XmlRpcExcepti
log.warn("XMLRpcClient is not connected to CARLA Adapter!");
}
}

/**
* Calls CARLA CDA Sim Adapter get_detected_objects XMLRPC method and returns an array of DetectedObject.
* @param infrastructureId String infrastructure ID of sensor to get detections from.
* @param sensorId String sensor ID of sensor to get detections from
* @return DetectedObject[] from given sensor.
* @throws XmlRpcException if XMLRPC call fails or connection is lost.
*/
public DetectedObject[] getDetectedObjects(String infrastructureId ,String sensorId) throws XmlRpcException{
if (isConnected) {
Object[] params = new Object[]{infrastructureId, sensorId};
Expand All @@ -92,7 +103,10 @@ public DetectedObject[] getDetectedObjects(String infrastructureId ,String senso

}
}

/**
* Method to set isConnected field to false. Does not actually close the underlying http connection session but
* is used to avoid repeated timeouts/exceptions on misconfiguration of XMLRPC client.
*/
public void closeConnection() {
log.warn("Closing XML RPC Client connection in CARLA Ambassador!");
isConnected = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public void testCreateSensor() throws XmlRpcException {
verify( mockClient, times(1)).execute("create_simulated_semantic_lidar_sensor", params);
}


/**
* Test GetDectedObjects
* @throws XmlRpcException
*/
@Test
public void testGetDetectedObjects() throws XmlRpcException {
// Create return JSON String
Expand Down Expand Up @@ -187,7 +190,10 @@ public void testGetDetectedObjects() throws XmlRpcException {

}


/**
* Test close connection
* @throws XmlRpcException
*/
@Test
public void testCloseConnection() throws XmlRpcException {
// Create request params
Expand Down

0 comments on commit 0c08f66

Please sign in to comment.