Игрок / Сцена - робот не движется в симуляции? - PullRequest
0 голосов
/ 25 июля 2010

Я новичок в игроке / сцене.Но как-то мне удалось придумать приведенный ниже код, но он не двигается

Сначала файл конфигурации

driver
(
    name "stage"

    provides ["simulation:0"]
    plugin "stageplugin"

    #load the world file
    worldfile "robotWorld.world"
)

driver
(
    name "stage"
    provides [
                    "position2d:0"
                    "laser:0"
             ]
    model "robot"
)

Файл map.inc

define map model
(
    #color of the map
    color "black"

    #we need a boundary wall aroung the map, then only the robot can't go outside of     the map

    boundary 1

    gui_nose 1
    gui_grid 1
    gui_movemask 0
    gui_outline 0

    fiducial_reurn 0
    gripper_return 0
)

Робот.inc file

define robots_laser laser
(
    # minimum range of the laser
    range_min 0.0

    #maximum range of the laser
    range_max 2

    #field of view or pan angle of the camera
    #fov 180

    #assume the robot's size as 400*200, and  the camera is in the front end
    pose [200 100 0 0]

    #size of the camera
    size [0.025 0.025 0.001]
)

define robot position
(
    #size of the robot
    size [50 50 50]

    #as a default centre of rotation is the geometry centre

    #shape of the robot
    polygons 1

    polygon[0].points 4
    polygon[0].point[0] [0 0]
    polygon[0].point[1] [1 0]
    polygon[0].point[2] [1 1]
    polygon[0].point[3] [0 1]

    # car steering model
    drive "car"

    #mass of the robot
    mass 10.0

    robots_laser()  
)

Мировой файл

include "robot.inc"
include "map.inc"

#size of the simulation
size [15 15]

#interval_sim=5
#interval_real=10

#GUI window
window
(
    size [700 700]
    scale 2.5
    show_data 1
)

map
(
    bitmap "map2"
    size [300 300 3]
)

robot
(
    name "robot"
    pose [0 0 0 0]
    color "Green"
)

Это основной файл cpp (mainCode.cpp)

#include<iostream>
#include<unistd.h>
#include<time.h>
#include<player-3.0/libplayerc++/playerc++.h>

using namespace std;

int main(int argc,char * argv[])
{
    using namespace PlayerCc;
    cout << "111111111111" << endl ;
    PlayerClient robotClient("localhost",6665);

    Position2dProxy p2dProxy(&robotClient,0);
    LaserProxy laserProxy(&robotClient,0);

    p2dProxy.SetMotorEnable(true);

    p2dProxy.RequestGeom();

    robotClient.Read();

    while(true) 
    {
        robotClient.Read();
        p2dProxy.SetCarlike(240,0);
        cout << laserProxy[45] << endl ;
    }

    cout << "reached the end of the coding" << endl ;
}

Все хорошо, норобот не движется, поэтому в приведенном выше коде я получаю постоянное значение в качестве вывода.И в симуляторе робот не двигается.Кто-нибудь, пожалуйста, помогите мне?

1 Ответ

0 голосов
/ 16 апреля 2013

Внешний по отношению к вашему контроллеру, Player / Stage имеет резьбу. Тем не менее, ваш код должен управлять своими собственными ресурсами. Итак, вам нужно отказаться от времени выполнения, чтобы могли запускаться другие вещи (например, прокси, на которые вы подписаны).

Добавьте вызов сна в конце цикла while. Это позволит прокси обновлять данные (как на игрока, так и на сцену), чтобы вы получали новые данные датчика, а игрок получал новые команды скорости.

...