How to make the vehicles collide in SUMO? - veins

I want to make Collision warning and emergency braking in veins with SUMO, but I find I can't make the two vehicles collide in SUMO. So What should I do to make the two vehicles collide in SUMO?
collision.net.xml
<net version="1.3" junctionCornerDetail="5" limitTurnSpeed="5.50">
<location netOffset="0.00,0.00" convBoundary="-300.00,0.00,300.00,0.00" origBoundary="10000000000.00,10000000000.00,-10000000000.00,-10000000000.00" projParameter="!"/>
<edge id=":gneJ1_0" function="internal">
<lane id=":gneJ1_0_0" index="0" speed=" 30" length="0.10" shape="0.00,-1.60 0.00,-1.60"/>
</edge>
<edge id="gneE0" from="gneJ0" to="gneJ1" priority="-1">
<lane id="gneE0_0" index="0" speed=" 30" length="300.00" shape="-300.00,-1.60 0.00,-1.60"/>
</edge>
<edge id="gneE1" from="gneJ1" to="gneJ2" priority="-1">
<lane id="gneE1_0" index="0" speed=" 30" length="300.00" shape="0.00,-1.60 300.00,-1.60"/>
</edge>
<junction id="gneJ0" type="dead_end" x="-300.00" y="0.00" incLanes="" intLanes="" shape="-300.00,0.00 -300.00,-3.20"/>
<junction id="gneJ1" type="priority" x="0.00" y="0.00" incLanes="gneE0_0" intLanes=":gneJ1_0_0" shape="0.00,0.00 0.00,-3.20 0.00,0.00">
<request index="0" response="0" foes="0" cont="0"/>
</junction>
<junction id="gneJ2" type="dead_end" x="300.00" y="0.00" incLanes="gneE1_0" intLanes="" shape="300.00,-3.20 300.00,0.00"/>
<connection from="gneE0" to="gneE1" fromLane="0" toLane="0" via=":gneJ1_0_0" dir="s" state="M"/>
<connection from=":gneJ1_0" to="gneE1" fromLane="0" toLane="0" dir="s" state="M"/>
</net>
collision.rou.xml
<routes>
<vType sigma="0" id="t1" maxSpeed="70" minGap="0"/>
<route edges="gneE0 gneE1" color="yellow" id="route_0"/>
<vehicle id="vehicle_0" depart="0.00" departPos="100.00" departSpeed="0" color="red" route="route_0" type="t1"/>
<vehicle id="vehicle_1" depart="0.00" departPos="95.00" departSpeed="20" color="blue" route="route_0" type="t1"/>
</routes>

Citing https://sumo.dlr.de/docs/Simulation/Safety.html#deliberately_causing_collisions: To force collisions at a set time, TraCI must be used. Besides setting the speed, it is also necessary to disable safety checks using the commands speedMode and laneChangeMode.
This might be hard to do in the context of Veins.

Set the "--default.action-step-length" parameter as "0.5"
Than you can create a method to set following parameters on a vehicle. For sure it will collide with any leading vehicle. (make sure Tau is smaller than action step length)
def add_aggressive_behavior(veh_id):
traci.vehicle.setAccel(veh_id, 10)
traci.vehicle.setDecel(veh_id, 4)
traci.vehicle.setEmergencyDecel(veh_id, 0.1)
traci.vehicle.setApparentDecel(veh_id, 0.1)
traci.vehicle.setTau(veh_id, 0.01)
traci.vehicle.setImperfection(veh_id, 0.1)
traci.vehicle.setLaneChangeMode(veh_id, 0)

First:setSpeedMode(0)
Second: Set the speed of the car behind enough,setSpeed(100);
Then two cars will collide!!!

If you are interested in developing algorithms for the vehicular collision warning system, you may need to predict the collision time and place rather than implementing it. Otherwise, you may create a route file with multiple flows approaching from different directions to simulating a collision.

Related

How to list the two most recent folders inside a directory using their timestamp

