11PyVESC Documentation
2- ====================
2+ ********************
3+
4+ .. toctree ::
5+ :titlesonly:
6+
7+
38PyVESC is aimed at being a easy to use and robust python implementation of the
49communication protocol used by the
510`VESC - Open Source ESC <http://vedder.se/2015/01/vesc-open-source-esc/ >`_
@@ -32,7 +37,7 @@ PyVESC can be used to go from a message (VESCMessage) to a packet (bytes).
3237.. code-block :: python
3338
3439 # make a SetDutyCycle message
35- my_msg = pyvesc.SetDutyCycle(255 )
40+ my_msg = pyvesc.SetDutyCycle(1e5 )
3641 print (my_msg.duty_cycle) # prints value of my_msg.duty_cycle
3742 my_packet = pyvesc.encode(my_msg)
3843 # my_packet (type: bytes) can now be sent over your UART connection
@@ -64,7 +69,7 @@ PyVESC serves two purposes:
6469#. Performs message encoding (to packet) and robust message decoding (to message object)
6570
6671Messages
67- --------
72+ ========
6873Here is a list of the messages currently supported in PyVESC. Note that not all
6974of VESC's messages are implemented. This is because we have only implemented the
7075messages we use as we don't want to distribute anything that hasn't been tested.
@@ -79,7 +84,7 @@ It should be noted that all message objects can be created in 3 ways:
7984#. From decoding the next packet in a buffer
8085
8186Setter Messages
82- ^^^^^^^^^^^^^^^
87+ ===============
8388These are the setter messages which are currently implemented.
8489
8590.. autoclass :: pyvesc.SetDutyCycle
@@ -90,14 +95,14 @@ These are the setter messages which are currently implemented.
9095.. autoclass :: pyvesc.SetRotorPositionMode
9196
9297Getter Messages
93- ^^^^^^^^^^^^^^^
98+ ===============
9499These are the getters that are currently implemented.
95100
96101.. autoclass :: pyvesc.GetValues
97102.. autoclass :: pyvesc.GetRotorPosition
98103
99104Implementing Additional Messages
100- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105+ ================================
101106Here we'll take a look at how to implement your own messages. You're message
102107class must have the metaclass `pyvesc.VESCMessage `. In addition to this you must
103108define two static attributes:
@@ -116,16 +121,16 @@ the SetDutyCycle message.
116121 class SetDutyCycle (metaclass = pyvesc .VESCMessage ):
117122 id = 5
118123 fields = [
119- (' duty_cycle' , ' f ' )
124+ (' duty_cycle' , ' i ' )
120125 ]
121126
122127 That's it! Taking a look at the declaration we see:
123128
124129* The message's ID is 5
125- * The message has a single field with a name `duty_cycle ` and type float32 (this
130+ * The message has a single field with a name `duty_cycle ` and type int (this
126131 is what the
127132 `format characters <https://docs.python.org/3.5/library/struct.html#format-characters >`_
128- `'f ' ` is)
133+ `'i ' ` is)
129134
130135If you are interested in the details of how this works, the `pyvesc.VESCMessage `
131136metaclass has a registry of all its children this registry is a dictionary
@@ -135,7 +140,7 @@ unique.
135140
136141
137142Encoding
138- --------
143+ ========
139144The following is the function call you should use to get a
140145packet for your message.
141146
@@ -145,7 +150,7 @@ Encoding is done by first serializing the message object and then framing it
145150in a VESC packet.
146151
147152Decoding
148- --------
153+ ========
149154The following is the function you should call to decode messages from the
150155buffer.
151156
0 commit comments