Skip to content

[BUG?] Locked module can rotate #8

@kazogihara

Description

@kazogihara

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions