Get Timestamp
SUMMARY
Get Timestamp returns the timestamp (in seconds) of the most recent state update.
Reads from the manipulator state - controller-reported time of the latest telemetry sample when connected, wall-clock time of the most recent cache write offline.
UNITS
Returns a timestamp in seconds.
The Skill
python
timestamp = robot.get_timestamp()The Code
python
"""
Logs the timestamp of the most recent state update, in seconds since the Unix epoch.
Supports Universal Robots (UR), Epson, virtual, and Isaac Sim.
Usage:
python get_timestamp.py [--ip <ROBOT_IP>] [--prim_path <PRIM_PATH>]
"""
import argparse
from loguru import logger
from telekinesis.synapse.robots.manipulators import universal_robots
def main(ip: str | None, prim_path: str | None) -> None:
"""Log the timestamp of the most recent state update."""
#===================== Create Robot ==========================================
robot = universal_robots.UniversalRobotsUR10E(name='UR10e')
try:
#===================== Connect Robot ==========================================
if ip:
robot.connect(ip=ip)
elif prim_path:
robot.connect(simulation_prim_path=prim_path)
# ==================== Run Skill ============================================
logger.success(f"timestamp [s since epoch]: {robot.get_timestamp()}")
except (ConnectionError, OSError) as e:
logger.error(f"Error occurred: {e}")
finally:
robot.disconnect()
robot.shutdown()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Read state timestamp Synapse example")
parser.add_argument("--ip", type=str, default=None,
help="UR robot IP address for real hardware, e.g. 192.168.1.100")
parser.add_argument("--prim_path", type=str, default=None,
help='Isaac Sim articulation prim path, e.g. "/World/ur10e"')
args = parser.parse_args()
main(ip=args.ip, prim_path=args.prim_path)Running the Example
bash
python get_timestamp.pybash
python get_timestamp.py --prim_path /World/ur10ebash
python get_timestamp.py --ip 192.168.1.100For all options:
bash
python get_timestamp.py --helpParameter Configuration
This skill takes no input parameters.
Returns
| Type | Description |
|---|---|
float | Timestamp of the most recent state update, in seconds. Controller-reported time when connected; wall-clock time of the last cache write offline. |
Where to Use the Skill
- State logging - Attach a timestamp to every sampled data point.
- Duration measurement - Record the timestamp before and after a motion to measure execution time.
- Data synchronization - Align robot state samples with external sensor streams.
When Not to Use the Skill
- You need wall-clock time independent of the robot state - use Python's
time.time()ordatetime.now()instead.