Time Service Class Experience

Hi,

I would like to know if orocos provide an easy way to convert from string to ticks.

the current architecture of my code working like:

First: Grab Image from Camera, Get Ticks of the grabbing process, then save the image and name it by the ticks value.

After That: (Offline Process [Testing, Visualization]) Read Images from disk, and use the name as time stamp [Here we need to convert from string to ticks].

Why I do that? Later I will develop another components which will do process in the same time stamp of the image.

Please let me know if there is any simple solution, and ask me if you need more details for my project.

Thanks AbdAlrahman

Time Service Class Experience

On Thu, May 7, 2015 at 10:44 AM, <alaaeldeen [dot] abdalrahman [..] ....j

wrote:

> Thank you for your grate reply, but for now I did it like that:
>
> stringstream sStrTime("Time Stamp: Tick As String");
> long long val;
> sStrTime >> val;
>

That is a valid solution as well, but with certain caveats.

Firstly, data sizes. 'long' is at least 32bits wide, while 'long long' is
at least 64bits wide. Because these are lower bounds, the size can change
depending on the data model, e.g., 'long' can be 32bits or 64bits (LP32 vs
LP64) .

Secondly, C++98 defines the std::istream::operator >> for 'long', but not
for 'long long'. The latter was introduced in C++11 [1].

So, the problem is potential precision loss. If you're using C++98, and in
you're data model 'long' is 32bits wide, and 'long long' is 64bits wide,
you're subject to loose precision in the conversion, as >> will convert the
input stream to a 'long', which will then be implicity converted to 'long
long'.

At least this is my understanding of it. I haven't actually tested it.

[1] http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/

>
> What do you think? Should I do it using stoll() or that is Ok?
> I will try it but if you know which is better please let me know :)
>
> Thanks
> AbdAlrahman
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Time Service Class Experience

Thank you, I guess you're right. I will try both a long all the project and
if you want I will update you withe the results.

Thanks
AbdAlrahman
On May 7, 2015 6:27 PM, "Adolfo Rodríguez Tsouroukdissian" <
adolfo [dot] rodriguez [..] ...> wrote:

>
>
> On Thu, May 7, 2015 at 10:44 AM, <alaaeldeen [dot] abdalrahman [..] ....j

wrote:
>
>> Thank you for your grate reply, but for now I did it like that:
>>
>> stringstream sStrTime("Time Stamp: Tick As String");
>> long long val;
>> sStrTime >> val;
>>
>
> That is a valid solution as well, but with certain caveats.
>
> Firstly, data sizes. 'long' is at least 32bits wide, while 'long long' is
> at least 64bits wide. Because these are lower bounds, the size can change
> depending on the data model, e.g., 'long' can be 32bits or 64bits (LP32 vs
> LP64) .
>
> Secondly, C++98 defines the std::istream::operator >> for 'long', but not
> for 'long long'. The latter was introduced in C++11 [1].
>
> So, the problem is potential precision loss. If you're using C++98, and in
> you're data model 'long' is 32bits wide, and 'long long' is 64bits wide,
> you're subject to loose precision in the conversion, as >> will convert the
> input stream to a 'long', which will then be implicity converted to 'long
> long'.
>
> At least this is my understanding of it. I haven't actually tested it.
>
>
> [1] http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
>
>>
>> What do you think? Should I do it using stoll() or that is Ok?
>> I will try it but if you know which is better please let me know :)
>>
>> Thanks
>> AbdAlrahman
>> --
>> Orocos-Users mailing list
>> Orocos-Users [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>
>
>
> --
> Adolfo Rodríguez Tsouroukdissian
> Senior robotics engineer
> adolfo [dot] rodriguez [..] ...
> http://www.pal-robotics.com
>
> PAL ROBOTICS S.L
> c/ Pujades 77-79, 4º4ª
> 08005 Barcelona, Spain.
> Tel. +34.93.414.53.47
> Fax.+34.93.209.11.09
> Skype: adolfo.pal-robotics
> Facebook <http://www.facebook.com/palrobotics1> - Twitter
> <http://twitter.com/#%21/palrobotics> - PAL Robotics YouTube Channel
> <http://www.youtube.com/user/PALRobotics>
>
> AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden
> contener información privilegiada y/o confidencial que está dirigida
> exclusivamente a su destinatario. Si usted recibe este mensaje y no es el
> destinatario indicado, o el empleado encargado de su entrega a dicha
> persona, por favor, notifíquelo inmediatamente y remita el mensaje original
> a la dirección de correo electrónico indicada. Cualquier copia, uso o
> distribución no autorizados de esta comunicación queda estrictamente
> prohibida.
>
> CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may
> contain confidential information which is privileged and intended only for
> the individual or entity to whom they are addressed. If you are not the
> intended recipient, you are hereby notified that any disclosure, copying,
> distribution or use of this e-mail and/or accompanying document(s) is
> strictly prohibited. If you have received this e-mail in error, please
> immediately notify the sender at the above e-mail address.
>

Time Service Class Experience

On Thu, May 7, 2015 at 9:14 AM, <alaaeldeen [dot] abdalrahman [..] ....j

wrote:

> Hi,
>
> I would like to know if orocos provide an easy way to convert from string
> to
> ticks.
>

'RTT::os::TimeService::ticks' is nothing but a typedef to 'long long', so
you need to perform a string to long long conversion. You don't need Orocos
for that. Here are three possible alternatives:

1. Using C99: strtoll [1]

2. Using C++11: stoll (for std::string) [1] or atoll (for char*) [2]

3. Using Boost: boost::lexical_cast<long long>(str)

[1] http://linux.die.net/man/3/strtoll
[2] http://www.cplusplus.com/reference/string/stoll/
[3] http://www.cplusplus.com/reference/cstdlib/atoll/

Best,

Adolfo.

> the current architecture of my code working like:
>
> First:
> Grab Image from Camera, Get Ticks of the grabbing process, then save the
> image and name it by the ticks value.
>
> After That: (Offline Process [Testing, Visualization])
> Read Images from disk, and use the name as time stamp [Here we need to
> convert from string to ticks].
>
> Why I do that?
> Later I will develop another components which will do process in the same
> time stamp of the image.
>
> Please let me know if there is any simple solution, and ask me if you need
> more details for my project.
>
> Thanks
> AbdAlrahman
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Time Service Class Experience

Thank you for your grate reply, but for now I did it like that:

stringstream sStrTime("Time Stamp: Tick As String"); long long val; sStrTime >> val;

What do you think? Should I do it using stoll() or that is Ok? I will try it but if you know which is better please let me know :)

Thanks AbdAlrahman