Trailmakers

Trailmakers

TRAILMAKERS WORKSHOP
The Trailmakers Workshop is THE place to share vehicles you have built in Trailmakers. We encourage you to only upload your own original work.
Making logic for camera steerable vehicle
I'm trying to make a camera steerable vehicle but in a way that I don't have to put those cumbersome aiming servos on the wheels.

The method is to have one compass on the vehicle body and one of the aiming servo, then to calculate the difference between the compass orientations and connect to the steering hinges. That would even allow to make a rear steer vehicle to follow the camera, which is not possible with just aiming servos.

However, I cannot wrap my head around the the logic when the compass value jumps from 180 to -180 (or 1 to -1 when normalised) when facing south.

It could be solvable by making whole lot of if-statements in the logic, but that makes the logic too cumbersome to build on a small vehicle. I want to make this neat and tidy. And I haven't found anyone try to do this from the workshop.

Another way to solve this would be comparing the two compasses and having the output be either full left or full right, but I want more gradual control.

Would anyone be able to help me to get the logic expression right?
< >
Showing 1-2 of 2 comments
Fireball 3 May @ 10:51am 
I tried to think of it (couldn't try out myself stuff because my little girl is sleeping in the room of my gaming PC).
I think you have no choice you need:

If (abs(delta)>180
then delta-new= (abs(delta)-360)*delta/abs(delta) else delta_new=delta

Delta in this case is compass_view - compass_car

Delta_new can than used as imput for the angle of the steering. But scale it by at least 0.5 else the tires will twist 180 (of they could) and you would still drive straigt forward ;-)
Using normalized compasses the equation would be:
[(Compass1-Compass2)%2] - 1

I think one of the compasses needs an offset of 180.
< >
Showing 1-2 of 2 comments
Per page: 1530 50