Previous
DoCommand
How to use and define the extra parameters that many resource API methods offer in the Go and Python SDKs.
You can use extra parameters with modular resource implementations that are models of built-in resource types.
For example, a new model of sensor, or a new model of SLAM service.
The extra parameters in that built-in resource type’s API allow users to pass information to a resource’s driver that isn’t specified as a parameter for all models of the resource type.
This is necessary to keep the API of resource types consistent across, for example, all models of motor or all models of camera.
Send extra information in an API call in extra parameters as follows:
Optional[Dict[str, Any]] indicates you are required to pass in an object of either type Dict[str, Any] or None as a parameter when calling this method.
An object of type Dict[str, Any] is a dictionary with keys of type str and values of any type,
For example:
async def main():
# ... Connect to the machine.
# Get your sensor resource from the machine.
your_sensor = YourSensor.from_robot(robot, "your-sensor")
# Define a dictionary containing extra information.
your_info = {"type": "temperature", "description": "more info", "id": 123}
# Send this information in an call to the sensor resource's API.
await your_sensor.get_readings(extra=your_info)
If passing an object of type None, you do not have to specify None in the method call.
extra (map[string]interface{}) indicates you are required to pass in an object of either type map[string]interface{} or nil as a parameter when calling this method.
An object of type map[string]interface{} is an map with keys of type string and values of any type that you have cast to an interface.
For example:
func main() {
... // Connect to the machine
// Get your sensor resource from the machine.
yourSensor, err := YourSensor.FromRobot(robot, "your-sensor")
// Define a map containing extra information.
your_info := map[string]interface{}{"type": "temperature", "description": "more info", "id": 123}
// Send this information in an call to the sensor resource's API.
err := yourSensor.Readings(context.Background(), your_info)
}
If passing an object of type nil, you must specify nil in the method call or the method will fail.
If extra information must be passed to a resource, it is handled within a new, modular resource model’s custom API wrapper.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!