Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 09-11-2017, 19:29   #1321
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 11,775
Re: Help / FAQ

Stn92

Attached is the EBL Properties page, note the choices available may be quite useful in solving your problem.

Rotate with boat
Maintain with heading or course over ground
EBL angle (port/starboard)
EBL Fixed end position
Show VRM
Always show EBL information
Persistant
Attached Thumbnails
Click image for larger version

Name:	EBL-Properties.jpg
Views:	42
Size:	70.6 KB
ID:	159004  
__________________

rgleason is offline   Reply With Quote
Old 10-11-2017, 03:11   #1322
Registered User

Join Date: Feb 2017
Posts: 22
Re: Help / FAQ

Two class B AIS transponders.
__________________

stn92 is offline   Reply With Quote
Old 10-11-2017, 14:03   #1323
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 11,775
Re: Help / FAQ

Have you tried the plugin yet?
rgleason is offline   Reply With Quote
Old 10-11-2017, 18:11   #1324
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,639
Re: Help / FAQ

Quote:
Originally Posted by stn92 View Post
Two class B AIS transponders.
Are you aware of their update frequency and accuracy? For docking a ship, I would expect something like at least a 10Hz high precision position/motion vector sources to be needed. Nothing like that is present in the class B equipment available on the market.
nohal is offline   Reply With Quote
Old 11-11-2017, 04:58   #1325
Registered User

Join Date: Feb 2017
Posts: 22
Re: Help / FAQ

Quote:
Originally Posted by rgleason View Post
Have you tried the plugin yet?
Yes i did. Thanks. But drawing the speed vectors which moving with boat, rotating with it and etc. - is not such difficult. I already did it.
[SPOILER]
Code:
            drawVector(false,ownship.v22.x, ownship.v22.y, v22);
            drawVector(true, ownship.v21.x, ownship.v21.y, v21);
            drawVector(false, ownship.v12.x, ownship.v12.y, v12);
            drawVector(true, ownship.v11.x, ownship.v11.y, v11);

void drawVector(bool out,  int posx, int posy, const Vector& v) {
    if (v.value > 1){ //если значение вектора не меньше порогового значения
        posx = floor(posx)*scale_factor_x;
        posy = floor(posy)*scale_factor_y;
        int value = -v.value*cc1->GetVPScale()*0.25;
        int angle = v.angle;
        angle -= gCog; // компенсируем угол поворота судна
        if (angle < 0) angle += 360;
        glTranslatef(posx, posy, 0);
        glRotatef(angle, 0, 0, 1);

        glBegin(GL_LINES);
        glVertex2f(0, 0);
        glVertex2f(0, value);
        glEnd();
      
        if (out){
            glBegin(GL_LINES);
            glVertex2f(0, value);
            glVertex2f(-5, value + 6);
            glEnd();

            glBegin(GL_LINES);
            glVertex2f(0, value);
            glVertex2f(5, value + 6);
            glEnd();
        }
        else {

            glBegin(GL_LINES);
            glVertex2f(0, 0);
            glVertex2f(-5, -6);
            glEnd();

            glBegin(GL_LINES);
            glVertex2f(0, 0);
            glVertex2f(5, -6);
            glEnd();

        }

        glRotatef(-angle, 0, 0, 1);
        glTranslatef(-posx, -posy, 0);
    }
}
[/SPOILER]

Now I need to find the point of the nearest intersection with the boundary of the s57 object(land, mole etc.). Just need the point. Draw a line to this point and calculate the distance - this is not a problem.
stn92 is offline   Reply With Quote
Old 11-11-2017, 06:34   #1326
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 11,775
Re: Help / FAQ

Nice, I guess you've got this figured out.

Perhaps look in weather_routing_pi code, where Sean figures out distance to GSHHS Background High Resolution and avoids land?

I could try to find that, but you're probably a lot faster at that than I am.

https://github.com/seandepagnier/weather_routing_pi

