Forums > MaxMSP

Trouble mapping output to unusual coordinate space

November 4, 2011 | 7:16 pm

I’m trying to control the motors of a Scribbler robot with a pictslider.

I’ve figured out what the x/y values of all the cardinal points need to be (see attached image)

but I’m having a heck of a time actually getting those values out in Max.

I’ve tried approaches using nodes, expr, table, and I’m just finding it mind-bending, although I suspect it’s rather simple.

[attachment=175274,2830]

Attachments:
  1. trouble.tiff

November 4, 2011 | 8:37 pm

The way you have put the points around the [pictslider] (which works with linear 2-dimensional cartesian coordinates) is not going to work (to the best of my knowledge and understanding).

As far as I can see, the coordinates you have used seem to be entirely normal cartesian coordinates, rotated 45 degrees.

Maye I ask how you arrived at those coordinates? And do you ONLY want those points, or do you want the intermediate values as well? If you only want those points, then that’s easy, but if you want the intermediate values then it’s going to be very tricky..


November 4, 2011 | 11:34 pm

>May I ask how you arrived at those coordinates?

The scribbler robot has two wheels. So to control it in a "joystick" fashion, I need to drive the two motors so that the robot will behave naturalistically based on the motion of the controller. There are a couple of ways to do this, but I chose:

CTR CTR: stop
FWD CTR: forward
FWD RT/LFT: maximum turn right or left (all drive forward in one wheel)
RT/RT & LFT/LFT: turn in place (wheels move opposite, max)
And the same for reverse

>And do you ONLY want those points, or do you want the intermediate values as well?

Yes, intermediate — that is what I’m struggling with!

>if you want the intermediate values then it’s going to be very tricky..

This is what I discovered!

Thanks for any insights you might have.


November 5, 2011 | 7:28 am

Basically you want to translate two joysticks into one..

I can’t think of any way this could happen on one [pictslider]. Why not use two [pictslider]s on Max? That would be dead easy and very straightforward.


November 5, 2011 | 12:11 pm

this patch gives intermediate values along each radius

– Pasted Max Patch, click to expand. –

November 5, 2011 | 1:26 pm

Thanks Samuel! This is excellent. I’ve commented the patch with my understanding of how you achieved it.

– Pasted Max Patch, click to expand. –

November 6, 2011 | 9:05 pm

Samuel’s patch was definitely on the right track, and I could not have gotten to this more fully developed patch without it. The previous patch works from the center to any cardinal point, but has discontinuities if you move around in the 2d space of the pictslider. For continuity along any vector of motion within the control space, the pictslider needs to be divided into 16 wedges, and the interpolation becomes not based on amplitude but angle within the wedge. After this, amplitude is used to scale everything towards zero as it approaches the center. TRICKY!

There is still a small error I can’t get at where I’m getting the result I should see at 270° when I am at 260° — so "forward" is actually somewhat right of true forward. But basically it works!

John

– Pasted Max Patch, click to expand. –

November 6, 2011 | 9:16 pm

Note however that the control area remains circular — the corners of the pictslider are ignored. If anyone knows how to stretch the circular aspect to the whole square…


November 7, 2011 | 7:44 pm

I’ve made a solution to this problem in a different way using a pictslider to drive the scribbler around. The main problem that John was trying to solve out was how to incorporate making the robot turn in place having wheels turn in opposite directions at the same time. I was thinking that for all practical purposes you’d only ever want the wheels to turn in opposite directions each at the same rate so I thought you could easily just have some key commands that would trigger this to happen at different speeds [Fast Left, Slow Left, Stop, Fast Right, Slow Right mapped to keys QWERT]. My patch still allows you to fully turn the robot around using the pictslider control but one wheel moves around the other which is stationary. Note that this patch generates messages that can be sent to the scribbler robot over a serial connection. It has two wheels which each accept integers 0 – 200 with 100 = stop, 0 = reverse full, 200 = forward full.

This was an interesting challenge. I’d love to hear how it could be done differently or better.

– Pasted Max Patch, click to expand. –

Viewing 9 posts - 1 through 9 (of 9 total)