Hey Didac,

yes, I know this formulation but was wondering that if there is some 'in built' sleep utility, i.e if I say i want to move by 90 degrees , i just have to write positon->data->cmd_vel_rot = 1.6 ;

thanks a lot for replying..

cheers !!

Raman.

Didac Busquets <busquets@silver.udg.es> wrote:
Hi Raman,

You are right: "more the sleeping time, more the rotation".

The explanation is easy: your code (position->data->cmd_vel_rot[2] =
-1.6) sets the robot's rotation velocity to 1.6 radians per second
(although I see that you changed it to 1.2 rad/s in the last code you
sent). Thus, if you sleep for a second before stopping the rotation
(position->data->cmd_vel_rot[2]=0), the robot is gonna rotate
(approximately) 1.6 radians, which is about PI/4, which is 90 degrees.

If you remove the sleep command, the robot will have 0 seconds to rotate
(you set the rotational velocity, but right after that you set it to 0
rad/s again) , therefore it won't turn at all.

Likewise, if you sleep for a longer time, it will turn more (e.g. 2
seconds, ~180 degrees).

I hope it helps.

Didac

Raman Agarwal wrote:

> hi,
>
> Following is the code that I used. I also used example.world with this
> client program. commands of interest are line numbers 10 to 50. I
> commented out the z axis motion and things worked fine, but still i
> had to use sleep command, coz if I dont use it the bot wont turn.
>
> This leads to the following question. whether, the rotation is
> dependent on the sleep command or not (i.e more the sleeping time,
> more the rotation.)
>
> We know whats happening, but why is the question..
>
> Raman.
>
> --------------------------------------------------------------------------------------------------------------------
> #include
> #include
>
> void get_position (gz_client_t *client, gz_position_t *position);
>
> int main (int argc, char *argv[])
> {
> gz_client_t *client;
> gz_position_t *position;
> int server_id;
> int client_id;
>
> // Assume one server and one client
> server_id = 0;
> client_id = 0;
>
> // Print all errors
> gz_error_init(1, 9);
>
> // Create a client object
> client = gz_client_alloc();
>
> // Connect to the server
> if (gz_client_connect_wait(client, server_id, client_id) != 0)
> return -1;
>
> // Create a position interface
> position = gz_position_alloc();
>
> // Connect to device on server
> if (gz_position_open(position, client, "robot1") != 0)
> return -1;
>
> /*
> ---------------------------------------------------
> leave program code unchanged till here...
> ---------------------------------------------------
> */
>
> // enable motors
> position->data->cmd_enable_motors = 1;
>
> // change direction of the bot
> 10> position->data->cmd_vel_rot[2] = -1.2; // ~90° clockwise
> 20> // position->data->cmd_vel_pos[2] = 0.12; // switch on motor for
> z-axis
> 30> sleep(1); // wait for 1ms
> 40> position->data->cmd_vel_rot[2] = 0; // fix this angle/pose
> 50> // position->data->cmd_vel_pos[2] = 0; // switch off motor for z-axis
>
> // move forward in new direction
> position->data->cmd_vel_pos[0] = 0.52; // switch on motor for x-axis
>
> // get and print position. the position variable
> // has current odometric position
> get_position(client, position);
>
> // disable motors
> position->data->cmd_enable_motors = 0;
>
> // Close the interface and free object
> gz_position_close(position);
> gz_position_free(position);
>
> // Close the connection and free the client object
> gz_client_disconnect(client);
> gz_client_free(client);
>
> return 0;
> }
>
>
> // Read some data
> void get_position (gz_client_t *client, gz_position_t *position)
> {
> // Wait for new data
> gz_client_wait(client);
>
> // Lock it
> gz_position_lock(position, 1);
>
> // Print it
> printf("%0.3f %0.3f\n", position->data->pos[0], position->data->pos[1]);
>
> // Unlock it
> gz_position_unlock(position);
>
> }
> --------------------------------------------------------------------------------------------------------------------
>
> */Jordi /* wrote:
>
> Sunday 28 May 2006 15:26、Raman Agarwal さんは書きました:
> > hi,
> >
> > yeah i realized that mails arent formatted.. i have included
> line numbers
> > to the program snippet for reference.
> >
> ---------------------------------------------------------------------------
> >-------------------------------------- 10> // enable motors
> > 15> position->data->cmd_enable_motors = 1;
> >
> > 20> // change direction of the bot
> > 25> position->data->cmd_vel_rot[2] = -1.6; // for ~90° clockwise
> > 30> position->data->cmd_vel_pos[2] = 0.12; // switch on motor
> for z-axis
> > 35> sleep(1); // wait for 1ms
> > 40> position->data->cmd_vel_rot[2] = 0; // fix this angle/pose
> > 45> position->data->cmd_vel_pos[2] = 0; // switch off motor for
> z-axis
> >
> > 50> // move forward in new direction
> > 55> position->data->cmd_vel_pos[0] = 1.52; // switch on motor
> for x-axis
> >
> >
> ---------------------------------------------------------------------------
> >--------------------------------------
> >
> > Q1 : is there a neater approach to turn the robot. ideally
> speaking, the
> > commands (30 to 45) shouldnt be used, but commenting them out
> ddnt move
> > anything :(
> >
> lines 30 and 45 are not used for sure, if you comment them out it
> should be
> working. If not, attach your entire program to the next email
>
>
> --
> Jordi Polo
>
>
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost and
> Risk!
> Fully trained technicians. The highest number of Red Hat
> certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
> _______________________________________________
> Playerstage-gazebo mailing list
> Playerstage-gazebo@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo
>
>
> ------------------------------------------------------------------------
> Ring'em or ping'em. Make PC-to-phone calls as low as 1�/min
>
> with Yahoo! Messenger with Voice.


--
Didac Busquets i Font

Dept. d'Electronica, Informatica i Automatica
Institut d'Inform� tica i Aplicacions
Edifici P-IV
Despatx 128
Universitat de Girona
Campus Montilivi
17071-Girona

Tel. (+34) 972.41.81.79
Fax. (+34) 972.41.80.98



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
Playerstage-gazebo mailing list
Playerstage-gazebo@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo



Contact:

Address
: am Haehnchen
Haus 8
53229
Bonn, Germany

Phone : +49 - (0)621 - 4057523

Handy : +49 - (0)177 - 6370708

Website : www.geocities.com/raman_agarwal82


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2/min with Yahoo! Messenger with Voice.