CONNECT
The CONNECT node establishes a connection to the Mecademic robot arm via HTTP and activates the robot arm. The IP Address to use is the same one that is used to access the Mecademic web interface. Example: 192.168.0.100 Params: ip_address : str The IP address of the robot arm. simulator : bool Whether to activate the simulator or not. Defaults to False. Returns: out : String The IP address of the robot arm, used in other Mecademic nodes to establish which arm they are communicating with.
Python Code
from flojoy import String, flojoy
from PYTHON.utils.mecademic_state.mecademic_state import (
add_handle,
init_handle_map,
query_for_handle,
)
@flojoy(deps={"mecademicpy": "1.4.0"})
def CONNECT(ip_address: str, simulator: bool = False) -> String:
"""
The CONNECT node establishes a connection to the Mecademic robot arm via HTTP and activates the robot arm. The IP Address to use is the same one that is used to access the Mecademic web interface. Example: 192.168.0.100
Parameters
----------
ip_address : str
The IP address of the robot arm.
simulator : bool
Whether to activate the simulator or not. Defaults to False.
Returns
-------
String
The IP address of the robot arm, used in other Mecademic nodes to establish which arm they are communicating with.
"""
init_handle_map(allow_reinit=True)
add_handle(ip_address)
handle = query_for_handle(ip_address)
if simulator:
handle.ActivateSim()
else:
handle.ActivateRobot()
handle.WaitActivated()
return String(s=ip_address)
Example
Having problems with this example app? Join our Discord community and we will help you out!
In this example, the CONNECT
node establishes a connection with the MECADEMIC MECA500 robot arm.
The node takes in the IP address of the robot arm as an input. It initializes the handle map and adds a handle for the given IP address.
Upon successful connection, the node returns the IP address, confirming that the robot arm is now connected and ready for further operations.
The CONNECT
node is used at the beginning of a workflow to ensure that a connection is established before any other operations are carried out.