第 19 節

Webots simulation platform

0瀏覽次數0訪問次數--跳出率--平均停留

This platform is very comfortable for testing kinematics.

You can convert SolidWorks to URDF (ROS officially provides the sw2urdf tool), and then convert URDF to Webots (Webots officially provides the urdf2webots tool).

https://github.com/ros/solidworks\_urdf\_exporter

https://github.com/cyberbotics/urdf2webots

In that case, even the motors have been selected for you — all you need to do is write the kinematics.

Motion control programs can be written in languages such as C/C++, Python, and Java. When controlling, simply pay attention to the method and units used for controlling the motor's angle and speed.

If you call setPosition(INFINITY) on the motor, it will become an angle motor, and the function originally used to set speed will instead set angular velocity.

If you do not set setPosition(INFINITY) for the motor, then this motor is a velocity motor.

The unit of angle is rad (questionable).

The speed unit is rad/s (questionable).

        for (int i = 0;i < 4;i++)
        {
                //舵电机仿真中默认顺时针为正
                swerve_motor[i] = robot->getMotor("swerve_joint" + std::to_string(i));
                //swerve_motor[i]->setPosition(INFINITY);       // 注释掉:不启用速度控制
                swerve_motor[i]->setPosition(0.0);       // 初始角度为0
                swerve_motor[i]->setVelocity(50.0);       // 设置角速度

                //驱动电机仿真中默认向后滚为正
                drive_motor[i] = robot->getMotor("drive_joint" + std::to_string(i));
                drive_motor[i]->setPosition(INFINITY);   // 启用速度控制
                drive_motor[i]->setVelocity(-0.0);        // 初始速度为0
        }
音乐页