Robot Arm Teaching Example
Description
- In 0-torque mode, the robot arm can be dragged manually
- Records the arm joint data while dragging
- Provides the function of replaying recorded motions
- Supports two recording methods: rosbag topic data recording and keyframe data recording
- rosbag recording overlaps better with the preset angles, but it records all data and may include an unwanted motion
- Keyframe recording
Program Logic
1. Startup Process
- Arm zero calibration: If the robotic arm is multi-turn and has already been calibrated, this step can be skipped; otherwise, straighten the arm and run the calibration command
- Start the robot: Select the corresponding startup command according to the robot type
- Motor enable: Press the 'o' key to enable the motors
2. Recording Modes
- rosbag recording mode: Records the complete topic data stream
- Keyframe recording mode: Records keyframe motions by pressing the 's' key
3. Playback Modes
- rosbag playback mode: Plays back the complete topic data stream
- Keyframe playback mode: Plays back keyframe data, with controllable execution speed
Build
cd /home/lab/kuavo-ros-opensource
sudo su
catkin build kuavo_sdk teach_pendantExecution
1. Start the Robot Program
First, arm zero calibration is required. If your robotic arm is multi-turn and you have already calibrated it, skip this step; otherwise, straighten the arm and run the following command to calibrate:
source devel/setup.bash
rosrun hardware_node setZero.shThen start the robot:
source devel/setup.bash
# 正常具有全身的机器人
roslaunch humanoid_controllers load_kuavo_real.launch teach_pendant:=1
# 只有上半身的机器人(轮臂机器人)
roslaunch humanoid_controllers load_kuavo_real_half_up_body.launch teach_pendant:=1After startup, press the o key to enable the motors.
2. Record a Data Bag
2.1 Record rosbag Topic Data
First make sure the robot is started in 0-torque mode, then run the following command to record topic data:
source devel/setup.bash
roslaunch teach_pendant launch_teach_pendant_record_rosbag.launch save_bag:=/path/to/save/bagname.bagHere /path/to/save/bagname.bag is the full path name of the rosbag file to be saved.
2.2 Record Keyframe Data
Press the 's' key on the keyboard to record one keyframe motion:
source devel/setup.bash
roslaunch teach_pendant launch_teach_pendant_record_file.launch save_file:=/path/to/save/filenameHere /path/to/save/filename is the full path name of the keyframe file to be saved.
The following is the terminal output when recording keyframes:
Recording started.
Key commands:
s - Save the current joint state to file
Ctrl+C - Exit the programAt this point, pressing 's' records one frame of data.
An example of a file with two recorded keyframes is as follows (the unit is degrees):
frame_1: [6.688944668069868, 0.26222175954934457, 0.8742850281282628, 0.043699139520925044, 0.1748552065106258, -0.17486768318044163, 0.04366378011757604, 8.587659186481185, -0.7212213275411588, 1.1147072424638924, -0.6557031046764389, 0.5901067615630409, 0.939812979855269, -0.6774928350594672]
frame_2: [6.674225439283481, 0.2622862835336425, 0.8742997290724711, 0.04366009126140115, 0.1748897410867445, -0.1748426016729588, 0.04367398806815109, -12.56390743084296, -51.71382905849491, -0.3496471881561264, -0.9398426465709862, 32.632482053002796, 6.797494131713388, -12.589631500169236]3. Play Back the Recorded Motion
Note: Before playing back a motion, first close the previous program and make sure the robot is standing in its normal state, then play back the motion.
First make sure the robot is started on the normal branch (able to stand normally with its whole body), then run the following command to play back the previously recorded motion:
3.1 Play Back the Recorded rosbag File
source devel/setup.bash
roslaunch teach_pendant launch_teach_pendant_play_rosbag.launch bag_file:=/path/to/bag/path/to/bag is the topic data bag file recorded earlier.
3.2 Play Back the Recorded Keyframe File
source devel/setup.bash
roslaunch teach_pendant launch_teach_pendant_play_file.launch file:=/path/to/file interval_sec:=1/path/to/fileis the keyframe data file recorded earlierinterval_secis the execution time interval between two keyframes. This parameter controls the motion execution speed; the unit is seconds, and the minimum value is 0.5 seconds
Parameter Description
teach_pendant: Startup parameter; set to 1 to enable teaching modesave_bag: Save path parameter in rosbag recording modesave_file: Save path parameter in keyframe recording modebag_file: File path parameter in rosbag playback modefile: File path parameter in keyframe playback modeinterval_sec: Time interval parameter in keyframe playback mode (unit: seconds, minimum value: 0.5)
Usage Notes
- Zero calibration: Zero calibration is required on first use or after replacing the robotic arm
- Motor enable: After startup, you must press the 'o' key to enable the motors before teaching operations
- Recording mode selection:
- rosbag mode is suitable for recording continuous motion trajectories
- Keyframe mode is suitable for recording discrete key poses
- Playback environment: When playing back a motion, the robot must be started in normal mode to ensure it can stand normally
- Time interval control: During keyframe playback, the motion execution speed can be controlled with the
interval_secparameter
Results
- Teaching recording: Drag the robot arm manually in 0-torque mode, and the system automatically records the joint data
- Motion replay: The robot accurately reproduces the taught motion along the recorded trajectory