Defining a new trajectory

343 views
Skip to first unread message

fyr...@googlemail.com

unread,
Apr 18, 2012, 6:05:09 AM4/18/12
to IMUSim
Dear IMUSim Team,

I came across IMUSim when I was looking for a fitting way to simulate
the data an IMU mounted on an underground mining device would deliver.
IMUSim seems to be doing exactly what I want, however I'm struggling
to find a way to define a trajectory myself.

When I try to create a new object of any of the trajectory classes, I
get an error message telling me it either "takes no parameters" or it
"can't be instatiated".

What am I doing wrong? Note that I have not worked with python in over
10 years, so my knowledge about that language is basically 0.

Kind regards.

Martin Ling

unread,
Apr 18, 2012, 9:28:31 AM4/18/12
to imusim...@googlegroups.com, fyr...@googlemail.com
On Wed, Apr 18, 2012 at 03:05:09AM -0700, fyr...@googlemail.com wrote:
>
> When I try to create a new object of any of the trajectory classes, I
> get an error message telling me it either "takes no parameters" or it
> "can't be instatiated".
>
> What am I doing wrong?

I don't know because you didn't post your code. Here's an example you
can work from though.

The simplest way to build up a trajectory is from known positions
and rotations at given times. IMUsim provides the tools to interpolate
between these to get the continuous trajectory needed for simulation.

Let's say you have an object that's moving and rotating. In this example
I'll generate the positions and rotations mathematically, but you could
use any existing data that you have from experiments or simulations. You
just need to load it in somehow.

We'll model an object moving with constant acceleration and angular rate:

from imusim.all import *

# Initial position:
position = vector(1, 2, 3)

# Velocity:
velocity = vector(3, 1, 2)

# Acceleration:
accel = vector(0.1, 0.1, -0.2)

# Angular rate on the Z-axis:
zrate = 0.1

# Timesteps from 0 to 10 seconds at 0.1 second intervals:
times = np.arange(0, 10, 0.1)

# Calculate positions at each timestep:
positions = position + velocity * times + 0.5 * accel * times**2

# Calculate rotations at each timestep:
rotations = QuaternionArray([Quaternion.fromEuler((zrate * t, 0, 0), 'zyx') for t in times])

# Create a SampledTrajectory from the data:
sampledTrajectory = SampledTrajectory.fromArrays(times, positions, rotations)

# Create a SplinedTrajectory that can be used for simulation:
splinedTrajectory = SplinedTrajectory(sampledTrajectory)


Hope this helps.


Martin

ehsan shokri

unread,
Dec 25, 2012, 5:09:33 PM12/25/12
to imusim...@googlegroups.com, fyr...@googlemail.com, martin...@earth.li
Hi dear Martin
I am new at IMUSIM
I want to know how can i plot my designed trajectory, because i need to compare it with my Matlab results also
is there a way to design 3D-trajectories in IMUSIM?
thanks 

Gregory Allen

unread,
Jan 11, 2013, 5:06:44 PM1/11/13
to imusim...@googlegroups.com
I'm using the Quaternion class in IMUSim, and came across something that I found confusing.

x = array([1., 0., 0.1])
y = array([0., 1., 0.])
z = array([0., 0., 1.])
QuaternionFromVectors(x,y,z)

IndexError: invalid index -> imusim.maths.quaternions.Quaternion.setFromMatrix

It turns out that QuaternionFromVectors really wants column matrices, so I have to:
xc = atleast_2d(x).T
yc = atleast_2d(y).T
zc = atleast_2d(z).T
QuaternionFromVectors(xc,yc,zc)

The culprit is in QuaternionFromVectors, where it converts the vectors to a rotation matrix.

def MatrixFromVectors(x,y,z):
#m = np.hstack((x,y,z)).T # from QuaternionFromVectors, works only for column matrices
#m = np.vstack((x,y,z)) # works for vectors (or row matrices)
#m = np.vstack((x.flatten(),y.flatten(),z.flatten())) # works for either
m = np.vstack((x,y,z)).reshape(3,3) # also works for either
return m

The last two work for both vectors and column matrices. I'd suggest a change to make it work with vectors.

[as an aside, a QuaternionFromMatrix in the style of QuaternionFromVectors would be nice.]

Thanks,
-Greg

Gregory E. Allen, PhD, Engineering Scientist
Applied Research Laboratories: The University of Texas at Austin
512-835-3487

Gregory Allen

unread,
Jan 11, 2013, 5:56:35 PM1/11/13
to imusim...@googlegroups.com
IMUSim seems like a great tool. Thank you for the effort you've obviously put in to release it to the world. Every time I dig in there, I'm amazed at how much good stuff is down in there. But…

Is anyone actively thinking about IMUSim anymore, or have the interested parties moved on? Is IMUSim abandonware? Activity seems pretty low.

Twice now I've spent some time hacking on IMUSim and felt like others could benefit from changes I've made. Putting the source code in a public repo instead of a tarball could help quite a bit. I could make my proposed change in a fork, and send the maintainers a pull request. That's the way lots of interesting open source projects are now going. My personal favorite source site is Bitbucket (I like mercurial), but GitHub and GoogleCode are also widely used. You also get things like an issue tracker and a wiki.
[Here's a project near to my heart: https://bitbucket.org/gallen/cpn]

The biggest problem I had (and have seen on the list) is getting it installed (unless you use EPD). When people can't even install, they're unlikely to look any deeper.

Thoughts?

Roger Pissard-Gibollet

unread,
Jan 11, 2013, 7:07:23 PM1/11/13
to imusim...@googlegroups.com, Gregory Allen
Le 11/01/2013 23:56, Gregory Allen a �crit :
> IMUSim seems like a great tool. Thank you for the effort you've obviously put in to release it to the world. Every time I dig in there, I'm amazed at how much good stuff is down in there. But�
>
> Is anyone actively thinking about IMUSim anymore, or have the interested parties moved on? Is IMUSim abandonware? Activity seems pretty low.
>
> Twice now I've spent some time hacking on IMUSim and felt like others could benefit from changes I've made. Putting the source code in a public repo instead of a tarball could help quite a bit. I could make my proposed change in a fork, and send the maintainers a pull request. That's the way lots of interesting open source projects are now going. My personal favorite source site is Bitbucket (I like mercurial), but GitHub and GoogleCode are also widely used. You also get things like an issue tracker and a wiki.
> [Here's a project near to my heart: https://bitbucket.org/gallen/cpn]
>
> The biggest problem I had (and have seen on the list) is getting it installed (unless you use EPD). When people can't even install, they're unlikely to look any deeper.
>
> Thoughts?
>
> Thanks,
> -Greg
>
> Gregory E. Allen, PhD, Engineering Scientist
> Applied Research Laboratories: The University of Texas at Austin
> 512-835-3487
>
Hello Greg,

I agree with you that IMUSim is a great tool and I had also some
troubles to install it. Personnally I prefer GitHub. A lot of python
projects like matplotlib for example use GitHub.
I plan to use IMUSim to connect it with real IMU data (form HikoB node
see http://openlab.hikob.com/) and add some reconstruction algo.

Thank you for this initiative
Roger

Roger Pissard-Gibollet
Research Engineer
INRIA Grenoble

Martin Ling

unread,
Jan 11, 2013, 8:17:38 PM1/11/13
to imusim...@googlegroups.com
Hi Greg, Roger & others.

The story is that both Alex Young & I have moved on from the department
at Edinburgh where we worked together for several years. Alex has been
working at Xsens in the Netherlands since September 2011, and I left in
December 2011 to do freelance electronics & software development work.

I still use IMUSim for a number of projects and am keen to see it
continue, but the time I've been able to put into even just maintaining
it and answering queries on the list has been pretty limited over the
last year.

It's great that you're keen to contribute, and I agree that's been
awkward due to the lack of a public repository. We weren't able to
release the original git repository with the code since it contained
various pieces of unpublished/private research work, and the history
was rather entangled.

To solve that problem I've just imported version 0.2 into a new
repository and pushed it to GitHub. Let's use this from now on.

https://github.com/martinling/imusim

To anyone who's made changes to IMUSim that they're willing to release:
please fork this repository, add your changes and send me pull requests.

It would be nice if we could get a 0.3 release together that fixed known
bugs and addressed the installation difficulties. I have a few bits and
bobs that can go in.

Beyond that, I'd love to hear people's ideas for future development.


Martin

On Sat, Jan 12, 2013 at 01:07:23AM +0100, Roger Pissard-Gibollet wrote:
>
> Le 11/01/2013 23:56, Gregory Allen a écrit :
> >IMUSim seems like a great tool. Thank you for the effort you've obviously put in to release it to the world. Every time I dig in there, I'm amazed at how much good stuff is down in there. But…
> >
> >Is anyone actively thinking about IMUSim anymore, or have the interested parties moved on? Is IMUSim abandonware? Activity seems pretty low.
> >
> >Twice now I've spent some time hacking on IMUSim and felt like others could benefit from changes I've made. Putting the source code in a public repo instead of a tarball could help quite a bit. I could make my proposed change in a fork, and send the maintainers a pull request. That's the way lots of interesting open source projects are now going. My personal favorite source site is Bitbucket (I like mercurial), but GitHub and GoogleCode are also widely used. You also get things like an issue tracker and a wiki.
> >[Here's a project near to my heart: https://bitbucket.org/gallen/cpn]
> >
> >The biggest problem I had (and have seen on the list) is getting it installed (unless you use EPD). When people can't even install, they're unlikely to look any deeper.
> >
> >Thoughts?
> >
> >Thanks,
> >-Greg
> >
> >Gregory E. Allen, PhD, Engineering Scientist
> >Applied Research Laboratories: The University of Texas at Austin
> >512-835-3487
> >
> Hello Greg,
>
> I agree with you that IMUSim is a great tool and I had also some
> troubles to install it. Personnally I prefer GitHub. A lot of python
> projects like matplotlib for example use GitHub.
> I plan to use IMUSim to connect it with real IMU data (form HikoB
> node see http://openlab.hikob.com/) and add some reconstruction
> algo.
>
> Thank you for this initiative
> Roger
>
> Roger Pissard-Gibollet
> Research Engineer
> INRIA Grenoble
>
> --
> You received this message because you are subscribed to the Google Groups "IMUSim" group.
> To post to this group, send email to imusim...@googlegroups.com.
> To unsubscribe from this group, send email to imusim-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/imusim-users?hl=en.
>
>


Reply all
Reply to author
Forward
0 new messages