Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gm_kerbal_adaptor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christopher Reis
gm_kerbal_adaptor
Commits
d1942a0a
Commit
d1942a0a
authored
Apr 18, 2017
by
Christopher Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Navigation and Docking Messages
parent
2f16e510
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
264 additions
and
46 deletions
+264
-46
PublishThread.cpp
PublishThread.cpp
+61
-36
PublishThread.hpp
PublishThread.hpp
+1
-0
dictionary.json
dictionary.json
+202
-10
No files found.
PublishThread.cpp
View file @
d1942a0a
...
@@ -27,9 +27,8 @@ using namespace gmsec::api;
...
@@ -27,9 +27,8 @@ using namespace gmsec::api;
json
dictionary
;
json
dictionary
;
std
::
string
url
=
"http://192.168.1.4:8085/telemachus/datalink?"
;
std
::
string
url
=
"http://192.168.1.4:8085/telemachus/datalink?"
;
std
::
string
v_url
;
std
::
string
v_url
;
std
::
vector
<
std
::
string
>
v_meas
;
std
::
string
o_url
;
std
::
string
o_url
;
std
::
vector
<
std
::
string
>
o_meas
;
std
::
string
n_url
;
static
size_t
WriteCallback
(
void
*
contents
,
size_t
size
,
size_t
nmemb
,
void
*
userp
)
static
size_t
WriteCallback
(
void
*
contents
,
size_t
size
,
size_t
nmemb
,
void
*
userp
)
{
{
...
@@ -74,13 +73,28 @@ void CALL_TYPE PublishThread::run()
...
@@ -74,13 +73,28 @@ void CALL_TYPE PublishThread::run()
v_url
+=
id
+
"="
+
id
+
"&"
;
v_url
+=
id
+
"="
+
id
+
"&"
;
}
}
}
}
if
(
dictionary
[
"subsystems"
][
i
][
"name"
]
==
"Orbit"
){
o_url
+=
url
;
for
(
size_t
j
=
0
;
j
<
dictionary
[
"subsystems"
][
i
][
"measurements"
].
size
();
j
++
)
{
std
::
string
id
(
dictionary
[
"subsystems"
][
i
][
"measurements"
][
j
][
"identifier"
].
get
<
std
::
string
>
());
o_url
+=
id
+
"="
+
id
+
"&"
;
}
}
if
(
dictionary
[
"subsystems"
][
i
][
"name"
]
==
"Navigation"
){
n_url
+=
url
;
for
(
size_t
j
=
0
;
j
<
dictionary
[
"subsystems"
][
i
][
"measurements"
].
size
();
j
++
)
{
std
::
string
id
(
dictionary
[
"subsystems"
][
i
][
"measurements"
][
j
][
"identifier"
].
get
<
std
::
string
>
());
n_url
+=
id
+
"="
+
id
+
"&"
;
}
}
}
}
std
::
cout
<<
v_url
<<
'\n'
;
std
::
cout
<<
v_url
<<
'\n'
;
while
(
true
)
{
while
(
true
)
{
get_v
();
get_v
();
//get_o();
get_o
();
get_n
();
//publish("GMSEC.TEST.PUBLISH");
//publish("GMSEC.TEST.PUBLISH");
example
::
millisleep
(
25
0
);
example
::
millisleep
(
100
0
);
}
}
teardown
();
teardown
();
...
@@ -142,60 +156,71 @@ void PublishThread::get_v(){
...
@@ -142,60 +156,71 @@ void PublishThread::get_v(){
Message
message
(
subject
.
c_str
(),
Message
::
PUBLISH
);
Message
message
(
subject
.
c_str
(),
Message
::
PUBLISH
);
for
(
json
::
iterator
it
=
js
.
begin
();
it
!=
js
.
end
();
++
it
)
{
for
(
json
::
iterator
it
=
js
.
begin
();
it
!=
js
.
end
();
++
it
)
{
if
(
it
.
value
().
is_string
())
{
if
(
it
.
value
().
is_string
())
{
//std::cout << it.key() << " : " << it.value().get<std::string>() << "\n";
std
::
string
field
(
it
.
key
());
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
std
::
string
>
().
c_str
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
std
::
string
>
().
c_str
());
}
}
if
(
it
.
value
().
is_number
())
{
if
(
it
.
value
().
is_number
())
{
//std::cout << it.key() << " : " << it.value().get<float>() << "\n";
std
::
string
field
(
it
.
key
());
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
float
>
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
float
>
());
}
}
//message.addField(std::string(it.key()).c_str(), std::string(it.value()).c_str());
}
}
// for (size_t i = 0; i < js.size(); i++) {
// std::cout << js[i].get<std::string>() << '\n';
// }
connection
->
publish
(
message
);
connection
->
publish
(
message
);
// float msnTime = js.at("v.missionTime");
// long alt = js.at("v.altitude");
// float latitude = js.at("v.lat");
// float longitude = js.at("v.long");
// std::string name = js.at("v.name");
// std::string subject = "GMSEC.KSP.MSG.TLM.PROCESSED.V";
// Message message(subject.c_str(), Message::PUBLISH);
// message.addField("ALTITUDE", (GMSEC_U32) alt);
// message.addField("MISSION-TIME", msnTime);
// message.addField("LONGITUDE", longitude);
// message.addField("LATITUDE", latitude);
// connection->publish(message);
// std::cout << msnTime << " " << alt << std::endl;
}
}
}
}
void
PublishThread
::
get_o
(){
void
PublishThread
::
get_o
(){
std
::
string
url
=
"http://192.168.1.4:8085/telemachus/datalink?"
;
url
+=
"name=v.name&"
;
url
+=
"orbit=o.orbitPatches"
;
CURL
*
curl
;
CURL
*
curl
;
CURLcode
res
;
CURLcode
res
;
std
::
string
readBuffer
;
std
::
string
readBuffer
;
curl
=
curl_easy_init
();
curl
=
curl_easy_init
();
if
(
curl
)
{
if
(
curl
)
{
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
o_
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
WriteCallback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
WriteCallback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
&
readBuffer
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
&
readBuffer
);
res
=
curl_easy_perform
(
curl
);
res
=
curl_easy_perform
(
curl
);
curl_easy_cleanup
(
curl
);
curl_easy_cleanup
(
curl
);
json
js
=
json
::
parse
(
readBuffer
);
json
js
=
json
::
parse
(
readBuffer
);
std
::
cout
<<
readBuffer
<<
std
::
endl
;
//std::cout << readBuffer << std::endl;
json
jo
=
js
[
"orbit"
][
0
];
//std::cout << jo.dump() << std::endl;
//std::string name = js.at("name");
float
inclination
=
jo
.
at
(
"inclination"
);
std
::
string
subject
=
"GMSEC.KSP.MSG.TLM.PROCESSED.O"
;
std
::
string
subject
=
"GMSEC.KSP.MSG.TLM.PROCESSED.O"
;
Message
message
(
subject
.
c_str
(),
Message
::
PUBLISH
);
Message
message
(
subject
.
c_str
(),
Message
::
PUBLISH
);
message
.
addField
(
"INCLINATION"
,
inclination
);
for
(
json
::
iterator
it
=
js
.
begin
();
it
!=
js
.
end
();
++
it
)
{
if
(
it
.
value
().
is_string
())
{
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
std
::
string
>
().
c_str
());
}
if
(
it
.
value
().
is_number
())
{
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
float
>
());
}
}
connection
->
publish
(
message
);
}
}
void
PublishThread
::
get_n
(){
CURL
*
curl
;
CURLcode
res
;
std
::
string
readBuffer
;
curl
=
curl_easy_init
();
if
(
curl
)
{
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
n_url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
WriteCallback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
&
readBuffer
);
res
=
curl_easy_perform
(
curl
);
curl_easy_cleanup
(
curl
);
json
js
=
json
::
parse
(
readBuffer
);
std
::
string
subject
=
"GMSEC.KSP.MSG.TLM.PROCESSED.N"
;
Message
message
(
subject
.
c_str
(),
Message
::
PUBLISH
);
for
(
json
::
iterator
it
=
js
.
begin
();
it
!=
js
.
end
();
++
it
)
{
if
(
it
.
value
().
is_string
())
{
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
std
::
string
>
().
c_str
());
}
if
(
it
.
value
().
is_number
())
{
std
::
string
field
(
it
.
key
());
message
.
addField
(
field
.
c_str
(),
it
.
value
().
get
<
float
>
());
}
}
connection
->
publish
(
message
);
connection
->
publish
(
message
);
}
}
}
}
...
...
PublishThread.hpp
View file @
d1942a0a
...
@@ -30,6 +30,7 @@ public:
...
@@ -30,6 +30,7 @@ public:
void
get_v
();
void
get_v
();
void
get_o
();
void
get_o
();
void
get_n
();
void
CALL_TYPE
run
();
void
CALL_TYPE
run
();
...
...
dictionary.json
View file @
d1942a0a
...
@@ -123,20 +123,212 @@
...
@@ -123,20 +123,212 @@
]
]
},
},
{
{
"name"
:
"
Communications
"
,
"name"
:
"
Orbit
"
,
"identifier"
:
"
comms
"
,
"identifier"
:
"
o
"
,
"measurements"
:
[
"measurements"
:
[
{
{
"name"
:
"Received"
,
"name"
:
"Relative Velocity"
,
"identifier"
:
"comms.recd"
,
"identifier"
:
"o.relativeVelocity"
,
"units"
:
"bytes"
,
"units"
:
"m/s"
,
"type"
:
"integer"
"type"
:
"float"
},
{
"name"
:
"Periapsis"
,
"identifier"
:
"o.PeA"
,
"units"
:
"meters"
,
"type"
:
"float"
},
{
"name"
:
"Apoapsis"
,
"identifier"
:
"o.ApA"
,
"units"
:
"m/s"
,
"type"
:
"float"
},
{
"name"
:
"Time to Apoapsis"
,
"identifier"
:
"o.timeToAp"
,
"units"
:
"seconds"
,
"type"
:
"float"
},
{
"name"
:
"Time to Periapsis"
,
"identifier"
:
"o.timeToPe"
,
"units"
:
"seconds"
,
"type"
:
"float"
},
{
"name"
:
"Inclination"
,
"identifier"
:
"o.inclination"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Eccentricity"
,
"identifier"
:
"o.eccentricity"
,
"units"
:
"none"
,
"type"
:
"float"
},
{
"name"
:
"Epoch"
,
"identifier"
:
"o.epoch"
,
"units"
:
"seconds"
,
"type"
:
"float"
},
{
"name"
:
"Period"
,
"identifier"
:
"o.period"
,
"units"
:
"none"
,
"type"
:
"float"
},
{
"name"
:
"Argument of Periapsis"
,
"identifier"
:
"o.argumentOfPariapsis"
,
"units"
:
"degree"
,
"type"
:
"float"
},
{
"name"
:
"Semimajor Axis"
,
"identifier"
:
"o.sma"
,
"units"
:
"degree"
,
"type"
:
"float"
},
{
"name"
:
"Longitude of Ascending Node"
,
"identifier"
:
"o.lan"
,
"units"
:
"degree"
,
"type"
:
"float"
},
{
"name"
:
"Mean Anomaly at Epoch"
,
"identifier"
:
"o.maae"
,
"units"
:
"none"
,
"type"
:
"float"
},
{
"name"
:
"Time of Periapsis Passage"
,
"identifier"
:
"o.timeOfPariapsisPassage"
,
"units"
:
"seconds"
,
"type"
:
"float"
},
{
"name"
:
"True Anomaly"
,
"identifier"
:
"o.trueAnomaly"
,
"units"
:
"none"
,
"type"
:
"float"
}
]
},
{
"name"
:
"Navigation"
,
"identifier"
:
"n"
,
"measurements"
:
[
{
"name"
:
"Heading"
,
"identifier"
:
"n.heading2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Pitch"
,
"identifier"
:
"n.pitch2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Roll"
,
"identifier"
:
"n.roll2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Raw Heading"
,
"identifier"
:
"n.rawheading2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Raw Pitch"
,
"identifier"
:
"n.rawpitch2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Raw Roll"
,
"identifier"
:
"n.rawroll2"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Root Heading"
,
"identifier"
:
"n.heading"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Root Pitch"
,
"identifier"
:
"n.pitch"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Root Roll"
,
"identifier"
:
"n.roll"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
},
{
{
"name"
:
"Sent"
,
"name"
:
"Root Raw Heading"
,
"identifier"
:
"comms.sent"
,
"identifier"
:
"n.rawheading"
,
"units"
:
"bytes"
,
"units"
:
"degrees"
,
"type"
:
"integer"
"type"
:
"float"
},
{
"name"
:
"Root Raw Pitch"
,
"identifier"
:
"n.rawpitch"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Root Raw Roll"
,
"identifier"
:
"n.rawroll"
,
"units"
:
"degrees"
,
"type"
:
"float"
}
]
},
{
"name"
:
"Docking"
,
"identifier"
:
"dock"
,
"measurements"
:
[
{
"name"
:
"Docking x Angle"
,
"identifier"
:
"dock.ax"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Docking y Angle"
,
"identifier"
:
"dock.ay"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Docking z Angle"
,
"identifier"
:
"dock.az"
,
"units"
:
"degrees"
,
"type"
:
"float"
},
{
"name"
:
"Docking x Distance"
,
"identifier"
:
"dock.x"
,
"units"
:
"meters"
,
"type"
:
"float"
},
{
"name"
:
"Docking y Distance"
,
"identifier"
:
"dock.y"
,
"units"
:
"meters"
,
"type"
:
"float"
}
}
]
]
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment