Running multiple quadricopters simultaneously with a path

Typically: "How do I... ", "How can I... " questions
Post Reply
DawoodRauf
Posts: 3
Joined: 21 Feb 2023, 16:48

Running multiple quadricopters simultaneously with a path

Post by DawoodRauf »

Hey coppelia,

I'm working on a project that involves with quadricopters and I'm having trouble running multiple quadricopters simultaneously with a path. One of the quadricopter follows the path, but the other one doesn’t. I need help to make it so that multiple quadricopters move along the path simultaneously when the simulation is running. Here I have provided a screenshot and the scripts for each quadricopter to follow a path.

The quadricopter #0 on the left doesn't move because it says:
3: Object does not exist. (in function 'sim.getObjectHandle')
stack traceback:
[C]: in function 'getObjectHandle'
[string "Quadricopter_target#0@childScript"]:3: in function <[string "Quadricopter_target#0@childScript"]:1>

The quadricpoter in the middle does move with a path.

The screenshot of the quadricopters is here: https://ibb.co/XxFMdny

Script for Quadricopter_target (middle, moves along the path)

Code: Select all

function sysCall_threadmain()
    target=sim.getObjectAssociatedWithScript(sim.handle_self)
    path=sim.getObjectHandle("Path")
    sim.followPath(target,path,1,0,0.3,15)
end

function sysCall_cleanup()
    -- Put some clean-up code here
end

-- See the user manual or the available code snippets for additional callback functions and details

Script for Quadricopter_target#0 (left, doesn’t move along the path due to sim.getObjectHandle)

Code: Select all

function sysCall_threadmain()
    target=sim.getObjectAssociatedWithScript(sim.handle_self)
    path=sim.getObjectHandle("Path0")
    sim.followPath(target,path,2,0,0.3,15)
end

function sysCall_cleanup()
    -- Put some clean-up code here
end

-- See the user manual or the available code snippets for additional callback functions and details

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Running multiple quadricopters simultaneously with a path

Post by coppelia »

Hello,

it appears you are running a quite old version of CoppeliaSim. What version is it?
We highly recommend using an up-to-date version, (currently V4.4, very soon V4.5).
Starting with V4.1 or V4.2, objects are accessed via sim.getObject and a path. This makes things more flexible and scalable.

In current version, have a look at the demo scene scenes/movingAlongAPath.ttt, when many objects are moving along a same path in different ways.

Cheers

DawoodRauf
Posts: 3
Joined: 21 Feb 2023, 16:48

Re: Running multiple quadricopters simultaneously with a path

Post by DawoodRauf »

Hi,

I am running CoppeliaSim Edu 4.1.0 version. I have looked at the code for the movingAlongAPath file and copied it to the quadricopter scripts, but in my case I couldn't replicate what movingAlongAPath.ttt used and I'm still having the same problem. Both of the quadricopters scripts "quadricopter_target" and "quadricopter_target#0" are child scripts and I'm still not able to make both quadricopters with different paths move along at the same time. I'm new in using CoppeliaSim and would like to get help fixing this issuse?

Thanks.

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Running multiple quadricopters simultaneously with a path

Post by coppelia »

Did you update to a newer version of CoppeliaSim? If yes, which one?

As of today, within a few hours, you will be able to download CoppeliaSim V4.5. I highly recommend staying up-to-date with current CoppeliaSim version.

Cheers

DawoodRauf
Posts: 3
Joined: 21 Feb 2023, 16:48

Re: Running multiple quadricopters simultaneously with a path

Post by DawoodRauf »

Yes, I have updated to the latest version of CoppeliaSim 4.5.1. I started with a new project but with the same scenario which is multiple quadricopters follow along with different paths that I had before. I have put 2 quadripcopters side by side but now both of them wouldn't move. Can you give me a sample code that could be helpful for me to get started to run both quadricopters follow with different paths at the same time? I tried to replicate the movingAlongAPath file, but I couldn't get it to work.

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Running multiple quadricopters simultaneously with a path

Post by coppelia »

When you say you couldn't get it to work, what happened? Any error message? What did you try?

Just open the movingAlongAPath.ttt demo scene. Then drag the model Quadcopter.ttm into the scene. Attach a child script to object Quadcopter/target. And paste the exact same content as the script of the red cube for instance: your quadcopter will then follow the path.

Cheers

Post Reply