Commit 3702a718 authored by Petyo Bogdanov Ilov's avatar Petyo Bogdanov Ilov

Fixes allowing user to start simulation only when it is done.

Integration with AutopilotAdapter (not yet done)
parent 2c5488d5
......@@ -3,4 +3,6 @@
.project
.classpath
.directory
.idea
.idea/*
/target/
......@@ -3,8 +3,18 @@ REM Batch script
SET CONFIG_DIR=main\resources
SET CONFIG_FILE=config.properties
SET APA=AutopilotAdapter.dll
SET OCTAVE=liboctave-4.dll
SET OINTERP=liboctinterp-4.dll
SET J_LIB_DIR=C:\ProgramData\Oracle\Java\javapath
SET SFS_EXT_DIR=C:\Users\Administrator\SmartFoxServer_2X\SFS2X\extensions\AllInOne
copy %CONFIG_DIR%\%CONFIG_FILE% %SFS_EXT_DIR%\%CONFIG_FILE%
copy %CONFIG_DIR%\%APA% %J_LIB_DIR%\%APA%
copy %CONFIG_DIR%\%OCTAVE% %J_LIB_DIR%\%OCTAVE%
copy %CONFIG_DIR%\%OINTERP% %J_LIB_DIR%\%OINTERP%
ECHO Extensions deployed \(Platform windows\)
\ No newline at end of file
......@@ -125,11 +125,11 @@
<artifactId>simulator</artifactId>
<version>${montisim.version}</version>
</dependency>
<!-- <dependency>
<dependency>
<groupId>montisim</groupId>
<artifactId>example-autopilot-ema</artifactId>
<version>0.0.5</version>
</dependency> -->
</dependency>
<!-- <dependency>
<groupId>montisim</groupId>
......@@ -250,8 +250,7 @@
<mainClass>package rwth.server.extensions.ZoneExt</mainClass>
</transformer>
</transformers>
<finalName>${project.name}</finalName>
<outputDirectory>${sfs.extensions}</outputDirectory>
<outputFile>${sfs.extensions}/${project.name}.jar</outputFile>
</configuration>
</execution>
</executions>
......
......@@ -10,16 +10,20 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x:2.13" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x-core:2.13" level="project" />
<orderEntry type="module" module-name="application-layer" />
<orderEntry type="module" module-name="environment" />
<orderEntry type="module" module-name="util" />
<orderEntry type="library" name="Maven: montisim:commons:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:library:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:control:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:navigation:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:environment:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:util:1.0.1" level="project" />
<orderEntry type="library" name="Maven: jfree:jfreechart:1.0.13" level="project" />
<orderEntry type="library" name="Maven: jfree:jcommon:1.0.16" level="project" />
<orderEntry type="module" module-name="commons" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-core:0.0.18" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:adt-multicollections:0.0.3" level="project" />
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
......@@ -28,7 +32,7 @@
<orderEntry type="library" name="Maven: de.topobyte:commons-cli-helper:0.0.3" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:melon-io:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-xml:0.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:dynsax:0.0.1" level="project" />
......@@ -49,32 +53,34 @@
<orderEntry type="library" name="Maven: de.topobyte:mercator-image:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:geomath:0.0.1" level="project" />
<orderEntry type="library" name="Maven: org.wololo:jts2geojson:0.6.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.8" level="project" />
<orderEntry type="library" name="Maven: org.tukaani:xz:1.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" name="Maven: net.imagej:ij:1.51j" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.sun:tools:1.4.2">
<CLASSES>
<root url="jar:///usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar!/" />
<root url="jar://C:/Program Files/Java/jdk1.8.0_102/jre/../lib/tools.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="vehicle" />
<orderEntry type="module" module-name="library" />
<orderEntry type="module" module-name="simulator" />
<orderEntry type="module" module-name="sensors" />
<orderEntry type="library" name="Maven: montisim-simulation:vehicle:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:sensors:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.jhlabs:filters:2.0.235-1" level="project" />
<orderEntry type="module" module-name="network" />
<orderEntry type="module" module-name="navigation" />
<orderEntry type="module" module-name="control" />
<orderEntry type="library" name="Maven: montisim-simulation:network:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:simulator:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim:example-autopilot-ema:0.0.5" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.51" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.1.51" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.51" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar.ema2kt:runtime:0.0.5" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.1" level="project" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project version="4" relativePaths="false">
<component name="ProjectRootManager" version="2" assert-keyword="true" project-jdk-name="1.8" jdk-15="true"/>
<component name="CodeStyleManager">
<option name="USE_DEFAULT_CODE_STYLE_SCHEME" value="true"/>
<option name="CODE_STYLE_SCHEME" value=""/>
</component>
<component name="libraryTable"/>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac"/>
<option name="CLEAR_OUTPUT_DIRECTORY" value="false"/>
<!--
<wildcardResourcePatterns>
<entry name="${wildcardResourcePattern}"/>
</wildcardResourcePatterns>
-->
<wildcardResourcePatterns>
<entry name="!?*.java"/>
</wildcardResourcePatterns>
</component>
<component name="JavacSettings">
<option name="DEBUGGING_INFO" value="true"/>
<option name="GENERATE_NO_WARNINGS" value="false"/>
<option name="DEPRECATION" value="true"/>
<option name="ADDITIONAL_OPTIONS_STRING" value=""/>
<option name="MAXIMUM_HEAP_SIZE" value="128"/>
<option name="USE_GENERICS_COMPILER" value="false"/>
</component>
<component name="JikesSettings">
<option name="DEBUGGING_INFO" value="true"/>
<option name="DEPRECATION" value="true"/>
<option name="GENERATE_NO_WARNINGS" value="false"/>
<option name="GENERATE_MAKE_FILE_DEPENDENCIES" value="false"/>
<option name="DO_FULL_DEPENDENCE_CHECK" value="false"/>
<option name="IS_INCREMENTAL_MODE" value="false"/>
<option name="IS_EMACS_ERRORS_MODE" value="true"/>
<option name="ADDITIONAL_OPTIONS_STRING" value=""/>
<option name="MAXIMUM_HEAP_SIZE" value="128"/>
</component>
<component name="AntConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false"/>
<option name="FILTER_TARGETS" value="false"/>
</component>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY"/>
<option name="OPTION_SCOPE" value="protected"/>
<option name="OPTION_HIERARCHY" value="false"/>
<option name="OPTION_NAVIGATOR" value="false"/>
<option name="OPTION_INDEX" value="false"/>
<option name="OPTION_SEPARATE_INDEX" value="false"/>
<option name="OPTION_USE_1_1" value="false"/>
<option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="false"/>
<option name="OPTION_DEPRECATED_LIST" value="false"/>
<option name="OTHER_OPTIONS"/>
<option name="HEAP_SIZE"/>
<option name="OPEN_IN_BROWSER" value="false"/>
</component>
<component name="JUnitProjectSettings">
<option name="TEST_RUNNER" value="UI"/>
</component>
<component name="EntryPointsManager">
<entry_points/>
</component>
<component name="DataSourceManager"/>
<component name="ExportToHTMLSettings">
<option name="PRINT_LINE_NUMBERS" value="false"/>
<option name="OPEN_IN_BROWSER" value="false"/>
<option name="OUTPUT_DIRECTORY"/>
</component>
<component name="ImportConfiguration">
<option name="VENDOR"/>
<option name="RELEASE_TAG"/>
<option name="LOG_MESSAGE"/>
<option name="CHECKOUT_AFTER_IMPORT" value="true"/>
</component>
<component name="ProjectModuleManager">
<modules>
<!-- module filepath="$$PROJECT_DIR$$/${pom.artifactId}.iml"/ -->
<module filepath="$PROJECT_DIR$/server.iml"/>
</modules>
</component>
<UsedPathMacros>
<!--<macro name="cargo"></macro>-->
</UsedPathMacros>
</project>
This diff is collapsed.
......@@ -49,6 +49,7 @@ public class RoomExt extends SFSExtension {
//handled client requests
private final String NEXT_FRAME = "next_frame";
private final String SIM_DONE = "sim_done";
//internal messaging
protected static final String SET_TRACK = "set_track";
......@@ -99,7 +100,6 @@ public class RoomExt extends SFSExtension {
WeatherSettings weatherSettings = new WeatherSettings(isRainy ? Weather.RAIN : Weather.SUNSHINE);
SFSObject sfsSector = (SFSObject) getParentRoom().getProperty(SECTOR);
trace(sfsSector);
//build sector's world
this.sector = new MapSector(sfsSector);
VisualisationEnvironmentContainer world = WorldBuilder.getInstance().buildSectorMap(this.sector, mapId);
......@@ -108,7 +108,33 @@ public class RoomExt extends SFSExtension {
List<List<EnvNode>> intersections = new EnvObjectBO().getAllIntersections(this.sector.getArea().getBounds(), mapId);
this.controller = new SimulationController(frameLoopFreq, cacheBuffer, intersections);
this.controller = new SimulationController(frameLoopFreq, cacheBuffer, intersections, this::onSimulationDone);
}
/**
* Callback, used to detect when a primary vehicle is removed,
* i.e. the simulation for it is done.
*
* @param vehicleId
* @return
*/
public Void onSimulationDone(Long vehicleId) {
for(User user : this.getParentRoom().getUserList()) {
long vid = (long) user.getProperty(V_ID);
trace("Callback for id: " + vehicleId);
//update user's vid
if(vid == 0) {
vid = this.controller.getDelayedVehicleId((Long) user.getProperty(TRACK_ID));
user.setProperty(V_ID, vehicleId);
}
trace("Final user vid: " + vid);
//if vehicle simulation is done, allow user to start visualization
if(vid == vehicleId.longValue()) {
send(SIM_DONE, null, user);
}
}
return null;
}
@Override
......
......@@ -14,6 +14,7 @@ import com.smartfoxserver.v2.core.SFSEventType;
import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.SFSRoomRemoveMode;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSArray;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSArray;
import com.smartfoxserver.v2.entities.data.SFSObject;
......@@ -95,7 +96,6 @@ public class ZoneExt extends SFSExtension {
initWorld(getConfigProperties());
} catch (Exception e) {
trace(ExtensionLogLevel.ERROR, "Failed to initialize the world: " + e);
e.printStackTrace();
}
//initialize Business logic objects
......@@ -204,7 +204,7 @@ public class ZoneExt extends SFSExtension {
this.sectors = new SectorBO().getSectors(this.mapId);
}
trace("Loaded map: " + this.mapId);
//register map to be accessible from RoomExt
getParentZone().setProperty(MAP, this.mapId);
}
......@@ -330,7 +330,7 @@ public class ZoneExt extends SFSExtension {
CreateRoomSettings cfg = new CreateRoomSettings();
//general room settings
cfg.setName("Sector-" + sector.getId()); //just to keep the Room name unique
cfg.setName("Sector" + sector.getId()); //just to keep the Room name unique
cfg.setDynamic(true);
cfg.setGame(true);;
cfg.setMaxUsers(this.max_sect_users);
......@@ -354,4 +354,38 @@ public class ZoneExt extends SFSExtension {
}
return null;
}
/**
* Uploading scenarios via user's request.
*
* @param user
* @param params
*/
private void uploadScenario(User user, ISFSObject params) {
if(!params.containsKey("name") || !params.containsKey("tracks"))
trace(ExtensionLogLevel.WARN, "Missing parameters!");
WeatherSettings wSettings = new WeatherSettings(this.isRainy ? Weather.RAIN : Weather.SUNSHINE);
PathFinder finder = new PathFinder(this.sectors, wSettings, this.mapId);
List<ScenarioTrack> scenTracks = new ArrayList<ScenarioTrack>();
String scenarioName = params.getUtfString("name");
ISFSArray sfsTracks = params.getSFSArray("tracks");
for(int t=0; t<sfsTracks.size(); ++t) {
ISFSObject track = sfsTracks.getSFSObject(t);
String trackName = track.getUtfString("name");
long source = track.getLong("source");
long target = track.getLong("target");
List<NavigationPath> sections = finder.findCompletePath(new EnvObjectBO().getNode(source), new EnvObjectBO().getNode(target));
scenTracks.add(new ScenarioTrack(0, trackName, sections));
}
this.scenarioBo.add(scenarioName, this.mapId, scenTracks);
//update user's scenario list
send(GET_SCENARIOS, getScenarios(), user);
}
}
......@@ -14,7 +14,6 @@ public class SimulationBuffer {
/**
* Creates buffer with default limit (Integer.MAX_VALUE)
* @param user
*/
public SimulationBuffer() {
this(Integer.MAX_VALUE);
......@@ -22,8 +21,7 @@ public class SimulationBuffer {
/**
* Create buffer with given buffer size
*
* @param user
*
* @param bufferSize
*/
public SimulationBuffer(int bufferSize) {
......@@ -46,15 +44,18 @@ public class SimulationBuffer {
* Adds a new frame to the tail of the queue.
*
* @param frame
* @return true if and only if there has been enough space to put the new frame into the queue
*/
public void push(FrameData frame) {
public boolean push(FrameData frame) {
try {
this.frames.put(frame);
return true;
} catch (InterruptedException e) {
this.console.trace(ExtensionLogLevel.ERROR, "BlockingQueue: " + e);
return false;
}
}
/**
* Clears queue data and sets isDone flag to false
*/
......
package rwth.server.simulation.adapters;
/**
* JNI binding to a CPP class generated for the native model.
*
* @author Alexander Ryndin
*/
public final class AutopilotAdapter {
static {
// make sure the corresponding DLL is on the classpath
// when the java app with simulation is started
System.loadLibrary("AutopilotAdapter");
}
private boolean isInitialized = false;
public void execute() {
initialize();
exec();
}
public void initialize() {
if (!isInitialized) {
init();
isInitialized = true;
}
}
public native void set_timeIncrement(double timeIncrement);
public native void set_currentVelocity(double currentVelocity);
public native void set_x(double currentGpsLat);
public native void set_y(double currentGpsLon);
public native void set_compass(double compass);
public native void set_currentEngine(double currentEngine);
public native void set_currentSteering(double currentSteering);
public native void set_currentBrakes(double currentBrakes);
public native void set_trajectory_length(int length);
public native void set_trajectory_x(double[] x);
public native void set_trajectory_y(double[] y);
public native double get_engine();
public native double get_steering();
public native double get_brakes();
private native void exec();
private native void init();
}
\ No newline at end of file
package rwth.server.simulation.adapters;
import commons.controller.commons.BusEntry;
import commons.controller.interfaces.FunctionBlockInterface;
import org.apache.commons.math3.linear.RealVector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import simulation.vehicle.PhysicalVehicle;
import simulation.vehicle.VehicleActuatorType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Wraps {@link AutopilotAdapter} and implements {@link FunctionBlockInterface}.
*
* @author Alexander Ryndin
*/
public class AutopilotAdapterAsFunctionBlock implements FunctionBlockInterface {
private static final Logger LOG = LoggerFactory.getLogger(AutopilotAdapter.class);
private static final int MAX_TRAJECTORY_LENGTH = 100;
private final AutopilotAdapter adapter;
private final double[] trajectoryX = new double[MAX_TRAJECTORY_LENGTH];
private final double[] trajectoryY = new double[MAX_TRAJECTORY_LENGTH];
private PhysicalVehicle vehicle;
public AutopilotAdapterAsFunctionBlock(AutopilotAdapter adapter) {
this.adapter = adapter;
}
public void setVehicle(PhysicalVehicle vehicle) {
this.vehicle = vehicle;
}
public PhysicalVehicle getVehicle() {
return vehicle;
}
@Override
public void execute() {
adapter.execute();
}
@Override
public void setInputs(Map<String, Object> inputs) {
adapter.initialize();
double timeIncrement = (Double) inputs.get(BusEntry.SIMULATION_DELTA_TIME.toString());
double currentVelocity = (Double) inputs.get(BusEntry.SENSOR_VELOCITY.toString());
RealVector gps = (RealVector) inputs.get(BusEntry.SENSOR_GPS_COORDINATES.toString());
double x = gps.getEntry(0);
double y = gps.getEntry(1);
double compass = (Double) inputs.get(BusEntry.SENSOR_COMPASS.toString());
double engine = getCurrentActuatorValue(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_MOTOR);
double steering = getCurrentActuatorValue(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_STEERING);
double brakes = getCurrentActuatorValue(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_LEFT);
LOG.debug("velocity " + currentVelocity);
LOG.debug("position " + x + " " + y);
LOG.debug("actuation " + brakes + " " + engine + " " + steering);
adapter.set_timeIncrement(timeIncrement);
adapter.set_currentVelocity(currentVelocity);
adapter.set_x(x);
adapter.set_y(y);
adapter.set_compass(compass);
adapter.set_currentEngine(engine);
adapter.set_currentSteering(steering);
adapter.set_currentBrakes(brakes);
Object ptx = inputs.get(BusEntry.PLANNED_TRAJECTORY_X.toString());
Object pty = inputs.get(BusEntry.PLANNED_TRAJECTORY_Y.toString());
if (ptx instanceof List<?> && pty instanceof List<?>) {
int trajectoryLength = processTrajectory((List<Double>) ptx, (List<Double>) pty);
adapter.set_trajectory_length(trajectoryLength);
} else {
LOG.error("planned trajectory is not provided");
adapter.set_trajectory_length(0);
}
}
@Override
public Map<String, Object> getOutputs() {
adapter.initialize();
double engine = adapter.get_engine();
double brakes = adapter.get_brakes();
double steering = adapter.get_steering();
Map<String, Object> result = new HashMap<>();
result.put(
BusEntry.ACTUATOR_ENGINE.toString(),
engine
);
result.put(
BusEntry.ACTUATOR_BRAKE.toString(),
brakes
);
result.put(
BusEntry.ACTUATOR_STEERING.toString(),
steering
);
LOG.debug("control commands " + brakes + " " + engine + " " + steering);
return result;
}
@Override
public String[] getImportNames() {
return new String[0];
}
private double getCurrentActuatorValue(VehicleActuatorType type) {
return vehicle.getSimulationVehicle().getVehicleActuator(type).getActuatorValueCurrent();
}
private int processTrajectory(List<Double> xCoords, List<Double> yCoords) {
if (xCoords.size() != yCoords.size()) {
LOG.error(
"corrupt trajectory data: x has length "
+ xCoords.size()
+ " and y has length "
+ yCoords.size()
);
return 0;
}
int len = xCoords.size();
if (len > MAX_TRAJECTORY_LENGTH) {
LOG.warn(
"trajectory is too long ("
+ len
+ " coordinates), only first "
+ MAX_TRAJECTORY_LENGTH
+ " coordinates will be processed"
);
len = MAX_TRAJECTORY_LENGTH;
}
for (int i = 0; i < len; i++) {
Double x = xCoords.get(i);
Double y = yCoords.get(i);
if (x == null || y == null) {
LOG.error(
"corrupt trajectory data: x = " + x
+ " and y = " + y
+ " at index i = " + i
);
return 0;
}
trajectoryX[i] = x;
trajectoryY[i] = y;
}
logTrajectory(len);
adapter.set_trajectory_x(trajectoryX);
adapter.set_trajectory_y(trajectoryY);
return len;
}
private void logTrajectory(int len) {
StringBuilder sb = new StringBuilder("planned trajectory:");
for (int i = 0; i < len; i++) {
sb.append(" (");
sb.append(trajectoryX[i]);
sb.append(';');
sb.append(trajectoryY