Welcome to ROSMASTER X3 Plus repository
3.MoveIt moves randomly(VM)
3. MoveIt moves randomly
This lesson takes the MoveIT simulation as an example. If you need to set the synchronization between the real machine and the simulation, please refer to the lesson [02, MoveIt Precautions and Controlling the Real Machine]. ! ! ! be careful! ! !
The effect demonstration is a virtual machine, and other masters are running (related to the performance of the master, depending on the actual situation).
3.2. Start
Start the MoveIT
roslaunch arm_moveit_demo x3plus_moveit_demo.launch sim:=true Start random motion node (choose one of two)
xxxxxxxxxxrosrun arm_moveit_demo 01_random_move.py # pythonrosrun arm_moveit_demo 01_random_move # C++The effect diagram is as follows

The effect of the source code is the same as that of the MoveIT interface [MotionPlanning--->Planning--->Goal State (random)].
3.2.Python source code
Import header file
xxxxxxxxxximport rospyfrom time import sleepfrom moveit_commander.move_group import MoveGroupCommanderInitialize nodes and create planning group instances
xxxxxxxxxx # Initialize node rospy.init_node("yahboomcar_random_move") # Initialize robotic arm planning group yahboomcar = MoveGroupCommander("arm_group")Set planning parameters
xxxxxxxxxx # Allow replanning when motion planning fails yahboomcar.allow_replanning(True) # Set planning time yahboomcar.set_planning_time(5) # Number of attempts to plan yahboomcar.set_num_planning_attempts(10) # Set allowable target position error yahboomcar.set_goal_position_tolerance(0.01) # Set allowable target pose error yahboomcar.set_goal_orientation_tolerance(0.01) # Set allowable target error yahboomcar.set_goal_tolerance(0.01) # Set maximum speed yahboomcar.set_max_velocity_scaling_factor(1.0) # Set maximum acceleration yahboomcar.set_max_acceleration_scaling_factor(1.0)Loop to set random target points
xxxxxxxxxx while not rospy.is_shutdown(): # Set random target points yahboomcar.set_random_target() # Start exercising yahboomcar.go() sleep(0.5)3.3. C++ source code
Import header file
xxxxxxxxxxCreate nodes and planning groups
xxxxxxxxxx ros::init(argc, argv, "yahboomcar_random_move_cpp"); ros::NodeHandle n; ros::AsyncSpinner spinner(1); spinner.start(); moveit::planning_interface::MoveGroupInterface yahboomcar("arm_group");Set planning parameters and initial position
xxxxxxxxxx // Set maximum speed yahboomcar.setMaxVelocityScalingFactor(1.0); // Set maximum acceleration yahboomcar.setMaxAccelerationScalingFactor(1.0); //Set target point yahboomcar.setNamedTarget("down"); //Start moving yahboomcar.move(); sleep(0.1);Loop to set random target points
xxxxxxxxxx while (!ros::isShuttingDown()){ //Set random target points yahboomcar.setRandomTarget(); yahboomcar.move(); sleep(0.5); }3.4. Node diagram
Take C++ node as an example
