Moving object in a defined environment

6 views (last 30 days)
Hello,
I'm new to MatLab and simulink and need some help getting started. How would I go about creating a 2d environment/room and putting in a simple shape such as a square, and moving that shape in the environment, in a straight line or from one point to another. How would this be done in simulink and how would this be done in matlab?
Kind regards Azim

Answers (1)

Cam Salzberger
Cam Salzberger on 9 Nov 2020
Edited: Cam Salzberger on 9 Nov 2020
That's not so much a question about "getting started" as it is about "doing a large project for me". Try breaking down the problem into individual questions and steps, answer the questions, and then look up the steps. For example, you may need to ask yourself:
  • Do I need a physics simulation, or am I just looking for a visualization tool?
  • If physics simulation, what level of simulation? Can I make assumptions like infinite acceleration and perfect collisions? Friction?
  • If physics simulation, what do I know about the moving object in the environment? Velocity? Desired velocity, but need to account for imperfect locomotion? Motor torques, and need to turn that into velocity?
  • If simple visualization, and all positions are known at all timesteps, then how do I want to display it? Movement in real-time ("animation")? A representation of the final path of the object? Both?
  • How am I choosing the path of the object in the environment? Randomly? Linearly? Do I need a tool to find a path between two points for me? Do I need to account for the kinematics of the object when making that path, or can I assume holonomic operation?
  • Does the orientation of the object matter?
Then you can look up various parts of the problem. For example, let's say you don't need a physics simulator, but you want to be able to select two points in a map and determine a path through freespace between them, then animate the object moving along that path in real-time. I would start with the most complex problem first
  • How to find path between two points in a map?
Which might lead you here. From that, you know you need an occupancy map for your environment, but it handles the path finding and shows an example with plotting that path too. Then you could just look up:
  • How to create occupancy map?
  • How to plot a square?
  • How to animate plot?
The last two will lead you to multiple different ways to visualize geometric shapes and show a plot changing in real-time.
Also, check out this guideline on asking good questions on MATLAB Answers for faster and more useful responses.
-Cam

Categories

Find more on Simulation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!