Would this become a new plugin?
rgleason is offline   Reply With Quote
Old 11-11-2017, 13:24   #1327
Registered User

Join Date: Feb 2017
Posts: 22
Re: Help / FAQ

Quote:
Originally Posted by rgleason View Post
Nice, I guess you've got this figured out.

I could try to find that, but you're probably a lot faster at that than I am.
I did not mean anything like that. I just wanted to say that my problem is not how to draw a vector. The language barrier greatly distorts the meaning. Sorry for wasting your time.
stn92 is offline   Reply With Quote
Old 18-11-2017, 03:50   #1328
Registered User

Join Date: Feb 2017
Posts: 22
Re: Help / FAQ

I figured out how to find closest intersection point with chart object.

This is the code. Maybe it will be useful to someone, too.

It retuns the lat/lon of the cosest intersection point with the specified object types on whole chart. The radius limitation does not work yet.

And example of using
Code:
std::vector<wxString> types = { "SLCONS", "LNDRGN", "LNDARE", "FLODOC", "PONTON" };
           
g_pi_manager->FindClosestObject(target_plugin_chart, gLat, gLon, 5, cc1->GetVP(), &minLat11, &minLon11, types);
      
dist11 = distance(gLat, gLon, minLat11, minLon11);
This is how it works. (not Paint this time)
stn92 is offline   Reply With Quote
Old 08-02-2018, 07:43   #1329
dnu
Registered User

Join Date: Feb 2018
Posts: 3
Plugin API interface form MMSI

Hello, and thank you for a brilliant piece of software!


Is there any interface in the plugin API to get information about a targeted ship in OpenCPN (the ship that I am currently Target Querying). Like the “Launcher” plugin (using SendPositionFixToAllPlugIns) can get information about my current position, I would like to use the “MMSI” of a random selected targeted ship, for quering information in an external source.


I have looked into the source code, but I have not been able to locate this interface.


Best regards, Daniel
dnu is offline   Reply With Quote
Old 08-02-2018, 08:03   #1330
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,639
Re: Plugin API interface form MMSI

Quote:
Originally Posted by dnu View Post
p { margin-bottom: 0.1in; line-height: 120%; } Hello, and thank you for a brilliant piece of software!


Is there any interface in the plugin API to get information about a targeted ship in OpenCPN (the ship that I am currently Target Querying). Like the “Launcher” plugin (using SendPositionFixToAllPlugIns) can get information about my current position, I would like to use the “MMSI” of a random selected targeted ship, for quering information in an external source.


I have looked into the source code, but I have not been able to locate this interface.


Best regards, Daniel
Daniel...
No, there currently is no such API. What exactly would be the usecase here? As in when exactly would the plugin get the information that "Something is needed to be done with MMSI xxxxxxxxx"

Anyway, probably ideal way to implement it is simply by sending an event through the SetPluginMessage API.

Very unfortunate you did not come a few days ago before 4.8.2 release, this development cycle will be big and long...

Pavel
nohal is offline   Reply With Quote
Old 08-02-2018, 08:09   #1331
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 2,245
Re: Plugin API interface form MMSI

Quote:
Originally Posted by dnu View Post
Hello, and thank you for a brilliant piece of software!


Is there any interface in the plugin API to get information about a targeted ship in OpenCPN (the ship that I am currently Target Querying). Like the “Launcher” plugin (using SendPositionFixToAllPlugIns) can get information about my current position, I would like to use the “MMSI” of a random selected targeted ship, for quering information in an external source.


I have looked into the source code, but I have not been able to locate this interface.


Best regards, Daniel
Daniel..
There's a JSON message for AIS targets.
See: AIS_Decoder_cpp
Search for "AIS_Decoder::SendJSONMsg"

Example extract from one plugin(radar_pi): (But it's used in many plugins.)
Code:
void radar_pi::SetPluginMessage(wxString &message_id, wxString &message_body) {
if (message_id == wxS("AIS") ) {
      wxJSONReader reader;
      wxJSONValue message;
      if (!reader.Parse(message_body, &message)) {
        wxJSONValue defaultValue(999);
        long json_ais_mmsi = message.Get(_T("mmsi"), defaultValue).AsLong();
        if (json_ais_mmsi > 200000000) {  // Neither ARPA targets nor SAR_aircraft
          wxJSONValue defaultValue("90.0");
          double f_AISLat = wxAtof(message.Get(_T("lat"), defaultValue).AsString());
          double f_AISLon = wxAtof(message.Get(_T("lon"), defaultValue).AsString());
..............................
Hakan is offline   Reply With Quote
Old 08-02-2018, 08:12   #1332
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 2,245
Re: Help / FAQ

Pavel is quicker and probably a better answer.
Hakan is offline   Reply With Quote
Old 08-02-2018, 08:19   #1333
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,639
Re: Plugin API interface form MMSI

Quote:
Originally Posted by Hakan View Post
Daniel..
There's a JSON message for AIS targets.
See: AIS_Decoder_cpp
Search for "AIS_Decoder::SendJSONMsg"

Example extract from one plugin(radar_pi): (But it's used in many plugins.)
Code:
void radar_pi::SetPluginMessage(wxString &message_id, wxString &message_body) {
if (message_id == wxS("AIS") ) {
      wxJSONReader reader;
      wxJSONValue message;
      if (!reader.Parse(message_body, &message)) {
        wxJSONValue defaultValue(999);
        long json_ais_mmsi = message.Get(_T("mmsi"), defaultValue).AsLong();
        if (json_ais_mmsi > 200000000) {  // Neither ARPA targets nor SAR_aircraft
          wxJSONValue defaultValue("90.0");
          double f_AISLat = wxAtof(message.Get(_T("lat"), defaultValue).AsString());
          double f_AISLon = wxAtof(message.Get(_T("lon"), defaultValue).AsString());
..............................
Yes, very similar to this, just not for every AIS message received but for the queried target.
Until such a direct API is available you could likely work it around with the existing APIs by building a target list from the data above and implement own mouse event handling in the MouseEventHook to get what you want.

Pavel
nohal is offline   Reply With Quote
Old 08-02-2018, 10:47   #1334
dnu
Registered User

Join Date: Feb 2018
Posts: 3
Re: Plugin API interface form MMSI

Quote:
Originally Posted by nohal View Post
Yes, very similar to this, just not for every AIS message received but for the queried target.
Until such a direct API is available you could likely work it around with the existing APIs by building a target list from the data above and implement own mouse event handling in the MouseEventHook to get what you want.

Pavel
… Dear Pavel and Haken

Thank you for both suggestions, I will investigate them further. I might also abuse the “navobj.xml.changes” file for obtaining the information – when I start tracking a vessel, the MMSI is posted to this file along with coordinates for temporary storage. I can easily detect this and piggybag that way.

My application is a little “obscured” compared to “normal” usage of OpenCPN. I use OpenCPN as a monitor tool, for coarse alignment of a directional measurement radar – so click and align, its just a little project in the name of science :-) It relies on AIS and ADSB translated to AIS (SAR) via GnuRadio in an offline environment. So I basically return the MMSI (/translated ICAO) to a backend tool which filters the position information and use this for coarse alignment.

Best regards, Daniel
dnu is offline   Reply With Quote
Old 08-02-2018, 10:53   #1335
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,639
Re: Plugin API interface form MMSI

Quote:
Originally Posted by dnu View Post

Thank you for both suggestions, I will investigate them further. I might also abuse the “navobj.xml.changes” file for obtaining the information – when I start tracking a vessel, the MMSI is posted to this file along with coordinates for temporary storage. I can easily detect this and piggybag that way.
Now this is a VERY bad idea Not to mention it will break as soon as you turn off recording track of the AIS targets...
__________________

nohal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 09:16.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.