Compass control

Hi everyone,

I’m working on a project and i need your help cause i can’t find the solution.
I have an RC car, and I drive it with a single joystick (direction and speed).
When the car moves away from the user, the directions “right / left” are correct “my left” is also “its left”.
But when the car comes back they are reversed , “my left” become “its right”.
I’m trying to find a way so that its movements are always “logical” for the user.

I imagined for example that if the car senses its distance from the remote
-> mooving away = normal directions.
-> approaching = reversed directions.

Perhaps the intensity of the control signal could be enough, but I 'm afraid it is not sensitive enough.

Maybe i’m wrong and something easyer exist…

I created a ticket, and someone from the staff sugested:
*" it could be possible **by adding a gyroscope , a microcontroller and a wireless module to send the information to the user.
The user will also have some sort of sensor to determine its the car orientation "
*

Any idea to solve this? :slight_smile:

Thanks a lot for your help!

The robot / car would need to know its orientation as well as yours; as such, you’d need to be carrying a sensor which provided both position and direction; this means a GPS-based controller - of which the easiest would be a flight controller since they also have a built-in magnetic compass to provide orientation. You’d need to create code such that if the car is in a specific location and oriented in a certain way, the controls would be reversed.
It might seem simple as a concept, but as far as we’re aware, implementing it would take quite a bit of electronics and programming. We’re not aware of anything which might work "out of the box.
There may be other ways of doing this, so perhaps other members of the community might offer their insight.

Thanks for your reply Benson,

I think i found an easy way to do it.

1 compas (A) in the car, 1 compas (B) in the remote and that’s it!
Then i just have to create a rule needed such as:

B orientation = 0°
If A orientation between 90° and -90° = normal control
If A orientation between 91° and -91° = reverted controls

Am i right? Could it be as sinple as that? xD

If the precision and reactivity of the compas is ok, i have questions / notes.

  • How will react the car if its orientation is 90.5°
  • The user have to point the remote strictly in dirrection of the car

Try some scenarios either on paper or in your head with the operator oriented in certain ways, as well as the car, and place the car around the operator. See if it makes sense.
Reusing your existing hardware won’t be easy since the compass needs to be connected to a microcontroller.

I tryed to imagine lots of scenarios and it will be very hard to configure with an standard RC car.
So i will build a prototype to test it.

Just to be sure, when we talk about that type of compass:
robotshop.com/en/lsm303-tilt-compensated-3-axis-compass.html
robotshop.com/en/tilt-compensated-magnetic-compass-cmps11.html

We are talking about azimut of the earth magnetic field, right?

I’m thinking about controlling it only with the compass.
I mean, the control will not give the order to turn right or left, but to get to the asked azimut.

Do you think that the precision and reactivity of a compass is enough as an only way to give it a direction?

Correct.

For the application you describe - certainly enough precision.

I presume that you were aiming for a control scheme somewhat like the following:

]Dual joystick axes are mapped to throttle and steering (like most RC cars)/:m]
]The desire is to flip the steering input as the car begins to approach you./:m]
With the above methodology, I expect that you will discover that the “inflection” point in the control scheme between the “moving away” and “approaching” scenarios will be problematic.

Imagine that you are driving the RC car away from you, but that you are performing a right turn. To do this, you are holding the throttle forward and the steering stick towards the right (or equivalent controls). The car starts veering towards its right, changing orientation from 0 to 90 degrees… But as you cross over into a 91 degree orientation, the controls will immediately reverse (at least for steering), causing the car to veer towards its left. Again, it crosses the 90 degree threshold and the car veers the other way, causing an abrupt oscillation around the “east-west” orientation.

An alternate scheme that you might find interesting could be the following:

]A two-axis joystick directs the car to move in the absolute direction of the control stick./:m]
]The desire is for the car to always re-orient itself so that it is following a direction parallel to your joystick input./:m]
Such a scheme could be viable, but it requires the car to constantly estimate the difference in angle between its heading and the joystick “heading” (relying upon a compass of some form on the car) and calculate the necessary steering input so that it can approach the target bearing & velocity. The control logic is more complex in this method, but the end result could be a fun, somewhat intuitive way to “move” your car around (rather than drive it). It would eliminate the need for you to consciously “put yourself inside the car’s orientation” in order to determine which way to steer. One disadvantage of this scheme is that movements across the joystick center point may cause the car to behave erratically as the heading can change rapidly despite a small change in control input.

Have fun!

Thanks for your contributions guys!

To conclude, i will build my own prototype and test the idea to control it with a single joystick, using compass.

To make it easier to build i will not use classic RC car, but 3 wheels to start.

  • 2 motorized wheels and 1 back wheel for stability.
    So the “car” will turn thanks to the difference of speed of the 2 motorized wheels, i suppose it will be easier to program.

Could you help me for the listing of hardware i will need?

Feel free to tell me if i forgot something. :wink:

For the car:

] 1 Arduino/:m]
] 1 compass module/:m]
] 2 brushless motors/:m]
] 2 ECS for brushless/:m]
] 1 battery/:m]
] 1 control receiver/:m]
] 1 USB charger module/:m]

For the remote

] 1 Arduino/:m]
] 1 compass module/:m]
] 1 joystick/:m]
] 1 transmitter module/:m]
] 1 USB charger module/:m]
Thanks for your help guys!

Not sure why you need two ESCs? Most RC cars only have one main drive motor and a servo for steering.

As i said, for the prototype i will use a 3 wheels car turning with the difference of speed between the 2 motors.
I think it will be easier to build and to program.

I’m not familiar with those hardware (but i will learn :slight_smile:

Do you think that for the group motor/esc/battery i chose is correct?

Is there everything i need? Like: cables, connector and small pieces i could forgot?

This is my shopping cart: 200$ total

Arduino Uno R3 USB Microcontroller
Product Code : RB-Ard-34

HMC5883L 3 Axis Magnetometer / Compass Module
Product Code : RB-Suf-17

Outrunner Sunshine Brushless Rotor Motor 2200KV 31.5A
Product Code : RB-May-05

35A BEC Multirotor ESC (Without Connectors)
Product Code : RB-May-03

7.4V Lipo Battery Charger
Product Code : RB-Dfr-607

Seeedstudio 433MHz RF Long Distance Transmitter / Receiver Pair
Product Code : RB-See-148

Adafruit Mini Joystick Sensor
Product Code : RB-Ada-35

Normally for a differential drive robot, you don’t use a brushless DC motor intended for use in a multirotor. We strongly suggest a DC gear motor and DC motor controller. Follow this tutorial series:
robotshop.com/blog/en/robots … ke-a-robot

Wow nice, i did not saw this tutorial pages, awesome, let’s read everting. xD

Try some scenarios either on paper or in your head with the operator oriented in certain ways, as well as the car, and place the car around the operator.