barrett_wam
natnet_client
- class LabeledMarkers[source]
Bases:
object
Helper class for keeping track of markers. This code is based on work from Pascal Klink.
- class NatNetClient(ver=(3, 0, 0, 0), server_ip='192.168.2.3', gateway_ip='192.168.2.1', quiet=True)[source]
Bases:
object
Client for communicating with OptiTrack. This code is based on work from Boris Belousov and Pascal Klink.
- Parameters:
ver – version as tuple
server_ip – IP address of the NatNet server, where Motive is running
gateway_ip – IP address of the gateway. Set to None to read out this IP from socket (which was not working in our tests)
quiet – Set to False to print additional NatNet messages using coloredlogs lib
- NAT_DISCONNECT = 9
- NAT_FRAMEOFDATA = 7
- NAT_MESSAGESTRING = 8
- NAT_MODELDEF = 5
- NAT_PING = 0
- NAT_PINGRESPONSE = 1
- NAT_REQUEST = 2
- NAT_REQUEST_FRAMEOFDATA = 6
- NAT_REQUEST_MODELDEF = 4
- NAT_RESPONSE = 3
- NAT_UNRECOGNIZED_REQUEST = 100
- run(daemon=True)[source]
Start the data and command threads. The attached callback functions (listener) should now retrieve data.
- Parameters:
daemon – If set to True, the data and command thread are closed as soon as the main thread has finished. Otherwise, the threads remain open and the program has to be shut down manually.
trackers
- class MarkerTracker(verbose=False)[source]
Bases:
object
Class for tracking markers with OptiTrack and a NatNet client. This code is based on work from Pascal Klink.
- class RigidBodyTracker(names: Sequence[str], rotation=None, offset: Union[ndarray, list] = array([0.0, 0.0, 0.0]))[source]
Bases:
object
Class for tracking rigid bodies with OptiTrack and a NatNet client This code is based on work from Pascal Klink.
Constructor
- Parameters:
names – list of rigid body names, e.g. [“cup”, “ball”]
rotation – Rotation instance of scipy.spatial.transform
offset – [x, y, z] offset from the OptiTrack coordinate system to the one used in simulation
- get_current_estimate(names: Sequence[str]) [List[Tuple], Tuple] [source]
Get position and rotation estimate for the given body names.
- Parameters:
names – list of rigid body names
- Return copied_ts:
list of tuples containing the current estimate for each body in names, or tuple if there would only be one element in the list