Skip to content

Commit

Permalink
PositStageNet 2.03: Code rewrite + added per-tracker timestamp data c…
Browse files Browse the repository at this point in the history
…hunk

- Improvements:
  - Added a new tracker data chunk to encode a timestamp per tracker.
  - Added flags to trackers to know which chunk have been received
    and to avoid transmitted properties that have not been set.
  - Rewrote the whole implementation to simplify its usage and to
    lower its computational time by reduce memory allocation and copy.
    Warning: The interface changed. You might need to adapt calls to
             the library if you update from a previous version. However,
             the changes should be straightforward.
  • Loading branch information
gppaille-vyv committed Oct 22, 2019
1 parent 7becc53 commit 7cb3465
Show file tree
Hide file tree
Showing 24 changed files with 1,069 additions and 1,857 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![psn logo](https://github.com/vyv-ca/psn-cpp/blob/master/doc/psn-logo.png)
![psn logo](https://www.posistage.net/wp-content/uploads/thegem-logos/logo_6f12e80755dcd5d74ec129f475257f13_3x.png)

# An Open Protocol for On-Stage, Live 3D Position Data

Expand Down
Binary file modified bin/win32/psn_client.exe
Binary file not shown.
Binary file modified bin/win32/psn_glut_client.exe
Binary file not shown.
Binary file modified bin/win32/psn_server.exe
Binary file not shown.
Binary file modified bin/win64/psn_client.exe
Binary file not shown.
Binary file modified bin/win64/psn_glut_client.exe
Binary file not shown.
Binary file modified bin/win64/psn_server.exe
Binary file not shown.
14 changes: 13 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
Change Log
===============================================

Version 2.03 - 2019-10-22

- Improvements:
- Added a new tracker data chunk to encode a timestamp per tracker.
- Added flags to trackers to know which chunk have been received
and to avoid transmitted properties that have not been set.
- Rewrote the whole implementation to simplify its usage and to
lower its computational time by reduce memory allocation and copy.
Warning: The interface changed. You might need to adapt calls to
the library if you update from a previous version. However,
the changes should be straightforward.

Version 2.02 - 2018-01-03
===============================================

- Bug:
- Description: psn_tracker class constructor was always setting its member 'validity' to 0, ignoring the given parameter
- Description: psn_tracker class constructor always was setting its member 'validity' to 0, ignoring the given parameter
- Fix: The constructor now uses the given parameter to initialize the member 'validity'.
- Bug:
- Description: The frame_id needed to be sequential. If not, a frame could be lost when reconstructing frame packets.
Expand Down
Binary file added doc/PosiStageNetprotocol_v2.03_2019_09_09.pdf
Binary file not shown.
2 changes: 0 additions & 2 deletions examples/vs2015/psn.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<ClInclude Include="..\..\include\psn_defs.hpp" />
<ClInclude Include="..\..\include\psn_encoder.hpp" />
<ClInclude Include="..\..\include\psn_encoder_impl.hpp" />
<ClInclude Include="..\..\include\psn_generic.hpp" />
<ClInclude Include="..\..\include\psn_generic_impl.hpp" />
<ClInclude Include="..\..\include\psn_lib.hpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
Expand Down
183 changes: 102 additions & 81 deletions examples/vs2015/psn_client/psn_client.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/*
The MIT License (MIT)
Copyright (c) 2014 VYV Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* The MIT License (MIT)
*
* Copyright (c) 2014 VYV Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
**/
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#include <psn_lib.hpp>
Expand All @@ -32,67 +32,88 @@ THE SOFTWARE.

void main( void )
{
wsa_session session ;
wsa_session session ;

//====================================================
// Init client
udp_socket socket_client ;
socket_client.bind( PSN_DEFAULT_UDP_PORT ) ;
socket_client.join_multicast_group( PSN_DEFAULT_UDP_MULTICAST_ADDR ) ;

::psn::psn_decoder psn_decoder ;

//====================================================
// Main loop
while ( 1 )
{
Sleep( 1 ) ;

// Update Client
{
::std::string msg ;
if ( socket_client.receive_message( msg , PSN_MAX_UDP_PACKET_SIZE ) )
{
psn_decoder.decode( msg ) ;

static uint8_t last_frame_id = 0 ;

if ( psn_decoder.get_last_decoded_frame_id() != last_frame_id )
{
last_frame_id = psn_decoder.get_last_decoded_frame_id() ;

::psn::psn_tracker_array recv_trackers = psn_decoder.get_trackers() ;
::psn::psn_tracker_array::iterator it ;

static int skip_cout = 0 ;
if ( skip_cout++ % 100 == 0 )
{
static ::std::string server_name ;
psn_decoder.get_psn_server_name( server_name ) ;

::std::cout << "--------------------PSN CLIENT-----------------" << ::std::endl ;
::std::cout << "PSN Server : " << server_name << ::std::endl ;
::std::cout << "Frame Id : " << (int)last_frame_id << ::std::endl ;
::std::cout << "Trackers : " << ::std::endl ;

for ( it = recv_trackers.begin() ; it != recv_trackers.end() ; ++it )
{
::std::cout << it->second.id_ << " \""
<< it->second.name_ << "\" "
<< it->second.pos_.x << " , "
<< it->second.pos_.y << " , "
<< it->second.pos_.z << " | "
<< it->second.ori_.x << " , "
<< it->second.ori_.y << " , "
<< it->second.ori_.z << ::std::endl ;
}

::std::cout << "-----------------------------------------------" << ::std::endl ;
}
}
}
}
}
udp_socket socket_client ;
socket_client.bind( ::psn::DEFAULT_UDP_PORT ) ;
socket_client.join_multicast_group( ::psn::DEFAULT_UDP_MULTICAST_ADDR ) ;

::psn::psn_decoder psn_decoder ;
uint8_t last_frame_id = 0 ;
int skip_cout = 0 ;

//====================================================
// Main loop
while ( 1 )
{
Sleep( 1 ) ;

// Update Client
::std::string msg ;

if ( socket_client.receive_message( msg , ::psn::MAX_UDP_PACKET_SIZE ) )
{
psn_decoder.decode( msg.data() , msg.size() ) ;

if ( psn_decoder.get_data().header.frame_id != last_frame_id )
{
last_frame_id = psn_decoder.get_data().header.frame_id ;

const ::psn::tracker_map & recv_trackers = psn_decoder.get_data().trackers ;

if ( skip_cout++ % 20 == 0 )
{
::std::cout << "--------------------PSN CLIENT-----------------" << ::std::endl ;
::std::cout << "System Name: " << psn_decoder.get_info().system_name << ::std::endl ;
::std::cout << "Frame Id: " << (int)last_frame_id << ::std::endl ;
::std::cout << "Frame Timestamp: " << psn_decoder.get_data().header.timestamp_usec << ::std::endl ;
::std::cout << "Tracker count: " << recv_trackers.size() << ::std::endl ;

for ( auto it = recv_trackers.begin() ; it != recv_trackers.end() ; ++it )
{
const ::psn::tracker & tracker = it->second ;

::std::cout << "Tracker - id: " << tracker.get_id() << " | name: " << tracker.get_name() << ::std::endl ;

if ( tracker.is_pos_set() )
::std::cout << " pos: " << tracker.get_pos().x << ", " <<
tracker.get_pos().y << ", " <<
tracker.get_pos().z << std::endl ;

if ( tracker.is_speed_set() )
::std::cout << " speed: " << tracker.get_speed().x << ", " <<
tracker.get_speed().y << ", " <<
tracker.get_speed().z << std::endl ;

if ( tracker.is_ori_set() )
::std::cout << " ori: " << tracker.get_ori().x << ", " <<
tracker.get_ori().y << ", " <<
tracker.get_ori().z << std::endl ;

if ( tracker.is_status_set() )
::std::cout << " status: " << tracker.get_status() << std::endl ;

if ( tracker.is_accel_set() )
::std::cout << " accel: " << tracker.get_accel().x << ", " <<
tracker.get_accel().y << ", " <<
tracker.get_accel().z << std::endl ;

if ( tracker.is_target_pos_set() )
::std::cout << " target pos: " << tracker.get_target_pos().x << ", " <<
tracker.get_target_pos().y << ", " <<
tracker.get_target_pos().z << std::endl ;

if ( tracker.is_timestamp_set() )
::std::cout << " timestamp: " << tracker.get_timestamp() << std::endl ;
}

::std::cout << "-----------------------------------------------" << ::std::endl ;
}
}
}
}
}


Loading

0 comments on commit 7cb3465

Please sign in to comment.