pose

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This package defines a number of helper structs and methods for managing poses and 3D math.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pose

type Pose struct {

	// 3D position of a quantity (e.g., a link) in the URDF
	Position Vector3 `xml:"xyz,attr"`

	// Rotation of the quantity (e.g., a link) in the URDF
	Rotation Rotation `xml:"rpy,attr"`
}

Pose is an object which exactly represents a pose according to the URDF specification.

It uses the xml struct tags so that you can take advantage of the xml encoding/decoding features (e.g., xml.Marhsal, xml.Unmarshal) to easily read or write URDFs. No need to write any additional functions.

func (*Pose) Clear

func (p *Pose) Clear()

Sets the position to the origin and sets the rotation to the identity rotation.

type Rotation

type Rotation [4]float64

Rotation is an array of four elements representing the rotation of a quantity as a quaternion. We assume that the order of elements is x,y,z,w.

TODO(Kwesi): Investigate turning this into a struct with explicitly labeled values for x,y,z,w.

func NewRotation

func NewRotation(x, y, z, w float64) Rotation

Creates a new Rotation by defining the x,y,z,w values of the quaternion.

func (*Rotation) Clear

func (r *Rotation) Clear()

Sets the quaternion to the identity rotation.

func (*Rotation) FromRollPitchYaw

func (r *Rotation) FromRollPitchYaw(roll, pitch, yaw float64)

Defines the Rotation object as the quaternion that is equivalent to the provided roll, pitch, yaw values. (Q: Are these Euler angles?)

Assume roll (x), pitch (y) and yaw (z) are angles in radians.

func (Rotation) Inverse

func (r Rotation) Inverse() Rotation

Returns the inverse of the current rotation.

func (Rotation) Multiply

func (r Rotation) Multiply(other Rotation) Rotation

Returns the product of the two quaternions.

func (*Rotation) Normalize

func (r *Rotation) Normalize()

Normalizes the current quaternion.

func (*Rotation) Rotate

func (r *Rotation) Rotate(vec Vector3) Vector3

Rotates the vector `vec` by the current rotation and returns the result.

func (*Rotation) ToRollPitchYaw

func (r *Rotation) ToRollPitchYaw() (roll, pitch, yaw float64)

Converts the current rotation into the roll-pitch-yaw values.

The returned values are in radians.

func (*Rotation) UnmarshalXMLAttr

func (r *Rotation) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr parses the values from an "attribute" in an URDF tag and stores the result (if possible) into the current rotation.

An example of a tag that would take advantage of this method is the following:

<origin rpy="0 0 3.141592653589793" xyz="0 -0.0306011 0.054904"/>

This method should not be called directly by the user. It is used to implement an interface from the encoding/xml package.

func (*Rotation) W

func (r *Rotation) W() float64

Get the W value of the quaternion

func (*Rotation) X

func (r *Rotation) X() float64

Get the X value of the quaternion

func (*Rotation) Y

func (r *Rotation) Y() float64

Get the Y value of the quaternion

func (*Rotation) Z

func (r *Rotation) Z() float64

Get the Z value of the quaternion

type Vector3

type Vector3 [3]float64

An array of three elements which can be used in the decoding or encoding of 3D vectors in a URDF.

func NewVector3

func NewVector3(x, y, z float64) Vector3

Defines a new vector using three input values.

func (*Vector3) Clear

func (v *Vector3) Clear()

Sets the current vector to all zeros.

func (Vector3) MarshalXMLAttr

func (v Vector3) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr returns an xml attribute that can be easily encoded into a new URDF file.

This method should not normally be called by users. It is used to implement some important interfaces in encoding/xml, and thus is mainly used by encoding/xml when you call those methods (e.g., when you call xml.Marshal()).

func (*Vector3) Plus

func (v *Vector3) Plus(other Vector3) Vector3

Returns the addition of the two vectors.

func (*Vector3) UnmarshalXMLAttr

func (v *Vector3) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr updates the current vector using the values obtained from the attributes of an xml tag.

For example, the following tag contains a quantity that would be decoded using this method:

<origin rpy="0 0 3.141592653589793" xyz="0 -0.0306011 0.054904"/>

Note: This method should not be normally called by users. It is defined so that this type implements an interface from encoding/xml. Usually, it is called by the methods from encoding/xml that need it (e.g., xml.Unmarshal).

func (*Vector3) X

func (v *Vector3) X() float64

Returns the first value in the vector.

func (*Vector3) Y

func (v *Vector3) Y() float64

Returns the second value in the vector.

func (Vector3) Z

func (v Vector3) Z() float64

Returns the third value in the vector.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL