RobotAPI HowTos

 

How to convert a pose variant to an Eigen matrix

Use the following code if you want to convert from an armarx::Pose, an armarx::FramedPose or an armarx::LinkedPose. Refer to Intelligent Coordinates for further information.

std::string refFrame = "Base";
// If you are in a statechart
FramedPosePtr pose = getInput<FramedPose>("pose");
Eigen::Matrix4f matrix = pose->toEigen();

How to convert position and orientation variants to an Eigen matrices

Use the following code if you want to convert from armarx::FramedPosition and armarx::FramedOrientation. Refer to Intelligent Coordinates for further information.

std::string refFrame = "Base";
// If you are in a statechart
FramedPositionPtr position = getInput<FramedPosition>("position");
FramedOrientationPtr orientation = getInput<FramedOrientation>("orientation");
PosePtr pose = new Pose(position, orientation);
Eigen::Matrix4f matrix = pose->toEigen();

How to change a frame of a coordinate/pose

Refer to Intelligent Coordinates.

How to start a RobotStateComponent

The RobotState component serves as a central component for storing all robot related data. For now this data covers the current joint angles of the robot.
The RobotStateComponent implements a KinematicUnitListener, hence it reacts on all joint updates that are reported by a KinematicUnit component. An exemplary startup script could look like this

export CORE_PATH=${ArmarXHome_DIR}/Core
export CORE_BIN_PATH=$CORE_PATH/build/bin
export SCRIPT_PATH=$CORE_BIN_PATH
$SCRIPT_PATH/startApplication.sh $CORE_BIN_PATH/KinematicUnitSimulationRun --Ice.Config=./config/Armar3Config.cfg &
$SCRIPT_PATH/startApplication.sh $CORE_BIN_PATH/RobotStateComponentRun --Ice.Config=./config/Armar3Config.cfg &

With the corresponding configuration in ./config/Armar3Config.cfg:

# setup for KinemticUnitSimulation
ArmarX.KinematicUnitSimulation.RobotFileName = RobotAPI/robots/Armar3/ArmarIII.xml
ArmarX.KinematicUnitSimulation.RobotNodeSetName = Robot
ArmarX.KinematicUnitSimulation.ObjectName = Armar3KinematicUnit
#setup for RobotStateComponent
ArmarX.RobotStateComponent.RobotFileName = RobotAPI/robots/Armar3/ArmarIII.xml
ArmarX.RobotStateComponent.RobotNodeSetName = Robot
ArmarX.RobotStateComponent.ObjectName = RobotStateComponent

How to inspect the robot's structure

Robots are usually defined in the Simox XML (https://git.h2t.iar.kit.edu/sw/simox/simox/-/wikis/FileFormat) or in the URDF format. To inspect the kinematic structure, visualizations and physical properties, you can use the RobotViewer tool which is part of the Simox library. In particlular you can visualize all coordinate frames that are present in the robot defintion. Start it with the following command:

RobotViewer --robot path/to/robot.xml
The Simox tool RobotViewer can be used to inspect the kinematic structure of a robot.

How to access a RobotStateComponent

The RobotStateComponent provides several methods for accessing the current configuration of the robot and for getting a snapshot of the current state which is compatible with models of the Simox/VirtualRobot framework. With these models the whole functionality of Simox (https://git.h2t.iar.kit.edu/sw/simox/simox) can be used, e.g. IK solving, collision detection or motion and grasp planning.

See also Remote Robot State.

Creating a synchronized model (RemoteRobot)

A RemoteRobot is a synchronized robot data structure which always represents the current state of the robot. Be aware, that any operations on this model (e.g. IK solving) may take long (e.g. 100 ms) due to the heavy network communication overhead. For complex operations it is suggested to create a local clone of the data structure and to synchronize this clone before working with it (see below).

The Remote Robot can be created by getting the proxy to the RobotStateComponent and grabbing a RemoteRobot:

std::string robotStateComponentName = "RobotState";
armarx::RobotStateComponentInterfacePrx robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(robotStateComponentName);
armarx::RemoteRobotPtr remoteRobot(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));

The remoteRobot object can now be accessed in order to get joint angles or to convert cooridnate frames.

Create a local robot and synchronize it by hand

When complex operations should be performed on a robot model the use of a RemoteRobot could slow down the computation since each joint access induces a network transfer. Hence the RemoteRobot offers a method to create a local copy of the remote data.
If only the structure of the robot is needed (without 3D models, useful e.g. for kinematic calculations, coorinate transformations, etc), the following method can be used to create a local clone of the robot:

VirtualRobot::RobotPtr robot = RemoteRobot::createLocalClone(robotStateComponent);

The robot instance can be manually synchronized with the remote data structure (i.e. copy the joint angle values) by calling:

RemoteRobot::synchronizeLocalClone(robot,robotStateComponent);

If a complete robot model (including 3d models) is needed, you can pass a filename to a local file to allow the system to load the complete robot:

std::string robotFile = "RobotAPI/robots/Armar3/ArmarIII.xml";
ArmarXDataPath::getAbsolutePath(robotFile,robotFile);
VirtualRobot::RobotPtr robot = RemoteRobot::createLocalClone(robotStateComponent, filename);

This model can be synchronized in the same way as the first model.

How to Plot Values from the Memory System

You can use the component MemoryToDebugObserver to query data from memory servers and send them to the DebugObserver. These values can then be viewed using the ObserverGui or the Live Plotter.

To use this functionality in your own code, use the class armarx::armem::client::util::MemoryToDebugObserver.

LinkedPose.h
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
RobotAPI
This file is part of ArmarX.
robots
std::vector< VirtualRobot::RobotPtr > robots
Definition: VisualizationRobot.cpp:86
armarx::PosePtr
IceInternal::Handle< Pose > PosePtr
Definition: Pose.h:306
armarx::FramedPosePtr
IceInternal::Handle< FramedPose > FramedPosePtr
Definition: FramedPose.h:250
SCRIPT_PATH
#define SCRIPT_PATH
Definition: CMakePackageFinder.cpp:55
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
filename
std::string filename
Definition: VisualizationRobot.cpp:84
armarx::FramedPositionPtr
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition: FramedPose.h:134
armarx::RemoteRobotPtr
std::shared_ptr< RemoteRobot > RemoteRobotPtr
Definition: RemoteRobot.h:263
Ice
Definition: DBTypes.cpp:64
armarx::FramedOrientationPtr
IceInternal::Handle< FramedOrientation > FramedOrientationPtr
Definition: FramedPose.h:191
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18