Added diff.drive and touchsensor
This commit is contained in:
parent
4e1cbfb2aa
commit
3892c2baeb
@ -4,7 +4,11 @@ from LinearAlgebra.Direction import Direction
|
|||||||
from LinearAlgebra.Angle import Angle
|
from LinearAlgebra.Angle import Angle
|
||||||
|
|
||||||
class DifferentialDrive(Thing):
|
class DifferentialDrive(Thing):
|
||||||
|
"""! A thing which can move itself using a differential drive system
|
||||||
|
"""
|
||||||
def __init__(self, participant = None):
|
def __init__(self, participant = None):
|
||||||
|
"""! Create a new differential drive
|
||||||
|
"""
|
||||||
super().__init__(participant)
|
super().__init__(participant)
|
||||||
|
|
||||||
## The radius of a wheel in meters
|
## The radius of a wheel in meters
|
||||||
@ -38,6 +42,10 @@ class DifferentialDrive(Thing):
|
|||||||
self.wheel_right.SetPosition(Spherical(distance, Direction.Right))
|
self.wheel_right.SetPosition(Spherical(distance, Direction.Right))
|
||||||
|
|
||||||
def SetWheelVelocity(self, speed_left, speed_right):
|
def SetWheelVelocity(self, speed_left, speed_right):
|
||||||
|
"""! Directly specify the speeds of the motors
|
||||||
|
@params speed_left The speed of the left wheel in degrees per second. Positive moves the robot in the forward direction.
|
||||||
|
@params speed_right The speed of the right wheel in degrees per second. Positive moves the robot in the forward direction.
|
||||||
|
"""
|
||||||
if self.wheel_left is not None:
|
if self.wheel_left is not None:
|
||||||
self.wheel_left.SetAngularVelocity(Spherical(speed_left, Direction.Left))
|
self.wheel_left.SetAngularVelocity(Spherical(speed_left, Direction.Left))
|
||||||
|
|
||||||
@ -45,6 +53,9 @@ class DifferentialDrive(Thing):
|
|||||||
self.wheel_right.SetAngularVelocity(Spherical(speed_right, Direction.Right))
|
self.wheel_right.SetAngularVelocity(Spherical(speed_right, Direction.Right))
|
||||||
|
|
||||||
def Update(self, currentTimeMs, recursive = True):
|
def Update(self, currentTimeMs, recursive = True):
|
||||||
|
"""!
|
||||||
|
@copydoc Thing::Update
|
||||||
|
"""
|
||||||
# This assumes forward velocity only...
|
# This assumes forward velocity only...
|
||||||
linear_velocity: Spherical = self.GetLinearVelocity().distance
|
linear_velocity: Spherical = self.GetLinearVelocity().distance
|
||||||
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
from Thing import Thing
|
from Thing import Thing
|
||||||
|
|
||||||
class TouchSensor(Thing):
|
class TouchSensor(Thing):
|
||||||
|
"""! A sensor which can detect touches
|
||||||
|
"""
|
||||||
def __init__(self, owner, parent):
|
def __init__(self, owner, parent):
|
||||||
|
"""! Create a touch sensor
|
||||||
|
"""
|
||||||
super().__init__(owner, parent)
|
super().__init__(owner, parent)
|
||||||
|
|
||||||
## Value which is true when the sensor is touching something, false otherwise
|
## Value which is true when the sensor is touching something, false otherwise
|
||||||
self.touched_somthing = False
|
self.touched_somthing = False
|
||||||
|
|
||||||
def GenerateBinary(bytes, ix_ref):
|
def ProcessBinary(bytes):
|
||||||
pass
|
"""! Function to extract the touch state received in a binary message
|
||||||
|
"""
|
||||||
def ProcessBinary(bytes):
|
pass
|
||||||
pass
|
|
Loading…
x
Reference in New Issue
Block a user