Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rob avanzada maria #71

Open
wants to merge 10 commits into
base: version-3
Choose a base branch
from
14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/learnbot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

235 changes: 235 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions learnbot_dsl/Clients/EV3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

class Robot(Client):

devicesAvailables = ["base","distancesensors", "groundsensors", "gyroscope"]
devicesAvailables = ["base", "distancesensors", "groundsensors", "gyroscope", "jointmotor"]

def __init__(self):
self.ev3Motor = None
self.ev3Sensors = None
self.ev3Base = None
self.connectToRobot()
self.base = Base(_callFunction=self.deviceBaseMove)
self.addJointMotor("ARM", _JointMotor=JointMotor(_callDevice=self.deviceSendAngleArm, _readDevice=None))
self.distanceSensors = DistanceSensors(_readFunction=self.deviceReadLaser)
self.groundSensors = GroundSensors(_readFunction=self.deviceReadGroundSensors)
self.gyroscope = Gyroscope(_readFunction=self.deviceReadGyroscope, _resetFunction=self.resetGyroscope)
Expand All @@ -28,11 +29,13 @@ def __init__(self):
self.start()

def connectToRobot(self):
self. conn = rpyc.classic.connect('192.168.0.113') # host name or IP address of the EV3
self. conn = rpyc.classic.connect('192.168.1.23') # host name or IP address of the EV3
self.ev3Motor = self.conn.modules['ev3dev2.motor'] # import ev3dev.ev3 remotely
LEFT_MOTOR = self.ev3Motor.OUTPUT_B
RIGHT_MOTOR = self.ev3Motor.OUTPUT_D
self.ev3Base = self.ev3Motor.MoveTank(LEFT_MOTOR, RIGHT_MOTOR)
ARM_MOTOR = self.ev3Motor.OUTPUT_A
self.ev3Arm = self.ev3Motor.ServoMotor(ARM_MOTOR)
self.ev3Sensors = self.conn.modules['ev3dev2.sensor.lego']
self.ultrasonic = self.ev3Sensors.UltrasonicSensor()
self.colorsensor = self.ev3Sensors.ColorSensor()
Expand Down Expand Up @@ -60,6 +63,26 @@ def deviceBaseMove(self, SAdv, SRot):
#print("rspeed", r_wheel_speed, "lspeed", l_wheel_speed)
self.ev3Base.on(left_speed=self.ev3Motor.SpeedDPS(l_wheel_speed), right_speed=self.ev3Motor.SpeedDPS(r_wheel_speed))

def deviceSendAngleArm(self, _angle):
if _angle > 2400 :
_angle = 2400
elif _angle < 600:
_angle = 600
# calculamos valor del angulo a enviar
if _angle == 1500:
a = 1500
elif _angle == 600:
a = 600
elif _angle == 2400:
a = 2400
elif _angle < 1500 and _angle > 600:
a = - 50
elif _angle > 1500 and _angle < 2400:
a = 50
self.ev3Arm.position_sp = a
# move the servo to the value of position_sp()
self.ev3Arm.run()

def deviceReadLaser(self):
dist = self.ultrasonic.value()
return {"front": [dist], # The values must be in mm
Expand All @@ -81,7 +104,6 @@ def resetGyroscope(self):
self.gyrosensor.mode = 'GYRO-ANG'



if __name__ == '__main__':
try:
robot = Robot()
Expand Down
2 changes: 2 additions & 0 deletions learnbot_dsl/functions/motor/jointmotor/arm_down.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def arm_down(lbot):
lbot.setJointAngle("ARM",-100)
3 changes: 3 additions & 0 deletions learnbot_dsl/functions/motor/jointmotor/arm_front.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def arm_front(lbot):
lbot.setJointAngle("ARM",0)

4 changes: 4 additions & 0 deletions learnbot_dsl/functions/motor/jointmotor/arm_up.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def arm_up(lbot):
lbot.setJointAngle("ARM",100)
4 changes: 4 additions & 0 deletions learnbot_dsl/functions/motor/jointmotor/setAngleArm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def setAngleArm(lbot,angle):
lbot.setJointAngle("ARM", angle)