Esempio n. 1
0
	def __init__(self,pinT,pinS):
		self.__mStateDeclarator = settings_store_client.StateDeclarator()
		self.__mPowerWatchdog = settings_store_client.PowerWatchdog(self.__mStateDeclarator);
		self.mRosPublisherThrottle = rospy.Publisher('/throttles', std_msgs.msg.Float32, queue_size=1)
	
		self.throttles = 0
		self.steering = 0
		self.settings = ActuatorSettings()
		self.mGoalThrottle=0 #-1 pour marche arriere max 0 arret 1 marche avant max
		self.mGoalSteering=0
		self.mLastNonNullGoalThrottle = 0
		
		self.__mGpio = None
		
		try:
			self.__mGpio = pigpio.pi()
		except:
			self.__mGpio = None
		self.pinT=pinT
		self.pinS=pinS
		self.__mStateDeclarator.setState("actuator/enable","disable")
				
		time.sleep(5)
		if self.__mGpio is None:
			self.__mStateDeclarator.setState("init/actuator",False)
			rospy.logerr('Fail to open gpio, actuator will not work properly')
		else:
			self.__mStateDeclarator.setState("init/actuator",True)
			rospy.logwarn('Powertrain is ready')
Esempio n. 2
0
    def __init__(self, pinA, pinB, pinC, pinD, settings):
        self.speed = 0
        self.thrust = [0, 0, 0, 0]  # Thrust table for all the engines
        self.mthrust = 0  # Command Thrust
        self.mGoalSpeed = 0.  # Goal Speed
        self.mGpio = pigpio.pi()
        self.pinA = pinA
        self.pinB = pinB
        self.pinC = pinC
        self.pinD = pinD
        self.sRosPublisher = rospy.Publisher('emaginarium/DiagThrust',
                                             emaginarium.msg.DiagThrust,
                                             queue_size=5)
        self.settings = settings  # Goal Speed propotional gain
        self.mStateDeclarator = settings_store_client.StateDeclarator()
        self.mPowerWatchdog = settings_store_client.PowerWatchdog(
            self.mStateDeclarator)
        lSettings = CommandThrustSettings()
        self.mStateDeclarator.setState("actuator/enable", "disable")
        self.mStateDeclarator.setState("init/actuator", True)
        try:
            self.updateThrust()  # mandatory init engines
        except:
            rospy.logerr('Fail to initialize engines')
            self.mGpio = None
        time.sleep(5)
        print('Powertrain is ready')

        self.updateThrust()
Esempio n. 3
0
    def __init__(self):
        self.__mStateDeclarator = settings_store_client.StateDeclarator()
        self.__mPowerWatchdog = settings_store_client.PowerWatchdog(
            self.__mStateDeclarator)
        self.mRosPublisherThrottle = rospy.Publisher('/throttles',
                                                     std_msgs.msg.Float32,
                                                     queue_size=1)
        self.mRosPublisherPingLidardDist = rospy.Publisher(
            'emobile/PingLidarDist', std_msgs.msg.Float32, queue_size=1)
        self.mRosPublisherSpeed = rospy.Publisher('/speed',
                                                  std_msgs.msg.Float32,
                                                  queue_size=1)
        self.mRosPublisherOdometry = rospy.Publisher('/odometry',
                                                     std_msgs.msg.Float32,
                                                     queue_size=1)

        self.throttles = 0
        self.steering = 0
        self.settings = ActuatorSettings()
        self.mGoalThrottle = 0  #-1 pour marche arriere max 0 arret 1 marche avant max
        self.mGoalSteering = 0
        self.mLastNonNullGoalThrottle = 0
        self.mIsInitialized = False

        self.__mSerialPort = None

        try:
            self.__mSerialPort = serial.Serial('/dev/ttyTHS1',
                                               baudrate=115200,
                                               timeout=1)
        except:
            self.__mSerialPort = None
        self.__mStateDeclarator.setState("actuator/enable", "disable")

        time.sleep(5)
        if self.__mSerialPort is None:
            self.__mStateDeclarator.setState("init/actuator", False)
            rospy.logerr('Fail to open esp32.')
        else:
            self.__mStateDeclarator.setState("init/actuator", True)
            rospy.logwarn('Powertrain is ready')
            self.mIsInitialized = True
Esempio n. 4
0
    def __init__(self):

        parser = cmdline.create_parser(
            description='')  #description='luma.examples arguments'
        args = parser.parse_args([])
        self.__mStateDeclarator = settings_store_client.StateDeclarator()

        # fc-list | grep Vera
        self.__mFontName = {}
        self.__mFontName[(True, True)] = "VeraBI.ttf"
        self.__mFontName[(True, False)] = "VeraBd.ttf"
        self.__mFontName[(False, True)] = "VeraIt.ttf"
        self.__mFontName[(False, False)] = "Vera.ttf"

        self.__mDevice = None

        # create device
        try:
            self.__mDevice = cmdline.create_device(args)
            self.__mDevice.clear()

            #create buffer
            self.__mBuffer = Image.new("RGB", self.__mDevice.size)
            self.__mBufferTmp = Image.new("RGB", self.__mDevice.size)

            self.__mHasPendingChanges = True
            self.__mPreviousBrightness = -1

            rospy.Subscriber('/oled_display/draw_rect',
                             grading_machine.msg.DisplayDrawRect,
                             self.__onDrawRect)
            rospy.Subscriber('/oled_display/draw_text',
                             grading_machine.msg.DisplayDrawText,
                             self.__onDrawText)
            self.__mStateDeclarator.setState('i2c_display', 'ok')
        except:
            self.__mDevice = None
            rospy.logerr('Fail to initialize i2c oled display')
            self.__mStateDeclarator.setState('i2c_display', 'error')
Esempio n. 5
0
from numpy import pi
from settings_store import settings_store_client

# parameters
# opening of the sensor (deg)
opening = 95
# number of beams
nBeams = 8
# range
rangemin = 0.0
rangemax = 15.0

# init ros node
rospy.init_node('leddar')

lStateDeclarator = settings_store_client.StateDeclarator()

pub = rospy.Publisher('/leddarVu8', LaserScan, queue_size=1)

lRate = rospy.Rate(30)

# init serial connection
lSerialPort = rospy.get_param('/leddarVu8/serialPort')
m = None

lAllIsOk = True
try:
    import minimalmodbus
    minimalmodbus.BAUDRATE = 115200
except:
    rospy.logerr('Fail to import minimalmodbus')