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
|
||||
|
||||
class DifferentialDrive(Thing):
|
||||
"""! A thing which can move itself using a differential drive system
|
||||
"""
|
||||
def __init__(self, participant = None):
|
||||
"""! Create a new differential drive
|
||||
"""
|
||||
super().__init__(participant)
|
||||
|
||||
## The radius of a wheel in meters
|
||||
@ -38,6 +42,10 @@ class DifferentialDrive(Thing):
|
||||
self.wheel_right.SetPosition(Spherical(distance, Direction.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:
|
||||
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))
|
||||
|
||||
def Update(self, currentTimeMs, recursive = True):
|
||||
"""!
|
||||
@copydoc Thing::Update
|
||||
"""
|
||||
# This assumes forward velocity only...
|
||||
linear_velocity: Spherical = self.GetLinearVelocity().distance
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
from Thing import Thing
|
||||
|
||||
class TouchSensor(Thing):
|
||||
"""! A sensor which can detect touches
|
||||
"""
|
||||
def __init__(self, owner, parent):
|
||||
"""! Create a touch sensor
|
||||
"""
|
||||
super().__init__(owner, parent)
|
||||
|
||||
## Value which is true when the sensor is touching something, false otherwise
|
||||
self.touched_somthing = False
|
||||
|
||||
def GenerateBinary(bytes, ix_ref):
|
||||
pass
|
||||
|
||||
def ProcessBinary(bytes):
|
||||
pass
|
||||
def ProcessBinary(bytes):
|
||||
"""! Function to extract the touch state received in a binary message
|
||||
"""
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user