Main Content

randomConfiguration

Generate random configuration of robot

Description

example

configuration = randomConfiguration(robot) returns a random configuration of the specified robot. Each joint position in this configuration respects the joint limits set by the PositionLimits property of the corresponding rigidBodyJoint object in the robot model.

Examples

collapse all

Show different configurations of a robot created using a rigidBodyTree model. Use the homeConfiguration or randomConfiguration functions to generate the structure that defines all the joint positions.

Load a FANUC LR Mate 200ib from the Robotics System Toolbox™ loadrobot. It is returned as a rigidBodyTree object.

robot = loadrobot("fanucLRMate200ib");
showdetails(robot)
--------------------
Robot: (9 bodies)

 Idx     Body Name            Joint Name            Joint Type     Parent Name(Idx)   Children Name(s)
 ---     ---------            ----------            ----------     ----------------   ----------------
   1          base        base_link-base                 fixed         base_link(0)   
   2        link_1               joint_1              revolute         base_link(0)   link_2(3)  
   3        link_2               joint_2              revolute            link_1(2)   link_3(4)  
   4        link_3               joint_3              revolute            link_2(3)   link_4(5)  
   5        link_4               joint_4              revolute            link_3(4)   link_5(6)  
   6        link_5               joint_5              revolute            link_4(5)   link_6(7)  
   7        link_6               joint_6              revolute            link_5(6)   flange(8)  tool0(9)  
   8        flange        joint_6-flange                 fixed            link_6(7)   
   9         tool0          link_6-tool0                 fixed            link_6(7)   
--------------------

Create a structure for the home configuration of the robot. The structure has joint names and positions for each body on the robot model.

config = homeConfiguration(robot)
config=1×6 struct array with fields:
    JointName
    JointPosition

Show the home configuration using show. You do not need to specify a configuration input.

show(robot);

Modify the configuration and set the second joint position to pi/2. Show the resulting change in the robot configuration.

config(2).JointPosition = pi/2;
show(robot,config);

Create random configurations and show them.

show(robot,randomConfiguration(robot));

Input Arguments

collapse all

Robot model, specified as a rigidBodyTree object.

Output Arguments

collapse all

Robot configuration, returned as a vector of joint positions or a structure with joint names and positions for all the bodies in the robot model. You can generate a configuration using homeConfiguration(robot), randomConfiguration(robot), or by specifying your own joint positions in a structure. To use the vector form of configuration, set the DataFormat property for the robot to either 'row' or 'column'.

Extended Capabilities

Version History

Introduced in R2016b

expand all