Hello,
Your code is almost correct. Your control loop should not increment
the speed of the robot, unless you want the robot to accelerate at a
drastic rate. Also the units are in meters / second. So a value of 10
will be really really fast.
Try using this control loop:
while (true)
{
posIface->Lock(1);
posIface->data->cmdVelocity.pos.x = 0.2;
posIface->Unlock();
}
I tested this code using the pioneer2d.world file.
-nate
On Jan 17, 2008 7:10 PM, hemanth korrapati <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to impart some velocity/acceleration to a position
> interface. I am doing this with the following code.
> When I run using this code the robot moves slowly (not even 1m/s speed).
> I dont have any idea about this.Can anyone help me ?
>
> Also it would be better if some examples showing the usage of velocity
> , laser etc are included in the gazebo source.
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> #include <gazebo/gazebo.h>
> #include <gazebo/GazeboError.hh>
>
> int main()
> {
> gazebo::Client *client = new gazebo::Client();
> gazebo::SimulationIface *simIface = new gazebo::SimulationIface();
> gazebo::PositionIface *posIface = new gazebo::PositionIface();
>
> int serverId = 0;
>
> /// Connect to the libgazebo server
> try
> {
> client->ConnectWait(serverId, GZ_CLIENT_ID_USER_FIRST);
> }
> catch (gazebo::GazeboError e)
> {
> std::cout << "Gazebo error: Unable to connect\n" << e << "\n";
> return -1;
> }
>
> /// Open the Simulation Interface
> try
> {
> simIface->Open(client, "default");
> }
> catch (gazebo::GazeboError e)
> {
> std::cout << "Gazebo error: Unable to connect to the sim
> interface\n" << e << "\n";
> return -1;
> }
>
> /// Open the Position interface
> try
> {
> posIface->Open(client, "position_iface_0");
> }
> catch (gazebo::GazeboError e)
> {
> std::cout << "Gazebo error: Unable to connect to the position interface\n"
> << e << "\n";
> return -1;
> }
>
> posIface->Lock(1);
> posIface->data->cmdEnableMotors = 1;
> posIface->Unlock();
>
> while (true)
> {
> posIface->Lock(1);
> posIface->data->cmdVelocity.pos.x+=10;
> posIface->Unlock();
>
> posIface->Lock(1);
> std::cout << posIface->data->cmdVelocity.pos.x << " " <<
> posIface->data->cmdVelocity.pos.y << " " <<
> posIface->data->cmdVelocity.pos.z << std::endl;
> posIface->Unlock();
>
> usleep(100000);
> }
> return 0;
> }
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Thank You
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Playerstage-gazebo mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-gazebo mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo