NVIDIA-AI-IOT / jetracer

An autonomous AI racecar using NVIDIA Jetson Nano
MIT License
1.06k stars 319 forks source link

Taimya only moves backwards in basic_motion #133

Open ParkerAI opened 2 years ago

ParkerAI commented 2 years ago

Gotten the hardware and software installed, and attempting to get basic motion to work. Steering was reversed, but responded fine, however, throttle will only move backwards, and will only accept positive values. Making either throttle or throttle_gain negative causes the car to simply sit in place and no action can be heard from the motor. I had once instance where it responded moving forward and backward correctly, but I'm not sure what caused it, it occurred in the middle of testing, and I have yet to be able to replicate it.

So right now the car will only take positive values for throttle, and because it's reserved, it will only move backwards. Wracking my brain for a solution, but can't find anything.

gotbordom commented 2 years ago

This sounds almost like the both the steering servo and the motor controller were plugged into the pins on the controller backwards?

krissdap commented 2 years ago

@ParkerAI For steering issue, you can modify steering_gain in jetracer/nvidia_racecar.py it defaults to -0.65, try setting to positive value, you might need to try adjusting steering_offset too if you can't make it center.

For forward/backward issue, if it only goes backwards, try working with throttle_gain from the same file.

For example,

from jetracer.nvidia_racecar import NvidiaRacecar

car = NvidiaRacecar()
car.steering_gain = traitlets.Float(default_value=0.65)
car.throttle_gain = traitlets.Float(default_value=-0.8)

The other problem of going in one direction not the other, it's probably because the behavior of the ESC (Electronic speed controller). Most modern ESC has three possible outputs: forward, brake, and backward.

To confirm this, send command in one direction, see the motor spin (in your case it's still going backward), then send command in another direction, the motor should stop, then repeat the same command again, the motor should now spin the the other direction (forward in your case).

If this is confirmed, then add code to your backward instruction.