Basic Control
Prerequisites
The COBOTTA server is running.
Basic control through the COBOTTA server
When troubleshooting, first call get_current_position() to verify communication. This operation does not require take_arm or motor_on.
import asyncio
from cobotta2 import Config
from cobotta2.server import AsyncCobottaClient
from x_logger import XLogger
async def main():
Config.load_yaml("config_cobotta1.yaml")
logger = XLogger(log_level="info", logger_name=Config.CLIENT_LOGGER_NAME)
client = AsyncCobottaClient(config=Config, logger=logger)
result = await client.get_current_position()
print(result)
if __name__ == "__main__":
asyncio.run(main())
Loading YAML configuration
There are two ways to use configuration. If a program uses only one device server and therefore one configuration, Config can be used directly without creating an instance.
Config.load_yaml("config_cobotta1.yaml")
client = AsyncCobottaClient(config=Config, logger=logger)
If a program uses multiple configurations, for example for an electronic balance and COBOTTA, create separate instances.
config_cobotta = Config("config_cobotta1.yaml")
config_aandd = Config("config_aandd_reader.yaml")
cobotta = AsyncCobottaClient(config=config_cobotta, logger=logger)
aandd = AsyncCobottaClient(config=config_aandd, logger=logger)
Configuration for starting the control server
See
server_fastapifor the FastAPI-based server.