Lego Mindstorms EV3: Making a bot go straight with Gyro - lego-mindstorms

I've been trying to use Lego EV3 with a gyro sensor to make it go straight. I've tried many videos, but they don't seem to work. Here's my code

to start off, your multiplier seems a little too off, usually I do something like 2.
You might want to refer to the image in the link below.
Gyro programming
I usually use this as my base gyro programming. If you understand My Blocks, I am basically using that in my programme. All I have to do is to add in the values in terms of direction, speed and distance.
Feel free to ask me if you need further help!

Related

Leap Motion Custom Gestures

Is there any program that allows custom gestures recording and exporting?
Of course custom gestures for Leap Motion.
The pre-made gestures are not enough for me to make the app.
I tried this old system:
LeapTrainer
However, I have a problem on importing and exporting, and the data exported seems not useful out of LeapTrainer.
Update 1: I tried to find gadgets from Unity Asset Store, but to no avail. Can anyone suggest some tools/SDKs? My main purpose is to use gestures as dynamic slashing(vertically/horizontally/diagonally).
Please anyone can help me?
I started the same way as you did, but i end up building my own gestures base on the API outputs.
Its not that hard you just need to think it a bit.
For example working with fingers, isExtended and Angle between them helps alot.
For the palm you can use the GetPosition and where is pointing at.
So you can do if palm pointing to my face and the hand is open(base on fingers) you will mimic the ARM HMD menu that you see on the LM samples out there.
Or if IndexFinger is extended and the thumb draw a gun on your hand, if the thumb angle is < 10 make the gun shoot.
I truly recommend you to go that way, it will help to expand your knowledge on the device API. 3rd party tools might work but you need to learn how to use them, so better spend that time learning the LM API.

How to use accelerometer, CMMotion data to locate a point in 3D space?

I am creating an application. In which iPhone will be placed (a separate cover is made for it) with golf club(racket). I want to get array of points which state the path of the racket movement.
For example, I start collecting the data when racket is on the ground. After then user prepares himself for shot. So, he will take the racket back side and then he will hit the shot by moving racket forward. I want to catch all these points in 3D and want to plot them on screen (2D projection). I saw many similar questions, accelerometer, CMMotion framework documents. But could not find a way to doing so.
I hope, I have explained the question properly. Can you suggest me some formula or how to process the data to achieve it?
Thanks in advance.
You cannot track these movements in the 3D space.
But you can track the orientation of the racket and that should work well.
I have implemented a sensor fusion algorithm for the Shimmer platform, not a trivial task. I would use Core Motion and I would not try to create my own sensor fusion algorithm.
Hope this helps, good luck!
i tried the sensors fusion algorithm developed by Madgwick, but the output, on my device, it's similar to the CoreMotion Attitude output.
I don't have the possibility to test the attitude outputs from other iPhone, but in my case, the problem it's the yaw angle, even if the iphone it's fixed on the table the yaw angle tend to be unstable, probably due to the distinct chip-placement of z-axis gyro.

iOS: Get how fast user is moving

I'm wanting to figure out if a user is not moving at all, walking, or running using the iPhone. I'm not trying to implement a pedometer. I just want to know around about if someone is moving briskly, slowly, or not at all. I don't need mph or anything like that.
I think the accelerometer may be able to do this for me, but I was wondering if someone knows of any tutorials or example code that might be able to point me in the right direction?
Thanks to all that reply
The accelerometer won't do you any good here - it will only capture changes in velocity.
Just track the current location periodically and calculate the speed.
There are no hard thresholds for walking vs. running motion, so you will have to experiment a bit. The AccelerometerGraph sample code should get you started on how to get and interpret accelerometer data.
The Accelerometer is good, but if the user has an iPhone 4 or iPad 2 you should use the gyroscope.
CMMotionManager and Event Handeling Guide - Motion Events
Apple Documentation is the best example you can get!
People have a different bounce in their step between walking and running which can be measured with the accelerometer, but this differs between individuals (what shoes they are wearing, what surface they are upon, what part of the body is attached to the iPhone etc.), and this motion can probably be imitated by shaking the iPhone just right while standing still.
Experiment by recording the two types of acceleration profiles, and then use some sort of pattern matching to pick the most likely profile candidate from the current recorded acceleration data.

Collision detection with images on the iPhone using OpenGL

