Sumo and Traci : LastStepVehicleNumber does not update - sumo

I am using Sumo 0.27.1 and the Traci interface.
I am trying to get the number of vehicles occupying a lane and for that
I use the following java code :
Repository<Lane> lanes = conn.getLaneRepository();
Map<String, Lane> laneMap = lanes.getAll();
Iterator<Entry<String, Lane>> laneMapIterator = laneMap.entrySet().iterator();
while(laneMapIterator.hasNext())
{
Entry<String, Lane> laneElem = laneMapIterator.next();
Lane l = laneElem.getValue();
if (!l.getID().startsWith(":"))
{
System.out.println("Lane ID: "+ l.getID() + " CO2: " + l.getCo2Emission());
System.out.println("Lane ID: "+ l.getID()
+ " Occupancy: " + l.getLastStepOccupancy() + " Vehicle Number: "
+ l.getLastStepVehicleNumber());
}
}
Although there are many cars introduced in the simulation, I can the
CO2, occupancy and vehicle number for just 3 of the lanes; and I get the
same numbers during the simulation.
A similar code is working fine for getting individual vehicle meters,
but does not work for lanes.
I there any update or reset command that I should explicitly take care of ?
Thanks in advance,
Vlad

Related

How to fix the issue of output file not appearing, after having launched a run configuration?

I work on CVRP in combinatorial optimization, where the goal is to compare several models on several instances, using the OPL language. For this to e done, I first wrote and tested the said models; then I wrote an main flow control supposed to run each instance for a 2 hours duration.
My problem is that after 2 hours, and this for each model, the output file appears for some instances, containing the desired information; but for other instances, the output files do not appear, as if these instances do not exist. This problem persists even when you launch one or more of these instances in isolation.
below is the main flow control code, where BPF designates the name of the .mod file, which is simply modified in the code, when one wishes to switch to another model.
{string} datFiles=...;
main {
var source = new IloOplModelSource("BPF.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
cplex.tilim=2*60*60;
cplex.threads=1;
for(var datFile in thisOplModel.datFiles)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataSource(datFile);
opl.addDataSource(data2);
opl.generate();
var o=new IloOplOutputFile("BPF "+datFile+".txt");
if (cplex.solve()) {
if(cplex.getCplexStatus()==11){
o.writeln("instance : " + datFile
+" / opt = "
+ " / UB = " + cplex.getObjValue()
+ " / LB = " + cplex.getBestObjValue()
+" / time = " + " - "
+" / Gap = "+cplex.getMIPRelativeGap()*100+"%");
}
else {
o.writeln("instance : " + datFile
+ " / opt = " + cplex.getObjValue()
+ " / UB = " + cplex.getBestObjValue()+"*"
+" / time = " + cplex.getSolvedTime()
+ " / Gap : -");
}
o.close();
}
opl.end();
}
}

How to get anchor point of SymbolItem

I can't figure out how to retrieve registration point that I see in properties panel transform section in script.
I use this script documentation http://ai.aenhancers.com/jsobjref/SymbolItem/
As far as I can tell they are just coordinates of the symbol's center. You can get them this way:
var symbol = app.activeDocument.selection[0];
var X = symbol.position[0] + symbol.width/2;
var Y = -symbol.position[1] + symbol.height/2;
alert("X: " + X + "\n" + "Y: " + Y);

Need help understanding how Eclipse IProgressMonitor works

I am using Eclipse IProgressMonitor to monitor the progress of a task. There are four steps, and I write the following code.
int totalWork = 100;
String message = "Compiling " + inputFile.getName();
monitor.beginTask(message, totalWork);
monitor.subTask(message + " - first pass");
...// Work
monitor.worked(25);
if (monitor.isCanceled())
return;
monitor.subTask(message + " - invoking");
...// work
monitor.worked(25);
if (monitor.isCanceled())
return;
monitor.subTask(message + " - second pass");
...// Work
monitor.worked(25);
if (monitor.isCanceled())
return;
monitor.subTask(message + " - final pass");
...// Work
monitor.worked(25);
if (monitor.isCanceled())
return;
monitor.done();
As I have total work 100, and each step increase it by 25, I am hoping to see the progress bar show 25% 50% etc. and increase. However the progress bar stops at some number (33%, 38%, 20%, kind of random on different machines) and does not change until the entire job is done. The task name changes though. I read the JavaDoc for this API and follow the way it suggests (I think). Can anyone help tell me where I went wrong?

supercollider arduino serial communication

I am working on an arduino uno + supercollider 3 project.
Basicly: I have an arduino set up with potentiometers, a sensor and some buttons. I put the data of inputs in an array and send it to my computer trough serial.
Currently, my output in the Arduino serial monitor is as this:
271:189:75:0:0:0:1:0:0:0:0:0
If I open the serial connection in Supercollider, what arrives is this:
271
Only the first value in the array arrives correctly. (The same setup with just 1 Arduino input to Supercollider worked like a charm, by the way. I just can't get it working with an array of inputs from arduino to SC3.)
arduino code to send data at this moment:
teSturen = String(val_lichtPin) + ":" + String(val_Pot1Pin) + ":" + String(val_Pot2Pin) + ":" + String(val_Pot3Pin) + ":" + String(val_Pot4Pin) + ":" + String(val_Pot5Pin) + ":" + String(knop1Staat) + ":" + String(knop2Staat) + ":" + String(knop3Staat) + ":" + String(knop4Staat) + ":" + String(knop5Staat) + ":" + String(knop6Staat);
Serial.println(String(teSturen));
I put all the numbers together in one string with an : as seperator, then send this.
SC3 code to receive:
~ino = ArduinoSMS("/dev/ttyACM0",9600);
~ino.action = {
arg msg;
var amsg;
//amsg = msg.split($:);
msg.postln;
};
There is more code, but that is for appointing vars and args, defining synths, et cetera. I limited this to the bits where it doesn't work.
Any ideas on why SC3 only receives the first number? I have tried for example to recplace the seperator : by , or ;, to send it as multiple integers in stead of one string, ...
The goal of it for me, is to be able to control various synths in supercollider with fysical control potentiometers, because that's a lot more fun to play with than keyboard or mouse controlling synths...
I appreciate any help, thank you!
Pretty late, but this still might help. I used the same setup some years ago. I used
p = ArduinoSMS("/dev/tty.usbmodem3d11", 115200);
while{state==0}{
p.action = { |... msg| m=[msg[0],msg[1]];
do something with m[0] and m[1] ...
};
to parse the message stream. My setup only read arrays of two bytes (msg[0]and msg[1]), but this should be expandable.
The full source code is available on https://github.com/symbolrush/FridgeKiller and another project with the same setup on https://github.com/symbolrush/ColliDuino.
Hope this helps and good luck!

Recorded Skeleton Data

The following is code I have used to try to record skeleton frame data
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame == null)
return;
this.Recorder.Record(skeletonFrame);
}
if the code above is run, what information is recorded?
If I were to save this information to an external file, what would I see?
Would there be coordinate information and a specific timestamp associated with each coordinate information?
Are you looking at recording the X, Y, Z data of the skeleton into a text file? It is generally easier to record the information separately in readable format. If you are looking at doing the aforementioned then this may help:
//save the XYZ of the skeleton data, but also save the XZ of depth data
private void saveCoordinates(Skeleton skeleton, string textFile)
{
StreamWriter coordinatesStream = new StreamWriter(newPath + "\\" + textFile);
foreach (Joint joint in skeleton.Joints)
{
coordinatesStream.WriteLine(joint.JointType + ", " + joint.TrackingState + ", " + joint.Position.X + ", " + joint.Position.Y + ", " + joint.Position.Z);
}
coordinatesStream.Close();
}