iRobotEducation / create3_sim

ROS 2 Simulation for the iRobot® Create® 3 Educational Robot
BSD 3-Clause "New" or "Revised" License
106 stars 56 forks source link

Acceleration/Deceleration profile of sim should match robot #59

Closed justinIRBT closed 2 years ago

justinIRBT commented 3 years ago

Problem When I tried to run a dance script on the robot vs. the sim the robot ends up at noticeably different angles with the same motion for the same time. This is likely because the command transitions are happening with a different ramp profile on robot vs. sim

Describe the solution you'd like Sim should use ramp limits as robot and command transitions should obey that ramp profile. This needs to factor in both axis (x/theta) and wheel (left/right) limits

justinIRBT commented 3 years ago

A couple of notes, I tried setting install/share/irobot_create_control/config/control.yaml to have extremely low acceleration to see if it was being applied, I tried the folowing

    # Velocity and acceleration limits
    # Whenever a min_* is unspecified, default to -max_*
    linear.x.has_velocity_limits: true
    linear.x.has_acceleration_limits: true
    linear.x.has_jerk_limits: false
    linear.x.max_velocity: 0.306
    linear.x.min_velocity: -0.306
    linear.x.max_acceleration: 0.01
    # Not using jerk limits yet
    # linear.x.max_jerk: 0.0
    # linear.x.min_jerk: 0.0

    angular.z.has_velocity_limits: true
    angular.z.has_acceleration_limits: true
    angular.z.has_jerk_limits: false
    angular.z.max_velocity: 1.9
    angular.z.min_velocity: -1.9
    # Using 0.6 linear for each wheel, assuming one wheel accel to 600 
    # and other to -600 with wheelbase leads to 5.15 rad/s^2
    # angular.z.max_acceleration: 5.15
    # angular.z.min_acceleration: -5.15
    angular.z.max_acceleration: 0.01
    angular.z.min_acceleration: -0.01
    # Not using jerk limits yet
    # angular.z.max_jerk: 0.0
    # angular.z.min_jerk: 0.0

But the robot seems to hit its max velocities instantly as opposed to the slow ramp I would expect. Secondly, I noticed linear and angular seem to use separate speed limiters, this doesn't account for the case where the command linear and angular are individually in bounds but the combination of both is higher than the individual wheel limits. For example if the command linear.x=0.306 and angular.z=1.9 is sent, each value is within limits, but if you execute both simultaneously, its outside of the individual wheel velocity limits. I can go into more detail on how this should be handled when this task gets assigned. If the acceleration limits in the existing code are a quick fix, it might make sense to fix that first, but if its a larger fix, it might be worth thinking about the full design, as the individual axis fix might be thrown away.

justinIRBT commented 2 years ago

There is a PR to fix the diff_drive_controller not obeying limits in ros2_controllers, its PR #252. That will address the not obeying any accel limits, but won't fix the per wheel max velocity/acceleration violation

justinIRBT commented 2 years ago

The PR to fix ros2_controllers accel limits merged into ros2_controllers, we will need to update our fork with the latest and get it into the create3_galactic branch. I asked @alsora to help with that. Once that is done, I think we can close this for now and consider the per wheel acceleration limits as follow on work. Those will likely have to be implemented in ros2_controllers diff_drive_controller, so it makes sense to wait until their master works on galactic and we stop using our fork, then we can make a branch to submit a PR against it and point to that branch until the PR is accepted.

alsora commented 2 years ago

Done. Now both the master and create3_galactic branches include https://github.com/ros-controls/ros2_controllers/commit/0469455c8fb70f001184e4e11034f271e019273c

justinIRBT commented 2 years ago

Closing for now. We can revisit the per wheel limits later