svenssonjoel / lispBM

An interpreter for a concurrent lisp-like language with message-passing and pattern-matching implemented in C.
http://www.lispbm.com
GNU General Public License v3.0
90 stars 7 forks source link

Function to set a config parameter on local + can-attached vescs #7

Closed aka13-404 closed 1 year ago

aka13-404 commented 1 year ago

Hello Sven,

As we have discussed on the discord, "Setting parameters on the vesc that the lisp runs on is easy and transparent - pick a config entry from the provided list, set it - (conf-set 'max-speed 228).

Running the same command on a can-connected vesc is really tedious - (can-cmd X (str-merge "(conf-set 'max-speed " (str-from-n 228) ")"))."

At the same time, in escooter applications, you (almost) always want to change a parameter on both controllers. A good example is max-speed, or max current,or current-max-scale.

So currently the way to do that, if you change a "profile" from the display, would be:

(progn
    (conf-set 'max-speed 228)
    (can-cmd 61 (str-merge "(conf-set 'max-speed " (str-from-n 228) ")"))."
)

Which is hard to read, and easy to forget to adjust, if you want your profile to do something slightly different.

What would be cool, is for a function to exist, which would take over the heavy lifting for me. Currently I have implemented the following code:

(defun set-param (param value can_slave_id_list)
    (progn
        (conf-set param value)
        (loopforeach i can_slave_id_list
            (can-cmd i (str-merge "(conf-set " "'" (sym2str param) " " (str-from-n value) ")"))
        )
    )
)

Which permits me to do what (conf-set) does, but instead on multiple vescs attached to the canbus (in my case it's only one, but I can imagine that for drone/multimotor setups it will apply to 4+ escs):

(set-param 'max-speed 228 (list 61))

I am not sure how this is relevant to electric skateboards, but all scripts that I know of for Kugoo/Ninebot/Xiaomi displays with multiple motors have the same need, and implement something close to that function either way.

This can be a shortform, since it does not need to execure fast in any form or way. Appreciate your time and effort on everything.

svenssonjoel commented 1 year ago

I think that @vedderb are adding more of these. So in some upcoming release of bldc and vesc_express more set/get functionality will be present.

svenssonjoel commented 1 year ago

Closing this