How to get speed and angle for a certain node - omnet++

i have been doing modification to TraCIDemo11p.cc file and i want to get the position , speed and angle for a certain node" node[8]". i know how to use getCurrentPosition() ,getCurrentSpeed() & getAngleRad() but i don't know how to refer (point) to the node .
i already checked the following question and answer and i could get the position only
How to get RSU coordinate from TraCIDem11p.cc?
i think i don't know how to use getParentModule() and getSubmodule() .
iam using veins 4.4 , sumo 0.25 , omnet 4.5

Using OMNeT++, you can get a cModule* that refers to any named node. As you already know that each of your cars will have a mobility module of a well-known name, this part is straightforward. From there, it's just an issue of casting the returned pointer to the right type (TraCIMobility).

Related

Moving an Object In Gazebo using ROS2 Terminal Commands

I have a project in which I have to move a cube in a Gazebo simulation. I need to do so using the terminal.
I recently had Ubuntu 21.10 with Gazebo 11 and ROS1 Noetic installed and had this working perfectly. I essentially just followed this tutorial: How to Move a Gazebo Model from Terminal
But I had to upgrade to Ubuntu 22.04 and I now have Gazebo 11.10.2 and ROS2 Humble.
I was able to get the current position of the cube thanks to this post:
/gazebo/get_model_state in ROS2 not present
So I modified my world file and used the command: ros2 service call /get_entity_state gazebo_msgs/GetEntityState '{name: cube1, reference_frame: world}' and I was able to get the location of the cube.
I figured the reverse would be something like: ros2 service call /set_entity_state gazebo_msgs/SetEntityState '{name: cube1, Pose:position{x:20, y:0, z:0}, reference_frame: world}' but I get an error saying Failed to populate field: 'SetEntityState_Request' object has no attribute 'name'. However, running ros2 interface show gazebo_msgs/srv/SetEntityState we can see that 'name' absolutely is an attribute:
gazebo_msgs/EntityState state # Entity state to set to.
string name #
# An entity can be a model, link, collision, light, etc.
# Be sure to use gazebo scoped naming notation (e.g. [model_name::link_name])
geometry_msgs/Pose pose #
Point position
float64 x
float64 y
float64 z
Quaternion orientation
float64 x 0
float64 y 0
float64 z 0
float64 w 1
geometry_msgs/Twist twist #
Vector3 linear
float64 x
float64 y
float64 z
Vector3 angular
float64 x
float64 y
float64 z
string reference_frame #
# Leaving empty or "world" defaults to inertial world frame.
# Be sure to fill all fields, values of zero have meaning.
---
bool success # Return true if setting state was successful.
So I am unsure of the syntax and the documentation that I could find does not really help:
ROS 2 Documentation: Humble
ROS 2 Migration: gazebo_ros_api_plugin
ROS 2 Migration: Entity states
Should I use ros2 topic pub as in this tutorial: How to Simulate a Robot Using Gazebo and ROS 2? If so, how? What is the syntax? I've also tried modifying the the output of GetEntityState and pasting into the argument of SetEntityState but get errors relating to the input being a string and not a dictionary, and other various syntax errors.
TL;DR: How do I move an object in Gazebo using ROS2 commands from the terminal, such as in this tutorial: How to Move a Gazebo Model from Terminal?
Thank you.

Figuring out coordinate format contained in SDO_ORDINATE_ARRAY attribute

I am working with some data which specifies an installation path, in another data source I have the location of events based on their lat/long location.
The installation location contained in the oracle attribute SDO_ORDINATE_ARRAY does not match any X/Y geographic coordinate system I am familiar with (Lat/Long or UTM). Is there a way to figure out what the data type is that is stored in the SDO_ORDINATE_ARRAY?
Here is an example of the data for a path with 3 (x,y) points:
MDSYS.SDO_GEOMETRY(2002,1026911,NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),
MDSYS.SDO_ORDINATE_ARRAY(
1352633.64991299994289875030517578125,
12347411.6615570001304149627685546875,
1352638.02988700009882450103759765625,
12347479.02890899963676929473876953125,
1352904.06293900008313357830047607421875,
12347470.76137300021946430206298828125,
))
The above should be roughly within the proximity to 33.9845° N, 117.5159° W, and I went through various conversions but could not find anything that led me anywhere close to the above.
I read through the documentation on SDO_GEOMETRY from the oracle page and did not find any help in figuring out what the data type is.
https://docs.oracle.com/database/121/SPATL/sdo_geometry-object-type.htm#SPATL494
Alternatively, if there is a way I can type in the lat/long somewhere to see all of the different coordinate types which are equivalent, I might also be able to figure out which format this is.
Looks like there is a typo inside MDSYS.SDO_GEOMETRY(2002,1026911,NULL,
1026911 is supposed to be a SRS - Spatial Reference System.
If we remove the first 1 we have 102691, and that is a very well known SRS code.
ESRI:102691 for NAD 1983 for StatePlane Minnesota North FIPS 2201 Feet
The corresponding WKT gives you all the necessary information to perform any coordinate conversion:
PROJCS["NAD_1983_StatePlane_Minnesota_North_FIPS_2201_Feet",
GEOGCS["GCS_North_American_1983",
DATUM["North_American_Datum_1983",
SPHEROID["GRS_1980",6378137,298.257222101]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["False_Easting",2624666.666666666],
PARAMETER["False_Northing",328083.3333333333],
PARAMETER["Central_Meridian",-93.09999999999999],
PARAMETER["Standard_Parallel_1",47.03333333333333],
PARAMETER["Standard_Parallel_2",48.63333333333333],
PARAMETER["Latitude_Of_Origin",46.5],
UNIT["Foot_US",0.30480060960121924],
AUTHORITY["EPSG","102691"]]

Units of an elasticsearch query to get distance from arbitrary point to Geopoint

I have a django project which uses elasticsearch 6.5.3 to index products in a store with locations as GeoPoints. I am trying to query this index and also calculate distance between an arbitrary point, say user's location to each oh these results.
I am using elasticsearch_dsl and my code looks something like this:
search_query = search_query.script_fields(distance={
'script':{
'inline':"doc['location'].arcDistance(params.lat, params.lon)",
'params': {
'lat':user_loc.lat,
'lon':user_loc.lon
}
}
})
for result in search_query.execute():
print(result.distance)
Which gives me values that looks like:
[123456.456879123]
But I'm not sure about its units.
By using and online distance calculator in https://www.nhc.noaa.gov/gccalc.shtml,
which gives me the distance as ~123km,
It looks like value is in meters.
So:
1. Where can I find some definitive answers about its units?
Please point me to the relevant documentation for these methods.
I am also interested to know if there is a way to specify the units expected for the results in the method call.
2. Is there a better way to do this in python?
The units are those returned by the arcDistance method providing the value in your script.
The arc distance (in meters) of this geo point field from the provided lat/lon
The painless docs leave a lot to be desired (there appears to be no docs on this method in 6.5). The quote above was obtained from here: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/modules-scripting.html
Additionally, they mention arcDistance caluclates meters here: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_scripting.html
I'm not sure about the exact python API, but elasticsearch have Geo Distance Query:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
In: https://github.com/elastic/elasticsearch-dsl-py/issues/398 there's an example of python usage of ES API:
MyDocType.search().filter(
'geo_distance', distance='1000m', location={"lat": "40", "lon": "-74"}
)
The 'geo_distance' query is the easiest way to get a distance between two geo points indexed to elasticsearch. I thinking that you don't need to use scripting in order to achieve that.
Regarding the distance unit, as you suspected the default is meters. from:
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#distance-units
Wherever distances need to be specified, such as the distance parameter in the Geo Distance Query), the default unit if none is specified is the meter.

Need help understanding Tango's functions related to coordinate systems

I am confused by parameters of those functions related to coordinate systems, for eample:
TangoSupport_getMatrixTransformAtTime(double timestamp,
TangoCoordinateFrameType base_frame,
TangoCoordinateFrameType target_frame,
TangoSupportEngineType base_engine,
TangoSupportEngineType target_engine,
TangoSupportDisplayRotation display_rotation_type,
TangoMatrixTransformData *matrix_transform)
(1)Base_engine: If I choose COORDINATE_FRAME_START_OF_SERVICE as base_frame . As described in the document, the coordinate system will use "Right Hand Local Level" . Then, what's the purpose of the base_engine parameter ? Is it meaningful here to choose something other than TANGO_SUPPORT_ENGINE_TANGO ?
(2) Target_engine: I choose COORDINATE_FRAME_START_OF_SERVICE as base_frame , and DEVICE as target. choose OPENGL for base_engine. then choose any value for target_engine. the result is always same
(1)Base_engine: If I choose COORDINATE_FRAME_START_OF_SERVICE as base_frame . As described in the document, the coordinate system will use "Right Hand Local Level" . Then, what's the purpose of the base_engine parameter ? Is it meaningful here to choose something other than TANGO_SUPPORT_ENGINE_TANGO ?
This really depends on your use case. It is rare that you use Tango coordinate as base frame, unless you have another set of transformation that transform start service to local origin.
Let's say you did a query like this: TangoSupport_getMatrixTransformAtTime(0.0, START_SERVICE, DEVICE, TANGO, TANGO,...); it is quavalant of doing a TangoService_getPoseAtTime query with start service and device frame pair.
More common case is that you want to transform something(i.e depth point) in to your local origin (i.e OpenGL origin) for render. What you will do is: TangoSupport_getMatrixTransformAtTime(0.0, START_SERVICE, DEPTH, OPENGL, TANGO,...);, the result of this call is opengl_T_depth_camera, you can then multiply this transform to the depth point returned from depth camera: P_opengl = opengl_T_depth_camera * P_depth_camera;. P_opengl is the point you can render out directly in OpenGL.
(2) Target_engine: I choose COORDINATE_FRAME_START_OF_SERVICE as base_frame , and DEVICE as target. choose OPENGL for base_engine. then choose any value for target_engine. the result is always same
This should be true for OPENGL and TANGO. There's a happy coincedent that opengl coordinate is same as the device frame coordinate. So if you put TANGO or OPENGL on the target_frame, the result will be the same. But if you put UNITY as target engine type, the result will be different.

How to get the 'current observation data' from the NDFD (NOAA, NWS) REST service?

I'm trying to use the NDFD (National Digital Forecast Database) to get current temperature and relative humidity given a Lat and Long using their REST based service.
The issue at hand:
I can't match the 'current observation data' WITH the 'results' I get back from the REST-service.
The setup:
Location:
* Apple (1-infinite loop, Cupertino, California)
* Lat = 37.33; Lon = -122.03
If I issue the following REST-call:
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?lat=37.33&lon=-122.03&product=time-series&begin=2009-06-21T17:12:35&end=2009-06-21T17:12:35&appt=appt&rh=rh&temp_r=temp_r&temp=temp
Note 1: I'm passing the begin and end time in UTC. They're the same because I'm
looking for just a single-point-in-time: the latest observed
temp and relative humidity.
AND, then compare it to what is the closet reporting stations (San Jose International Airport, CA - KSJC - 37.37N 121.93W) # http://www.weather.gov/xml/current_obs/KSJC.xml
** I can never get them to MATCH. **
Note 2: The nearest reporting station is return back from the REST call
as well, so I know I'm comparing Location apples to Location apples.
I've had two ideas:
1: I'm doing something wrong with how I'm passing in the begin/end times into the REST call...
2: You can't get 'current observed data' the way I'm trying to...
Lastly:
I've found a solution using outoftime's NOAA ruby lib , [it parses an observation stations YAML file to find the nearest one given Lat/Lng then goes directly to that station via its identifier i.e. http://www.weather.gov/xml/current_obs/KSJC.xml].... but it just feels like I may be missing something obvious here and would like to use the REST-based interface ;)
Any help or pointers would be appreciated!
Thanks!
It looks like the service you are calling isn't for current data. Judging by the URL and the XML results it seems to be for forecasts. You can also put in future dates to get future forecast data. It expects the dates to be in the -0700 time zone according to the response. I'm not sure which service you should be calling to get the data you want though.
I know that this is an old question, but this is what I'm using to get current weather conditions: http://forecast.weather.gov/MapClick.php?lat=43.09110&lon=-79.0162&unit=0&lg=english&FcstType=dwml
Found this api/link yesterday. Its still developmental (operation-mode="developmental"):
http://forecast.weather.gov/MapClick.php?lat=37.33&lon=-122.03&FcstType=dwml
If you want the "current" observation, you use the XML here:
http://w1.weather.gov/xml/current_obs/seek.php?state=or&Find=Find
e.g.,:
http://w1.weather.gov/xml/current_obs/KAST.xml
If you click on the link you'll get a rendered page. However, if you pull from it using normal rest methods or just wget, it delivers an xml file.

Resources