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

''None'' response. #27

Open
yosh101 opened this issue Sep 29, 2022 · 0 comments
Open

''None'' response. #27

yosh101 opened this issue Sep 29, 2022 · 0 comments

Comments

@yosh101
Copy link

yosh101 commented Sep 29, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant