Skip to content

''None'' response. #27

@yosh101

Description

@yosh101

I am trying to read the rpm of motor, which is actually connected to VESC 4 on firmware version 5. Hereby I am using PyVESC method to send the message from Jetson to VESC. With PyVESC, it send the message to VESC, which RPM or/and Current it should give to the VESC in order to get the desired rpm from the motor. Below you can see this in the code. But, i am not able to read the return value which gives motor. Here, I get "None".

import pyvesc
import serial
import time
import datetime
from pyvesc import GetValues, SetRPM, SetCurrent, SetRotorPositionMode, GetRotorPosition

port_object = serial.Serial("/dev/ttyACM0",115200, timeout=0.1)


message = pyvesc.SetRPM(10000)
cumessage = pyvesc.SetCurrent(10000)
packet = pyvesc.encode(message)
cupacket = pyvesc.encode(cumessage)


while True:
    data = ''
    port_object.write(packet)
    port_object.write(cupacket)
    print("data; ", port_object.in_waiting)
    #data = port_object.read(5)
    #print(data)
    port_object.write(pyvesc.encode_request(GetValues))
    #print(port_object.in_waiting)
                # Check if there is enough data back for a measurement
    if port_object.in_waiting > 78:
        (response, consumed) = pyvesc.decode(78)

        #packets = []
        #now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
        print("response: ",response)
        print("consumed: ", consumed)
        """for sensor, value in response.__dict__.items():
            data = {}
            data['measurement'] = sensor
            data['tags'] = {}
            data['tags']['source'] = 'vesc'
            data['time'] = now
            data['fields'] = {}
            data['fields']['value'] = value
            packets.append(data)"""
            #print(data)

      
#port_object.flush()
#VESCMessage = pyvesc.GetVaĺues()
#packet = pyvesc.decode(VESCMessage)
#print(pa)

this is the result:

data;  2681
response:  None
consumed:  0
data;  2620
response:  None
consumed:  18
data;  2559
response:  None
consumed:  36
data;  2498
response:  None
consumed:  40
data;  2437
response:  None
consumed:  47
data;  2376
response:  None
consumed:  23

Does anyone know what is the problem here, why it gets none? what could be the best solutions? Would be really great! Thanks in Advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions