Skip to content

Commit 7bdbeed

Browse files
committed
update readme and fix some function names
1 parent 7ca57a8 commit 7bdbeed

File tree

5 files changed

+62
-49
lines changed

5 files changed

+62
-49
lines changed

README.md

+41-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# sidecar-starter-pack
22

3-
Authentication and communication utilities for FarmBot sidecars
3+
This library provides authentication, API, and control utilities for **FarmBot sidecars**. A **sidecar** is another computer such as a Raspberry Pi, laptop, or server that you are in full control of to install your own packages onto and run your own code, unlocking what cannot be done using FarmBot OS or the web app alone. For example, a sidecar could:
4+
5+
- Extend the capabilities of your FarmBot with specialized hardware such as a GPU, or a camera or other sensor requiring special drivers.
6+
- Expose your FarmBot's hardware capabilities as a device in a larger ecosystem such as one for home automation or scientific research.
7+
- Perform more advanced manipulation of your web app account's data which may be infeasible using the frontend interface.
48

59
[![Test Status](https://github.com/FarmBot-Labs/sidecar-starter-pack/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/FarmBot-Labs/sidecar-starter-pack/actions?query=branch%3Amain)
610
[![Coverage Status](https://coveralls.io/repos/github/FarmBot-Labs/sidecar-starter-pack/badge.svg?branch=main)](https://coveralls.io/github/FarmBot-Labs/sidecar-starter-pack?branch=main)
@@ -150,17 +154,17 @@ sidecar-starter-pack/
150154

151155
| class `BasicCommands()` | Description |
152156
| :--- | :--- |
153-
| `wait()` | Pauses execution for a certain number of milliseconds. |
157+
| `wait()` | Pauses FarmBot execution for a certain number of milliseconds. Note: You may need to combine this with a `sleep()` in your sidecar code. |
154158
| `e_stop()` | Emergency locks (E-stops) the Farmduino microcontroller and resets peripheral pins to OFF. |
155159
| `unlock()` | Unlocks a locked (E-stopped) device. |
156-
| `reboot()` | Reboots the FarmBot OS and reinitializes the device. |
157-
| `shutdown()` | Shuts down the FarmBot OS, turning the device off. |
160+
| `reboot()` | Reboots FarmBot OS and reinitializes the device. |
161+
| `shutdown()` | Shuts down FarmBot OS, turning the device off. Note: You will need to unplug and plug the FarmBot back in to turn it back on. |
158162

159163
### broker.py
160164

161165
| class `BrokerConnect()` | Description |
162166
| :--- | :--- |
163-
| `connect()` | Establish persistent connection to send messages via message broker. |
167+
| `connect()` | Establish a persistent connection to send messages via the message broker. |
164168
| `disconnect()` | Disconnect from the message broker. |
165169
| `publish()` | Publish messages containing CeleryScript via the message broker. |
166170
| `on_connect()` | Callback function triggered when a connection to the message broker is successfully established. |
@@ -187,15 +191,15 @@ sidecar-starter-pack/
187191
188192
| class `Information()` | Description |
189193
| :--- | :--- |
190-
| `get_info()` | Get information about a specific endpoint. |
191-
| `edit_info()` | Change information contained within an endpoint. |
192-
| `add_info()` | Create new information contained within an endpoint. |
193-
| `delete_info()` | Delete information contained within an endpoint. |
194-
| `safe_z()` | Returns the highest safe point along the z-axis. |
194+
| `get_info()` | GET information from the API. |
195+
| `edit_info()` | PATCH information in the API. |
196+
| `add_info()` | POST information to the API. |
197+
| `delete_info()` | DELETE information in the API. |
198+
| `safe_z()` | Returns the safe Z coordinate. |
195199
| `garden_size()` | Returns x-axis length, y-axis length, and area of garden bed. |
196-
| `group()` | Returns all group info or single by id. |
197-
| `curve()` | Returns all curve info or single by id. |
198-
| `soil_height()` | Use the camera to determine soil height at the current location. |
200+
| `group()` | Returns all groups or a single group by id. |
201+
| `curve()` | Returns all curves or a single curve by id. |
202+
| `measure_soil_height()` | Use the camera to determine soil height at the current location. |
199203
| `read_status()` | Returns the FarmBot status tree. |
200204
| `read_sensor()` | Reads the given pin by id. |
201205

@@ -205,16 +209,16 @@ sidecar-starter-pack/
205209
| :--- | :--- |
206210
| `get_job()` | Retrieves the status or details of the specified job. |
207211
| `set_job()` | Initiates or modifies job with given parameters. |
208-
| `complete_job()` | Marks job as completed and triggers any associated actions. |
212+
| `complete_job()` | Marks job as completed. |
209213

210214
### messages.py
211215

212216
| class `MessageHandling()` | Description |
213217
| :--- | :--- |
214-
| `log()` | Sends new log message via the API. Requires the page to be refreshed before appearing. |
218+
| `log()` | Sends new log message via the API. Requires the web app page to be refreshed before appearing. |
215219
| `message()` | Sends new log message via the message broker. |
216-
| `debug()` | Sends debug message used for developer information or troubleshooting. |
217-
| `toast()` | Sends a message that pops up on the user interface briefly. |
220+
| `debug()` | Sends debug message used for developer information or troubleshooting. These will not persist in the database. |
221+
| `toast()` | Sends a message that pops up in the web app briefly. |
218222

219223
### movements.py
220224

@@ -223,26 +227,26 @@ sidecar-starter-pack/
223227
| `move()` | Moves to the specified (x, y, z) coordinate. |
224228
| `set_home()` | Sets the current position as the home position for a specific axis. |
225229
| `find_home()` | Moves the device to the home position for a specified axis. |
226-
| `axis_length()` | Returns the length of a specified axis. |
230+
| `find_axis_length()` | Finds the length of a specified axis. |
227231
| `get_xyz()` | Returns the current (x, y, z) coordinates of the FarmBot. |
228-
| `check_position()` | Verifies position of the FarmBot within specified tolerance range. |
232+
| `check_position()` | Verifies the current position of the FarmBot is within the specified tolerance range. |
229233

230234
### peripherals.py
231235

232236
| class `Peripherals()` | Description |
233237
| :--- | :--- |
234238
| `control_servo()` | Set servo angle between 0-100 degrees. |
235-
| `control_peripheral()` | Set peripheral value (ON/OFF or slider value from 0-255) and mode (digital or analog). |
236-
| `toggle_peripheral()` | Toggles the state of a specific peripheral between 'on' (100%) and 'off' (0%). |
237-
| `on()` | Turns specified peripheral 'on' (100%). |
238-
| `off()` | Turns specified peripheral 'off' (0%). |
239+
| `control_peripheral()` | Set peripheral value (digital ON/OFF or analog value from 0-255). |
240+
| `toggle_peripheral()` | Toggles the state of a specific peripheral between 'ON' (100%) and 'OFF' (0%). |
241+
| `on()` | Turns specified peripheral 'ON' (100%). |
242+
| `off()` | Turns specified peripheral 'OFF' (0%). |
239243

240244
### resources.py
241245

242246
| class `Resources()` | Description |
243247
| :--- | :--- |
244-
| `sequence()` | Executes a predefined sequence. |
245-
| `get_seed_tray_cell()` | Identifies and returns the location of specified cell in the seed tray. |
248+
| `sequence()` | Executes a predefined sequence by id. |
249+
| `get_seed_tray_cell()` | Returns the coordinates of the specified cell in a seed tray. |
246250
| `detect_weeds()` | Scans the garden to detect weeds. |
247251
| `lua()` | Executes custom Lua code snippets to perform complex tasks or automations. |
248252
| `if_statement()` | Performs conditional check and executes actions based on the outcome. |
@@ -253,9 +257,9 @@ sidecar-starter-pack/
253257

254258
| class `ToolControls()` | Description |
255259
| :--- | :--- |
256-
| `mount_tool()` | Mounts the given tool and pulls it out of assigned slot. |
257-
| `dismount_tool()` | Dismounts the currently mounted tool into assigned slot. |
258-
| `water()` | Moves to and waters plant based on age and assigned watering curve. |
260+
| `mount_tool()` | Mounts the given tool and pulls it out of its assigned slot. |
261+
| `dismount_tool()` | Dismounts the currently mounted tool into its assigned slot. |
262+
| `water()` | Moves to and waters a plant based on its age and assigned watering curve. |
259263
| `dispense()` | Dispenses user-defined amount of liquid in milliliters. |
260264
<!--- | `verify_tool()` | Verifies if tool is mounted to UTM via tool verification pin and MOUNTED TOOL field in FarmBot’s state tree. | --->
261265

@@ -280,3 +284,12 @@ message = {
280284
]
281285
}
282286
```
287+
288+
### Local development
289+
290+
If you are working on the sidecar-starter-pack itself, ensure any changes pass all tests before submitting a pull request.
291+
292+
```
293+
python -m pip install coverage
294+
coverage run -m unittest discover
295+
```

functions/information.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# ├── [API] garden_size()
1212
# ├── [API] group()
1313
# ├── [API] curve()
14-
# ├── [BROKER] soil_height()
14+
# ├── [BROKER] measure_soil_height()
1515
# ├── [BROKER] read_status()
1616
# └── [BROKER] read_sensor()
1717

@@ -114,17 +114,17 @@ def curve(self, curve_id=None):
114114
self.state.print_status(endpoint_json=curve_data)
115115
return curve_data
116116

117-
def soil_height(self):
118-
"""Use the camera to determine soil height at the current location."""
117+
def measure_soil_height(self):
118+
"""Use the camera to measure the soil height at the current location."""
119119

120-
soil_height_message = {
120+
measure_soil_height_message = {
121121
"kind": "execute_script",
122122
"args": {
123123
"label": "Measure Soil Height"
124124
}
125125
}
126126

127-
self.broker.publish(soil_height_message)
127+
self.broker.publish(measure_soil_height_message)
128128

129129
def read_status(self):
130130
"""Returns the FarmBot status tree."""

functions/movements.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ├── [BROKER] move()
88
# ├── [BROKER] set_home()
99
# ├── [BROKER] find_home()
10-
# ├── [BROKER] axis_length()
10+
# ├── [BROKER] find_axis_length()
1111
# └── [BROKER] check_position()
1212

1313
from .broker import BrokerConnect
@@ -82,17 +82,17 @@ def find_home(self, axis="all", speed=100):
8282

8383
self.state.print_status(description="Moved to home position.")
8484

85-
def axis_length(self, axis="all"):
86-
"""Returns the length of a specified axis."""
85+
def find_axis_length(self, axis="all"):
86+
"""Finds the length of a specified axis."""
8787

88-
axis_length_message = {
88+
find_axis_length_message = {
8989
"kind": "calibrate",
9090
"args": {
9191
"axis": axis
9292
}
9393
}
9494

95-
self.broker.publish(axis_length_message)
95+
self.broker.publish(find_axis_length_message)
9696

9797
def get_xyz(self):
9898
"""Returns the current (x, y, z) coordinates of the FarmBot."""

main.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def curve(self, curve_id=None):
123123
"""Returns all curve info or single by id."""
124124
return self.info.curve(curve_id)
125125

126-
def soil_height(self):
126+
def measure_soil_height(self):
127127
"""Use the camera to determine soil height at the current location."""
128-
return self.info.soil_height()
128+
return self.info.measure_soil_height()
129129

130130
def read_status(self):
131131
"""Returns the FarmBot status tree."""
@@ -181,9 +181,9 @@ def find_home(self, axis="all", speed=100):
181181
"""Moves the device to the home position for a specified axis."""
182182
return self.movements.find_home(axis, speed)
183183

184-
def axis_length(self, axis="all"):
185-
"""Returns the length of a specified axis."""
186-
return self.movements.axis_length(axis)
184+
def find_axis_length(self, axis="all"):
185+
"""Finds the length of a specified axis."""
186+
return self.movements.find_axis_length(axis)
187187

188188
def get_xyz(self):
189189
"""Returns the current (x, y, z) coordinates of the FarmBot."""

tests/tests_main.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,10 @@ def exec_command():
946946
extra_rpc_args={},
947947
mock_api_response={})
948948

949-
def test_axis_length(self):
950-
'''Test axis_length command'''
949+
def test_find_axis_length(self):
950+
'''Test find_axis_length command'''
951951
def exec_command():
952-
self.fb.axis_length()
952+
self.fb.find_axis_length()
953953
self.send_command_test_helper(
954954
exec_command,
955955
expected_command={
@@ -979,10 +979,10 @@ def exec_command():
979979
extra_rpc_args={},
980980
mock_api_response={'mode': 0})
981981

982-
def test_soil_height(self):
983-
'''Test soil_height command'''
982+
def test_measure_soil_height(self):
983+
'''Test measure_soil_height command'''
984984
def exec_command():
985-
self.fb.soil_height()
985+
self.fb.measure_soil_height()
986986
self.send_command_test_helper(
987987
exec_command,
988988
expected_command={

0 commit comments

Comments
 (0)