I have a parent folder and inside that I have a few folders. For an automation, I want to take the latest of the two folders according to timestamp.
I have tried to take the latest folder by using timstampselector.
<timestampselector property="latest.modified">
<path>
<dirset dir="MyDirectoryPath">
<include name="*" />
</dirset>
</path>
</timestampselector>
Inside my parent folder, I have the following folders:
test (Last modified on 07/04/2019 10:30 AM)
check (Last modified on 08/04/2019 05:00 PM)
integrate (Last modified on 08/04/2019 12:30 PM)
slave (Last modified on 09/04/2019 05:00 PM)
Our script should take the latest two modified folders, which is in the above case it should be integrate & slave.
How can I achieve that?
Generally speaking, it's a good idea to stay away from ant-contrib whenever possible. This particular problem can be quickly solved with native Ant's resource collections:
<last count="2" id="latest.two.files">
<sort>
<date />
<fileset dir="MyDirectoryPath" />
</sort>
</last>
Full example target:
<target name="select-latest">
<delete dir="testdir" />
<mkdir dir="testdir" />
<touch file="testdir/test" datetime="07/04/2019 10:30 AM" />
<touch file="testdir/check" datetime="08/04/2019 05:00 PM" />
<touch file="testdir/integrate" datetime="08/04/2019 12:30 PM" />
<touch file="testdir/slave" datetime="09/04/2019 05:00 PM" />
<last count="2" id="latest.two.files">
<sort>
<date />
<fileset dir="testdir" />
</sort>
</last>
<echo message="${toString:latest.two.files}" />
</target>
The task you are using is part of Ant-Contrib rather than core Ant. The documentation says you can use the count attribute to say how many items you want to select. In your case, set it to two:
<timestampselector property="latest.modified" count="2">
<path>
<dirset dir="MyDirectoryPath">
<include name="*" />
</dirset>
</path>
</timestampselector>
This appeared to work fine for me: the property was set to a comma-separated list of two directories.

What are the valid options for unit of measure when using the Amazon MWS feed api

Trying to upload a product using the Amazon mws feed api and my request is getting rejected. The error message from Amazon says I need to specify the unit of measure but I can't find the valid options for unitOfmeasure anywhere in the schema amazon publishes.
This is my body I am sending to Amazon:
<?xml version='1.0' encoding='iso-8859-1'?>
<AmazonEnvelope>
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>A326GY9JGCP2ET</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>cpa56309</SKU>
<StandardProductID>
<Type>UPC</Type>
<Value>7426895714885</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Maximum Comfort CPAP Headgear Universal Replacement Strap for Masks * 4-Point Connection Works for Most All Nasal & Full-face Sleep apnea Masks - Sleep Apnea, Anti-Snoring Equipment</Title>
<Brand>wiser Innovations</Brand>
<Description>This is a <b>bold</b> test</Description>
<BulletPoint>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</BulletPoint>
<BulletPoint>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</BulletPoint>
<BulletPoint>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</BulletPoint>
<BulletPoint>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</BulletPoint>
<BulletPoint>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</BulletPoint>
<MSRP currency='USD'>22</MSRP>
<Manufacturer>Wiser</Manufacturer>
<SearchTerms>MORE COMFORT-Super comfortable, ultra soft, no-irritation neoprene strap</SearchTerms>
<ItemType>cpap-accessories</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<UnitCount unitOfMeasure='1'>1</UnitCount>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
This is the schema definition for uploading misc health products for unitcount
<xsd:element name="UnitCount" minOccurs="0">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:decimal">
<xsd:attribute name="unitOfMeasure" type="StringNotNull"
use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
Anyone know where to find the options for unitOfMeasure? I have tried Individual and Box.
I think unitOfMeasure attribute should store any string representing a measure. For example GR which is gram. Or Fl Oz which is Fluid Ounces.

Use ros launch to create a directory and then pass it's path to different nodes

At runtime (when I call roslaunch), I want to create a new subdirectory in a known directory, and pass that path to two different nodes as a rosparam.
How can I edit my .launch file to do this?
For example,I have the folder ~/datacapture. whenever I use roslaunch, I want to create a subdirectory based on the current time, (ie ~/datacacpture/20161129_1352/) and pass that into a few nodes using rosparams.
To further explain what I want to do, here is an example roslaunch file:
<launch>
<node
name="node_A"
pkg="pkg_A"
type="A"
output="screen"
>
<param name="dataDumpFolder" value="???" />
</node>
<node
name="node_B"
pkg="pkg_B"
type="B"
output="screen"
>
<param name="dataDumpFolder" value="???" />
</node>
</launch>
What i want it to look like is this:
<launch>
#1) create a new folder using current date.
#2) pass it's filepath into a variable. let's call the variable, NEW_FOLDER_FILE_PATH
<node
name="node_A"
pkg="pkg_A"
type="A"
output="screen"
>
<param name="dataDumpFolder" value="NEW_FOLDER_FILE_PATH" />
</node>
<node
name="node_B"
pkg="pkg_B"
type="B"
output="screen"
>
<param name="dataDumpFolder" value="NEW_FOLDER_FILE_PATH" />
</node>
</launch>
This is not possible in any generic way. It's also not a good idea as (a) roslaunch was not meant for this and (b) the error handling will be interesting.
If there is any way to not require a shared folder name, or if you could pre-determine it and pass it on to the launch file as argument, or if you could have a node that provides the filename (as service or via latched topic), this may be preferable.
That said, the best option to do this within roslaunch is to write a small shell script that creates the required folder and prints the name to stdout. This allows you to use <param name="dataDumpFolder" command="your script" />. You may need to remove some whitespace before using the value.

vo_ros/vo: malloc(): memory corruption caused by image size?

I want to set up the monocular visual odometry system by the Robotics and Perception Group of the university of Zurich for a robotics project. Project site is https://github.com/uzh-rpg/rpg_svo. They implemented it as ROS node what is really cool, but when I launch the svo_ros node roslaunch svo_ros live.launch I get an error:
[ INFO] [1455715165.624976791]: SVO initialized
[ INFO] [1455715165.625768093]: Found parameter: svo/cam_topic, value: /image_raw
[ INFO] [1455715197.445786640]: RESET
*** Error in `/home/user/workspace/indigo/devel/lib/svo_ros/vo': malloc(): memory corruption: 0x0000000001187920 ***
I would guess this is caused by a wrong image size configuration, so the OpenCV functions used by svo corrupt the memory working on the images.
I calibrated my camera using the camera_calibration ros node. I translated the output to the .yaml-file representation in the /param/camera_pinhole.yaml as follows
cam_model: Pinhole
cam_width: 644
cam_height: 484
cam_fx: 588.481298
cam_fy: 587.819899
cam_cx: 328.046456
cam_cy: 226.471844
cam_d0: -0.363501
cam_d1: 0.165011
cam_d2: 0.000571
cam_d3: -0.000577
As I got the image resolution 644x484 from the calibration data and confirmed it using the image_view node of the image_view package, I would say the image cam_width and height I configured is correct. I even tried to set image_width and image_height in launch-filge to the same size, but it didn't change anything.
<launch>
<node pkg="svo_ros" type="vo" name="svo" clear_params="true" output="screen">
<!-- param name="image_width" value="644" type="int" />
<param name="image_height" value="484" type="int" />
<param name="cam_width" value="644" type="int" />
<param name="cam_height" value="484" type="int" / -->
<!-- Camera topic to subscribe to -->
<param name="cam_topic" value="/image_raw" type="str" />
<!-- Camera calibration file -->
<rosparam file="$(find svo_ros)/param/camera_pinhole.yaml" />
<!-- Default parameter settings: choose between vo_fast and vo_accurate -->
<rosparam file="$(find svo_ros)/param/vo_fast.yaml" />
</node>
</launch>
Did I miss to fit any parameters or other configurations or does someone have an other ideas what is wrong?
Thanks in advance.
I actually found a solution to this issue.
It was caused when making the image pyramid when the image had an odd number of columns.
I fixed it by modifying the file rpg_vikit/vikit_common/src/vision.cpp
Line 91 previously read:
const int stride = in.step.p[0];
I changed it to:
const int stride = in.step.p[0]/2 * 2;

MapForce - Add dayTimeDuration to dayTimeDuration

I am trying to use mapforce to generate an xslt 2.0 file. The mapping is adding 2 dayTimeDuration elements, doing so results in the following error;
No match for core.add(xs:dayTimeDuration, xs:dayTimeDuration). Check argument types.
Supported: +(xs:double, xs:double) -> xs:double
I thought that xslt 2.0 supported adding 2 dayTimeDurations. Is there a way of doing this using mapforce?
Cheers
Stew
Had almost the same problem, first tried to add functx-library but saw it creates absolute path in the generated xslt2-code, which isn't very good.
Well, turns out you can implement that function, but first you have to do some modifications...
Find your Mapforce installation directory, and MapForceLibraries -subdirectory. From that open the "core.mff", and find
<group name="math functions">
<component name="add" growable="true" growablebasename="value">
<sources>
<datapoint name="value1" type="xs:decimal"/>
<datapoint name="value2" type="xs:decimal"/>
</sources>
<targets>
<datapoint name="result" type="xs:decimal"/>
</targets>
As you can seem the "sources" and "targets" elements seems to define the in- and out data types. As it is, they have only implemented "add"-function for "xs:decimal". You can copy/paste this component, then rename it and give new in- out- data types, in your case they are both "xs:dayTimeDuration". Note that there are implementations for each supported language, but you can omit those that are not needed. Here's
what should work:
<component name="addDayTimeDuration" growable="true" growablebasename="value">
<sources>
<datapoint name="value1" type="xs:dayTimeDuration"/>
<datapoint name="value2" type="xs:dayTimeDuration"/>
</sources>
<targets>
<datapoint name="result" type="xs:dayTimeDuration"/>
</targets>
<implementations>
<implementation language="xslt">
<operator value="+"/>
</implementation>
<implementation language="xslt2">
<operator value="+"/>
</implementation>
<implementation language="builtin">
<function name="Core_Add"/>
</implementation>
</implementations>
<description>
<short>result = value1 + value2</short>
<long>Result is the dayTimeDuration value of adding value1 and value2.</long>
</description>
</component>
Your new function should now appear in the "math functions" and should be good to use.
After contacting Altova (the makers of MapForce);
While XPath 2 does offer a subtract-dayTimeDurations operation, this is not presently offered as a function inside MapForce.