using System;
using System.Collections.Generic;
using UnityEngine;
namespace URDF
{
///
/// Represents a URDF origin with position (xyz) and rotation (rpy - roll, pitch, yaw)
///
[Serializable]
public class URDFOrigin
{
public Vector3 xyz;
public Vector3 rpy; // Roll, Pitch, Yaw in radians
public URDFOrigin()
{
xyz = Vector3.zero;
rpy = Vector3.zero;
}
public URDFOrigin(Vector3 xyz, Vector3 rpy)
{
this.xyz = xyz;
this.rpy = rpy;
}
}
///
/// Represents URDF geometry (mesh, box, sphere, cylinder)
///
[Serializable]
public class URDFGeometry
{
public enum GeometryType
{
Mesh,
Box,
Sphere,
Cylinder
}
public GeometryType type;
public string meshFilename; // For mesh type
public Vector3 scale; // For mesh type
public Vector3 size; // For box type
public float radius; // For sphere/cylinder type
public float length; // For cylinder type
}
///
/// Represents a URDF visual element
///
[Serializable]
public class URDFVisual
{
public URDFOrigin origin;
public URDFGeometry geometry;
public string materialName;
public Color color;
}
///
/// Represents a URDF link
///
[Serializable]
public class URDFLink
{
public string name;
public List visuals;
public URDFOrigin inertialOrigin;
public float mass;
public Vector3 inertia; // ixx, iyy, izz
public URDFLink(string name)
{
this.name = name;
this.visuals = new List();
this.inertialOrigin = new URDFOrigin();
this.mass = 0f;
this.inertia = Vector3.zero;
}
}
///
/// Represents a URDF joint limit
///
[Serializable]
public class URDFJointLimit
{
public float lower;
public float upper;
public float effort;
public float velocity;
}
///
/// Represents a URDF joint
///
[Serializable]
public class URDFJoint
{
public enum JointType
{
Revolute,
Continuous,
Prismatic,
Fixed,
Floating,
Planar
}
public string name;
public JointType type;
public string parentLink;
public string childLink;
public URDFOrigin origin;
public Vector3 axis; // Rotation/translation axis
public URDFJointLimit limit;
public URDFJoint(string name)
{
this.name = name;
this.type = JointType.Fixed;
this.parentLink = "";
this.childLink = "";
this.origin = new URDFOrigin();
this.axis = Vector3.up;
this.limit = new URDFJointLimit();
}
}
///
/// Represents a complete URDF robot model
///
[Serializable]
public class URDFRobot
{
public string name;
public Dictionary links;
public Dictionary joints;
public URDFRobot(string name)
{
this.name = name;
this.links = new Dictionary();
this.joints = new Dictionary();
}
}
}