Giter Site home page Giter Site logo

programmablematterproject / visiblesim Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 5.0 123.67 MB

VisibleSim is a simulator of networked modular robots.

Home Page: https://www.programmable-matter.com/simulation

License: Other

CMake 0.56% Makefile 1.28% Shell 0.05% Python 0.20% C++ 84.58% C 1.30% GLSL 0.04% Common Lisp 11.99%
modular research-tool robotics simulator visiblesim

visiblesim's People

Contributors

chpawel avatar docben avatar egartner avatar jlengiew avatar julien-bourgeois avatar madeleinebecker4 avatar nazandre avatar pescher-florian avatar pthalamy avatar strublar avatar thadeuk avatar vconnat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

visiblesim's Issues

[BUG] Illegal module insertion occurred

Issue description

Hi!
I found a bug at module insertion function in context menu.
Module can be inserted even if clicking non connector portion.

Context (Environment)

What's the expected result?

  • Can not insert block when click non connector portion

What's the actual result?

  • Can insert block when click non connector portion

Steps to reproduce the issue

Note: This may not be happen depending on memory state.
Video:
https://www.youtube.com/watch?v=l8awqUfgwUA&ab_channel=TEMMIEHOIHOI

config.xml

<?xml version="1.0" standalone="no" ?>
<world gridSize="5,5,5">
    <blockList blockSize="10,10,10">
        <block position="1,1,1" color="255,140,0" orientation="3" />
    </blockList>
</world>

Possible Solution

Set a value({0, 0, 0}) when clicking non connector portion to tabConnectorPositions.

In my view, the reason is that tabConnectorPositions doesn't have argument corresponding to non-connector spot.
This caused a buffer overrun, which resulted in an incorrect value for realPos.
Following is log of that time.

Thread 1 "myMotionTest" hit Breakpoint 1, Catoms3D::Catoms3DBlock::getNeighborPos (this=0xe15c8980, connectorID=56 '8', pos=...) at robots/catoms3D/catoms3DBlock.cpp:160
160         bool Catoms3DBlock::getNeighborPos(uint8_t connectorID, Cell3DPosition &pos) const {
(gdb) n
161             Vector3D realPos;
(gdb) n
163             Catoms3DWorld *wrl = getWorld();
(gdb) n
164             const Vector3D bs = wrl->lattice->gridScale;
(gdb) n
166             realPos.set(tabConnectorPositions[connectorID], 3, 1);
(gdb) p bs
$4 = {_pt = {10, 10, 10, 0}}
(gdb) n
167             realPos *= bs;
(gdb) p realPos
$5 = {_pt = {0.000748447317, 7.13885687e+31, 5.66773757e-08, 1}}
(gdb) n
168             realPos.set(3,1.0); // A vérifier
(gdb) p realPos
$6 = {_pt = {0.00748447329, 7.13885668e+32, 5.66773735e-07, 0}}
(gdb) n
169             realPos = ((Catoms3DGlBlock *) ptrGlBlock)->mat * realPos;
(gdb) p realPos
$7 = {_pt = {0.00748447329, 7.13885668e+32, 5.66773735e-07, 1}}
(gdb) n
170             if (realPos[2] < 0) return false;
(gdb) p realPos
$8 = {_pt = {3.56942795e+32, 3.56942795e+32, -5.04793378e+32, 1}}

[Feature Request] Simulation Execution Control

When running the simulation it would be great to have some control over the mechanics of the execution. Specifically, I am referring to two items here: playback speed, and the ability to reset. In terms of playback speed it would be nice to have some variability here to better visualize what is happening in the simulation. I suppose you could capture and export a video and then watch it with the desired speed there, but that seems like an unnecessary step. The ability to reset would just be a feature allowing the user to reset the simulation from the GUI. Currently, one has to close the program and restart to achieve this.

Great software! I just wanted to offer a few suggestions based on what I would have liked to be able to do while running a simulation.

[BUG?] Locked module can rotate

Hi!
I found locked module can rotate. This seems to be bug, so could you check it?

#include "myMotionTestCode.hpp"

MyMotionTestCode::MyMotionTestCode(Catoms3DBlock *host) : Catoms3DBlockCode(host), module(host)
{
    // @warning Do not remove block below, as a blockcode with a NULL host might be created
    //  for command line parsing
    if (not host)
        return;
}

void MyMotionTestCode::startup()
{
    console << "start " << module->blockId << "\n";
    if (module->blockId == 11)
    { // Master id is 1
        module->setColor(RED);
        Cell3DPosition target_pos = module->position + Cell3DPosition(1, 1, 1);
        module->moveTo(target_pos);
        // console << "canMoveto " << target_pos << " from " << module->position << " is "<< module->canMoveTo(target_pos) << "\n";
    }
}

  • myMotionTestCode.h
#ifndef myMotionTestCode_H_
#define myMotionTestCode_H_

#include "robots/catoms3D/catoms3DSimulator.h"
#include "robots/catoms3D/catoms3DWorld.h"
#include "robots/catoms3D/catoms3DBlockCode.h"


using namespace Catoms3D;

class MyMotionTestCode : public Catoms3DBlockCode {
private:
	Catoms3DBlock *module = nullptr;
public :
	MyMotionTestCode(Catoms3DBlock *host);
	~MyMotionTestCode() {};
  Cell3DPosition targetPos;
/**
  * This function is called on startup of the blockCode, it can be used to perform initial
  *  configuration of the host or this instance of the program.
  * @note this can be thought of as the main function of the module
  */
    void startup() override;

/*****************************************************************************/
/** needed to associate code to module                                      **/
	static BlockCode *buildNewBlockCode(BuildingBlock *host) {
	    return(new MyMotionTestCode((Catoms3DBlock*)host));
	}
/*****************************************************************************/
};

#endif /* myMotionTestCode_H_ */
  • config.xml
<?xml version="1.0" standalone="no" ?>
<world gridSize="26,26,26" visual="1024,800">
    <camera target="54.5554,56.3875,22.0596" directionSpherical="-2561.64,33.8501,220" angle="45.000000" near="0.100000" far="2000.000000" />
    <spotlight target="0,0,0" directionSpherical="135,80,800" angle="43.152390" />
    <blockList blockSize="10,10,10">
        <block position="5,5,0" color="255,140,0" orientation="0" />
        <block position="5,6,0" color="255,140,0" orientation="0" />
        <block position="6,6,0" color="255,140,0" orientation="0" />
        <block position="6,5,0" color="255,140,0" orientation="0" />
        <block position="6,5,1" color="255,140,0" orientation="0" />
        <block position="6,4,1" color="255,140,0" orientation="0" />
        <block position="6,6,1" color="255,140,0" orientation="0" />
        <block position="5,6,1" color="255,140,0" orientation="0" />
        <block position="4,6,1" color="255,140,0" orientation="0" />
        <block position="4,5,1" color="255,140,0" orientation="0" />
        <block position="5,5,1" color="255,140,0" orientation="0" />
    </blockList>
</world>

[BUG?] This motion is allowed?

Hi!
I found module motion that seems to be not allowed.
Could you check it?

#include "myMotionTestCode.hpp"

MyMotionTestCode::MyMotionTestCode(Catoms3DBlock *host) : Catoms3DBlockCode(host), module(host)
{
    // @warning Do not remove block below, as a blockcode with a NULL host might be created
    //  for command line parsing
    if (not host)
        return;
}

void MyMotionTestCode::startup()
{
    console << "start " << module->blockId << "\n";
    if (module->blockId == 2)
    {
        module->setColor(RED);
        Cell3DPosition target_pos = module->position + Cell3DPosition(1, 1, -1);
        module->moveTo(target_pos);
    }else if(module->blockId == 3){
        module->setColor(RED);
        Cell3DPosition target_pos = module->position + Cell3DPosition(0, 1, -1);
        module->moveTo(target_pos);        
    }
}
  • myMotionTestCode.hpp
#ifndef myMotionTestCode_H_
#define myMotionTestCode_H_

#include "robots/catoms3D/catoms3DSimulator.h"
#include "robots/catoms3D/catoms3DWorld.h"
#include "robots/catoms3D/catoms3DBlockCode.h"
#include "robots/catoms3D/catoms3DMotionEngine.h" 
#include "robots/catoms3D/catoms3DRotationEvents.h"

using namespace Catoms3D;

class MyMotionTestCode : public Catoms3DBlockCode {
private:
	Catoms3DBlock *module = nullptr;
public :
	MyMotionTestCode(Catoms3DBlock *host);
	~MyMotionTestCode() {};
  Cell3DPosition targetPos;
/**
  * This function is called on startup of the blockCode, it can be used to perform initial
  *  configuration of the host or this instance of the program.
  * @note this can be thought of as the main function of the module
  */
    void startup() override;

/*****************************************************************************/
/** needed to associate code to module                                      **/
	static BlockCode *buildNewBlockCode(BuildingBlock *host) {
	    return(new MyMotionTestCode((Catoms3DBlock*)host));
	}
/*****************************************************************************/
};

#endif /* myMotionTestCode_H_ */
  • myMotionTest.cpp
#include <iostream>
#include "myMotionTestCode.hpp"

using namespace std;
using namespace Catoms3D;

int main(int argc, char **argv) {
    try {
        createSimulator(argc, argv, MyMotionTestCode::buildNewBlockCode);
        getSimulator()->printInfo();
        BaseSimulator::getWorld()->printInfo();
        deleteSimulator();
    } catch(std::exception const& e) {
        cerr << "Uncaught exception: " << e.what();
    }

    return 0;
}

config.xml

<?xml version="1.0" standalone="no" ?>
<world gridSize="26,26,26" visual="1024,800">
    <camera target="54.5554,56.3875,22.0596" directionSpherical="-2561.64,33.8501,220" angle="45.000000" near="0.100000" far="2000.000000" />
    <spotlight target="0,0,0" directionSpherical="135,80,800" angle="43.152390" />
    <blockList blockSize="10,10,10">
        <block position="5,5,0" color="255,140,0" orientation="0" />
        <block position="5,4,1" color="255,140,0" orientation="0" />
        <block position="7,4,1" color="255,140,0" orientation="0" />
        <block position="8,5,0" color="255,140,0" orientation="0" />
    </blockList>
</world>

[BUG?]Is this a motion constraint violation?

Hi!
I found a behavior that seems to be a violation of the motion constraint.
A motion like "Figure 1: 3D Catom rotation and motion constraints." seems to be forbidden but can do on VisibleSim.
Is this a bug?
https://projects.femto-st.fr/programmable-matter/massively-parallel-self-reconfiguration

Motion Video
https://www.youtube.com/watch?v=Bv87lHdS770&ab_channel=TEMMIEHOIHOI

  • myMotionTest.cpp
#include <iostream>
#include "myMotionTestCode.hpp"

using namespace std;
using namespace Catoms3D;

int main(int argc, char **argv) {
    try {
        createSimulator(argc, argv, MyMotionTestCode::buildNewBlockCode);
        getSimulator()->printInfo();
        BaseSimulator::getWorld()->printInfo();
        deleteSimulator();
    } catch(std::exception const& e) {
        cerr << "Uncaught exception: " << e.what();
    }

    return 0;
}
  • myMotionTestCode.h
#ifndef myMotionTestCode_H_
#define myMotionTestCode_H_

#include "robots/catoms3D/catoms3DSimulator.h"
#include "robots/catoms3D/catoms3DWorld.h"
#include "robots/catoms3D/catoms3DBlockCode.h"


using namespace Catoms3D;

class MyMotionTestCode : public Catoms3DBlockCode {
private:
	Catoms3DBlock *module = nullptr;
public :
	MyMotionTestCode(Catoms3DBlock *host);
	~MyMotionTestCode() {};
  Cell3DPosition targetPos;
/**
  * This function is called on startup of the blockCode, it can be used to perform initial
  *  configuration of the host or this instance of the program.
  * @note this can be thought of as the main function of the module
  */
    void startup() override;

/**
  * @brief Provides the user with a pointer to the configuration file parser, which can be used to read additional user information from each block config. Has to be overridden in the child class.
  * @param config : pointer to the TiXmlElement representing the block configuration file, all information related to concerned block have already been parsed
  *
  */
    void parseUserBlockElements(TiXmlElement *config) override;

/**
  * @brief Callback function executed whenever the module finishes a motion
  */
    void onMotionEnd() override;

/*****************************************************************************/
/** needed to associate code to module                                      **/
	static BlockCode *buildNewBlockCode(BuildingBlock *host) {
	    return(new MyMotionTestCode((Catoms3DBlock*)host));
	}
/*****************************************************************************/
};

#endif /* myMotionTestCode_H_ */
  • myMotionTestCode.cpp
#include "myMotionTestCode.hpp"

MyMotionTestCode::MyMotionTestCode(Catoms3DBlock *host) : Catoms3DBlockCode(host), module(host)
{
    // @warning Do not remove block below, as a blockcode with a NULL host might be created
    //  for command line parsing
    if (not host)
        return;
}

void MyMotionTestCode::startup()
{
    console << "start " << module->blockId << "\n";
    if (module->blockId == 11)
    { // Master id is 1
        module->setColor(RED);
        Cell3DPosition target_pos = module->position + Cell3DPosition(-1, -1, -1);
        module->moveTo(target_pos);
    }
}

void MyMotionTestCode::parseUserBlockElements(TiXmlElement *config)
{
    const char *attr = config->Attribute("leader");
    if (attr != nullptr)
    {
        std::cout << module->blockId << " is leader!" << std::endl; // complete with your code
    }
}

void MyMotionTestCode::onMotionEnd()
{
    // complete with your code
    console << " End of motion to " << module->position << "\n";
}

  • config.xml
<?xml version="1.0" standalone="no" ?>
<world gridSize="30,30,30" windowSize="1024,800">
    <camera target="70.3487,55.9268,21.9671" directionSpherical="-2522.68,37.2878,120" angle="45.000000" near="0.100000" far="2000.000000" />
    <spotlight target="0,0,0" directionSpherical="135,80,800" angle="51.340192" />
    <blockList blockSize="10,10,10">
        <block position="5,5,0" color="255,140,0" orientation="0" />
        <block position="5,6,0" color="255,140,0" orientation="0" />
        <block position="6,6,0" color="255,140,0" orientation="0" />
        <block position="6,5,0" color="255,140,0" orientation="0" />
        <block position="6,5,1" color="255,140,0" orientation="0" />
        <block position="6,4,1" color="255,140,0" orientation="0" />
        <block position="6,6,1" color="255,140,0" orientation="0" />
        <block position="5,6,1" color="255,140,0" orientation="0" />
        <block position="4,6,1" color="255,140,0" orientation="0" />
        <block position="4,5,1" color="255,140,0" orientation="0" />
        <block position="6,6,2" color="255,140,0" orientation="0" />
    </blockList>
</world>

[BUG] Trying to insert a block on non-empty cell from Contextual Menu

Hi!
When I tried to insert a block using the context menu, I was confronted with the error message Trying to insert a block on non-empty cell. The process is,

  1. Click a block with ctrl + right click
    無題
    無題1

  2. Select another block with ctrl + left click
    無題2

  3. Select orient. If selected block has a block on the direction, the error occur.
    無題4

Uncaught exception: Trying to insert a block on non-empty cell at (15,15,15)

I think the menu should be closed once another block is selected, so that this bug will be fixed.

[BUG] A module on the edge of wall is sink

Hi!
I found a module on the edge of wall is sink in.
This will occur only on the wall in the photo where the module is sink in.
Just an apparent issue, but odd, so could you check it?
image

  • config.xml
<?xml version="1.0" standalone="no" ?>
<world gridSize="10,10,10" windowSize="1848,1016">
    <camera target="54.5554,56.3875,22.0596" directionSpherical="-2561.64,33.8501,220" angle="45.000000" near="0.100000" far="2000.000000" />
    <spotlight target="0,0,0" directionSpherical="135,80,800" angle="51" />
    <blockList blockSize="10,10,10">
        <block position="9,5,1" color="255,140,0" orientation="0" />
        <block position="9,4,1" color="255,140,0" orientation="0" />
        <block position="0,9,1" color="255,140,0" orientation="0" />
        <block position="1,9,1" color="255,140,0" orientation="0" />
        <block position="1,5,9" color="255,140,0" orientation="0" />
        <block position="1,4,9" color="255,140,0" orientation="0" />
    </blockList>
</world>

[Question] Can I build online VisibleSim?

Hi!
The online VisibleSim site now seems to be unavailable due to DB issue.
So I want to build VisibleSim online site.
If I can, could you give me web application source code?

  • DB issue
    image

[BUG]Deprecated tag is generated at config exporter

Hi!
I found deprecated config tag is generated at config generator in context menu.
I think this needs to be fixed, could you please check it?

  • generated config example
<?xml version="1.0" standalone="no" ?>
<world gridSize="5,5,6" windowSize="1280,720">
    <camera target="25,20,10" directionSpherical="0,30,100" angle="30.000000" near="1.000000" far="300.000000" />
    <spotlight target="25,25,0" directionSpherical="-35,40,150" angle="45.000000" />
    <blockList blockSize="10,10,10">
        <block position="0,0,0" color="128,128,64" orientation="0" />
        <block position="1,0,0" color="128,128,64" orientation="0" />
    </blockList>
</world>
  • deprecated tag
    • windowSize
    • angle
    • directionSpherical

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.