I'm working on a 2D game (kind of like a top down space shooter) for the iPhone using an engine very similar to cocos2d (not exactly though) on OpenGL ES. I'm trying to figure out how I'm going to do collision detection.
All the ships for my game are images, and the game will load the image as a texture onto the screen. I've got very very simple detection going already that basically just takes the rectangles of the images and checks to see if those collide and can do that just fine.
But, of course the ship isn't perfectly taking up the entire rectangle so there is whitespace in there. So my question is how am I supposed to account for that whitespace? Do I have to have the matrices of the ships stored? Or is there another way? I've also heard of possibly using the Chipmunk physics engine for collision detection? How would that work?
(1) regarding Chipmunk, the short answer is yes you should immediately download chipmunk, donate something to the bloke, and start learning about it.
Working with that for a day or so will basically answer all the questions you have. If you want to work with physics games you're going to need to get in to it.
(2) you ask about using an approximation ("just" a rectangle) instead of something more accurately shaped like your spaceships. In fact, you'll be perhaps amazed to learn, that is precisely how it is usually done in all your famous big-name games you've played since we were all kids! Indeed sometimes you might use little more than A DOT (!) to detect collisions.
What you'd probably do in production is try a more complicated model, and play with it for a few hours and see, is it actually any better to play with than your simple dot or rectangle model.
If you do want to make a more complicated model -- just make one! Build it up from three or four rectangles using your current system. Try them "all against each other", and have "one big one to check first" to see if it is even anywhere near each other (sort of a simple spatial hashing).
You will find that when you do it with Chipmunk, which as you now know you have to immediately begin after reading this message, you just build it up the same tedious way. It's not a magic bullet. But if you were going to use a "more complicated model" yes it is better to go with something standard, chipmunk, to do the work in - it will get done quicker and better. There is heaps to learn and you should hop to it!
(3) Unity is not just for 3D Finally if you want to do it the smart-ass grown up way, you'd have to use Unity3D which will let you access the very metal, the Nvidia physics on the chipset. Note that unity works perfectly for 2D games also - you just click one button in unity to use a 2D projection (many brand-name ifone 2D games are done exactly like that).
If you use that approach, you can (if you want) have "absolutely exact" physics, with every nook and cranny of your model modelled.
What is the downside to doing this? Ah hah ... well the thing is, you need superb actual 3D models of all the stuff in your game! (Like you see them building in the "how we made the movie" special features that come with your favourite Pixar blu-ray.) To do that you need things like autodesk, maya and the like. you would quite likely buy some models ready-made from a digital prop shop (no need to build "a chair" as it has been done 1000 times already and you can buy one for ten dollars).
(Unity3D is completely free to use for a few months while you see if it can make you money.)
Incidentally on the Chipmunk front --- you can just use Corona which is ridiculously easy to use and has chipmunk-like physics completely built in with zero effort on your part! You could have the whole game done in less time than it took to write this email. You could be selling your game already and thinking up the next one. Or, you could use "Cocos" which indeed has a chipmunk-like physics library built-in .. personally (just me) I do not like and won't touch cocos - but of course many games use it.
(It seems pointless, to me, using cocos which is a "for idiots" product, when you can just go ahead and use Corona, which is a "for idiots" product but stupendously easier to use, 1000x more solid, and probably literally 10x faster to finish your product and start making money.)
Noel Summary:
So in some sense using Unity3D (and hence, the actual nvidia physics on your computer's chips) is the ultimate solution if you want detailed nook-and-cranny collisions. Going down one step, Chipmunk is exactly, precisely what you should be using on the ifone/ipad for 2D physics -- it is precisely what is used in all the famous games we know so well. You have a bit of learning to do so hop to it - it's superfun. Finally go right ahead and just make your current model more complicated if you wish - roll your own by adding more rectangles!
And the fourth point is, be sure to remember that in games, astonishingly, you can often get away with remarkably simple physics (often SIMPLER!! than one rectangle - just a damn point - ie, simply measuring the distance between centers!) Fifthly after going to all the effort of testing more detailed physics, you would play test one against each other, and find out what is the simplest physics you can get away with.

how would I use iphone motion detection for an egg shaking-like application?

I am hoping to build an application similar to those egg shaking applications, to better understand how to detect motion on the iphone. I've been looking at accelerometer methods and motion and motion methods, but can't seem to get working what I want to do.
The specifics of my need are as follows: I want to be able to play one sound when user shakes the phone away from them, and play another sound when they shake back towards them. The motion from the user would be very similar to an egg shaker, with two different sounds able to be played depending on whether they moved the device towards or away from their chest. It would also be good to measure the intensity with which they moved away or towards.
Any ideas?
I've searched apple's sample code for a similar application, but there doesnt seem to be one.
Look at this game which is open source and makes great use of the accelerometer. It's a good one to be able to tell which direction you are going, but I haven't messed around much with intensity. I'm sure it's easy enough once you get into the details.
http://github.com/haqu/tweejump