Commit f3de260e authored by Jose Tiago Macara Coutinho's avatar Jose Tiago Macara Coutinho Committed by blissadm_ID31@bibhelm
Browse files

ID31 robot: ID31 robot emotion controller

parent 67e5d5c2
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import time
import serial
from bliss.controllers.motor import Controller
from bliss.common import log as elog
from bliss.common.axis import AxisState
from bliss.common.utils import object_attribute_get, object_attribute_set, object_method
from StaubPy import id31Controller
"""
Bliss controller for ID31Robot.
"""
class ID31Robot(Controller):
Cache = {}
def initialize(self):
"""
"""
# opens communication
print("Initialisation of ID31 robot.")
host = self.config.get('host')
try:
self.id31 = ID31Robot.Cache[host]
except KeyError:
ID31Robot.Cache[host] = id31Controller.ID31Controller(controllerAssociated=self.config.get('host'))
self.id31 = ID31Robot.Cache[host]
# Change for True if you want a lot of debugs on the controller and in the console.
self.id31.printDebug=False
print("Creating robot 'firmware' and shipping to controller. (fast)")
self.id31.makeOnly()
print("Starting new robot controller 'firmware' (takes time (5-25sec))")
self.id31.loadOnly()
print("Initialising values in controller. (fast)")
self.id31.initValues()
self.movingStatus="initialised"
print("Post Init Actions in controller. (fast)")
self.id31.postInit()
self.id31.scanSpeed.velocity = self.config.get('speed')
def finalize(self):
"""
"""
# Closes communication
def initialize_axis(self, axis):
"""
Reads specific config
Adds specific methods
"""
axis.role = axis.config.get('role')
def read_position(self, axis):
"""
Returns position's setpoint or measured position.
Args:
- <axis> : bliss axis.
- [<measured>] : boolean : if True, function returns
measured position in ???
Returns:
- <position> : float : axis setpoint in ???.
"""
return getattr(self.id31, axis.role)
def read_encoder(self, encoder):
raise NotImplementedError
# def read_velocity(self, axis):
# """
# Args:
# - <axis> : Bliss axis object.
# Returns:
# - <velocity> : float
# """
# return self.id31.scanSpeed.velocity
# def set_velocity(self, axis, new_velocity):
# #But bliss do not know that other axis velocity changed also.
@object_attribute_get(type_info="float")
def get_speed(self, axis):
return self.id31.scanSpeed.velocity
@object_attribute_set(type_info="float")
def set_speed(self, axis, new_speed):
self.id31.scanSpeed.velocity = new_speed
def state(self, axis):
if self.id31.hasMovesProgrammed:
return AxisState("MOVING")
else:
return AxisState("READY")
def prepare_move(self, motion):
setattr(self.id31, motion.axis.role, motion.target_pos)
def start_one(self, motion):
"""
"""
print("START one", motion)
self.id31.moveToPosition()
def start_all(self, *motion_list):
print("START ALL", motion_list)
self.id31.moveToPosition()
def stop(self, axis):
i = 0
while self.id31.hasMovesProgrammed and i < 5:
self.id31.resetMotion()
i += 1
if self.id31.hasMovesProgrammed:
logging.error('robot still has programmed moves after 5 attempts to stop')
@object_method(types_info=("None", "None"))
def openGripper(self,axis):
self.id31.openGripper()
@object_method(types_info=("None", "None"))
def closeGripper(self,axis):
self.id31.closeGripper()
@object_method(types_info=("None", "None"))
def shakerOn(self,axis):
self.id31.shakerOn()
@object_method(types_info=("None", "None"))
def shakerOff(self,axis):
self.id31.shakerOff()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment