Merge branch 'main' of https://git.passer.life/RoboidControl/RoboidControl-python
This commit is contained in:
		
						commit
						dca94c7194
					
				@ -2,6 +2,7 @@ import numpy as np
 | 
				
			|||||||
from LinearAlgebra.SwingTwist import SwingTwist
 | 
					from LinearAlgebra.SwingTwist import SwingTwist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def SendAngle8(buffer, ix_ref, angle):
 | 
					def SendAngle8(buffer, ix_ref, angle):
 | 
				
			||||||
 | 
					    """! Send an 8-bit angle value """
 | 
				
			||||||
    # Normalize angle
 | 
					    # Normalize angle
 | 
				
			||||||
    while angle >= 180:
 | 
					    while angle >= 180:
 | 
				
			||||||
        angle -= 360
 | 
					        angle -= 360
 | 
				
			||||||
@ -13,6 +14,7 @@ def SendAngle8(buffer, ix_ref, angle):
 | 
				
			|||||||
    ix_ref[0] += 1
 | 
					    ix_ref[0] += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def SendFloat16(buffer, ix_ref, value):
 | 
					def SendFloat16(buffer, ix_ref, value):
 | 
				
			||||||
 | 
					    """! Send a 16-bit floating point value """
 | 
				
			||||||
    ix = ix_ref[0]
 | 
					    ix = ix_ref[0]
 | 
				
			||||||
    value16 = np.float16(value)
 | 
					    value16 = np.float16(value)
 | 
				
			||||||
    binary = value16.view(np.uint16)
 | 
					    binary = value16.view(np.uint16)
 | 
				
			||||||
@ -23,6 +25,7 @@ def SendFloat16(buffer, ix_ref, value):
 | 
				
			|||||||
    ix_ref[0] += 2
 | 
					    ix_ref[0] += 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ReceiveFloat16(buffer, ix_ref) -> float:
 | 
					def ReceiveFloat16(buffer, ix_ref) -> float:
 | 
				
			||||||
 | 
					    """! Receive a 16-bit floating point value """
 | 
				
			||||||
    ix = ix_ref[0]
 | 
					    ix = ix_ref[0]
 | 
				
			||||||
    # if ix < len(buffer) - 1:
 | 
					    # if ix < len(buffer) - 1:
 | 
				
			||||||
    binary = (buffer[ix] << 8) + buffer[ix+1]
 | 
					    binary = (buffer[ix] << 8) + buffer[ix+1]
 | 
				
			||||||
@ -33,11 +36,13 @@ def ReceiveFloat16(buffer, ix_ref) -> float:
 | 
				
			|||||||
    return float(value16)
 | 
					    return float(value16)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def SendSpherical(buffer, ix_ref, vector):
 | 
					def SendSpherical(buffer, ix_ref, vector):
 | 
				
			||||||
 | 
					    """! Send a spherical vector """
 | 
				
			||||||
    SendFloat16(buffer, ix_ref, vector.distance)
 | 
					    SendFloat16(buffer, ix_ref, vector.distance)
 | 
				
			||||||
    SendAngle8(buffer, ix_ref, vector.direction.horizontal)
 | 
					    SendAngle8(buffer, ix_ref, vector.direction.horizontal)
 | 
				
			||||||
    SendAngle8(buffer, ix_ref, vector.direction.vertical)
 | 
					    SendAngle8(buffer, ix_ref, vector.direction.vertical)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def SendQuat32(buffer, ix_ref, q):
 | 
					def SendQuat32(buffer, ix_ref, q):
 | 
				
			||||||
 | 
					    """! Send a 32-bit quaternion value """
 | 
				
			||||||
    if isinstance(q, SwingTwist):
 | 
					    if isinstance(q, SwingTwist):
 | 
				
			||||||
        q = q.ToQuaternion()
 | 
					        q = q.ToQuaternion()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user