zinger_swerve_controller icon indicating copy to clipboard operation
zinger_swerve_controller copied to clipboard

Speed and direction changes

Open peterheim1 opened this issue 1 year ago • 12 comments

Hi Patrick I'm building a new drive base for the robot that is much faster and I noticed that when I drive at a steady state any change in velocity or input some rotation the speed drops to zero or very close to it then picks up. I never noticed before as the robot was slow and the input was constrained at a lower value. I think if your doing small changes in direction it should be smooth

peterheim1 avatar Jun 30 '24 10:06 peterheim1

Hi @peterheim1 Yeah that seems like a reasonable expectation. I thought I fixed something like that a while ago but clearly I have not. I currently have no idea what would be causing this. Any chance you can upload another bag file for me to look at?

pvandervelde avatar Jul 02 '24 01:07 pvandervelde

ok here is the second bag I tried to do this on a fresh copy but had this error on the new check out zero_odometry.header.stamp = self.get_clock.now().to_msg() [swerve_controller-1] AttributeError: 'function' object has no attribute 'now'

peterheim1 avatar Jul 02 '24 02:07 peterheim1

The rosbag only contains the cmd_vel and the commands send to the steering and velocity parts, but not the joint states (i.e. not the result of the commands). Is that on purpose?

pvandervelde avatar Jul 02 '24 09:07 pvandervelde

I was testing the new robot base and it doesn't do joint_states yet. just tested it on the old robot and i did the same until t turned on the joint_states again. I can run both robot at the same time for testing if you put a note somewhere this will happen then we can close this

peterheim1 avatar Jul 02 '24 10:07 peterheim1

If you're seeing this on both robots then I think we should keep this open until we can show it's not the swerve code. I'm not making any promises of fixing this soon as I'm still busy with life and a new job, but I'm aiming to have a look as soon as I can. Thanks so much for taking my code and using it!

pvandervelde avatar Jul 03 '24 07:07 pvandervelde

ok here is the second bag I tried to do this on a fresh copy but had this error on the new check out zero_odometry.header.stamp = self.get_clock.now().to_msg() [swerve_controller-1] AttributeError: 'function' object has no attribute 'now'

i have this same issue on mine too, im running just for gazebo

voltrare avatar Jul 24 '24 14:07 voltrare

ok here is the second bag I tried to do this on a fresh copy but had this error on the new check out zero_odometry.header.stamp = self.get_clock.now().to_msg() [swerve_controller-1] AttributeError: 'function' object has no attribute 'now'

i have this same issue on mine too, im running just for gazebo

Can you try changing this line

zero_odometry.header.stamp = self.get_clock.now().to_msg()

to

zero_odometry.header.stamp = self.get_clock().now().to_msg()

In your local copy and let us know if that works?

pvandervelde avatar Aug 03 '24 08:08 pvandervelde

@peterheim1 I've been looking at the rosbag you provided and noticed something interesting. The velocity commands are going way too high relative to the requested speeds (e.g. at the start the requested speed is 0.35 and the final commanded speed is nearly 10.0). Then there are no measurements as the velocity drops back, or really there are no velocity commands and then it just starts at the velocity that is requested.

image

This is the /cmd_vel components at the bottom and the module velocity commands at the top. Notice how there are no little dots in the velocity commands as the value drops down. I'm not sure why its doing that. I'm assuming you don't have a copy of the logs for that run?

I've run some simple simulations and the controller can definitely handle constant velocities. But I don't know why it would 'overspeed'.

Also is there any information about the actual size of your robot (body dimensions and wheel radius etc.)?

pvandervelde avatar Sep 08 '24 11:09 pvandervelde

Another thought that has come to mind is that the code uses the joint_state information to determine what the current state is so that it can move from there. So I wonder if not having the joint_state information is causing the wild jumps

pvandervelde avatar Sep 09 '24 07:09 pvandervelde

I have a joint_state publisher the sends wheel velocity but the swerve controller dose a slow acceleration if i ignore the velocity / acceleration and just go to max power i can drive the robot around and it sort of works. That was the old robot it was much slower. the new robot is twice as fast and becomes uncontrollable also the wheel velocity is wrong when turning. I feel we need to fix the acceleration issue so the robot is controllable the see if the above issues are still a problem.

the robot specs are Size 45cm x 45cm steering center 30cm x30 cm wheel dia 10cm weight 18Kg 4 nema 17 steering motors 4 magnetic encoders for steering I2C comms 4 gear motors belt drive no gearing with encoders 4 arduino micro control boards I2C comms BNO8X for direction sense fused with odomrtery over I2C arduino uno R4 as main MCU rplidar I5 mini computer

3 python programs to control the robot main controller receives cmd_vel(position and velocity commands) publishes joint_states odom_controller publishes odom from joint_states angle controller publishes robot angle for odom conrtroller here is a link of the robot driving using my old controller the steering is very flaky

peterheim1 avatar Sep 09 '24 09:09 peterheim1

Ok in that case can you have a look at the last comment I put on issue #5. It's this one: https://github.com/pvandervelde/zinger_swerve_controller/issues/5#issuecomment-2285903134.

pvandervelde avatar Sep 09 '24 09:09 pvandervelde

@voltrare @peterheim1 the issue with the

zero_odometry.header.stamp = self.get_clock.now().to_msg() [swerve_controller-1] AttributeError: 'function' object has no attribute 'now'

Should be resolved with PR #10

pvandervelde avatar Sep 21 '24 01:09 pvandervelde