Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
p4robotics-templates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hsanghyu
p4robotics-templates
Commits
42457fca
There was an error fetching the commit references. Please try again later.
Commit
42457fca
authored
3 years ago
by
shong7
Browse files
Options
Downloads
Patches
Plain Diff
class18: template updated
parent
cad66142
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
class18/message.c
+42
-0
42 additions, 0 deletions
class18/message.c
with
42 additions
and
0 deletions
class18/message.c
+
42
−
0
View file @
42457fca
#define _GNU_SOURCE
#include
<time.h>
double
seconds_now
(
void
)
{
struct
timespec
now
;
if
(
clock_gettime
(
CLOCK_MONOTONIC
,
&
now
))
{
fprintf
(
stderr
,
"Retrieving system time failed.
\n
"
);
exit
(
1
);
}
return
now
.
tv_sec
+
now
.
tv_nsec
/
1000000000
.
0
;
}
void
on_l2g
(
const
lcm_recv_buf_t
*
rbuf
,
const
char
*
channel
,
const
l2g_t
*
msg
,
void
*
userdata
)
{
printf
(
"l2g: %.2f %.2f %.2f
\n
"
,
,
,
);
}
int
main
(
void
)
{
lcm_t
*
lcm
=
lcm_create
(
NULL
);
l2g_t_subscription_t
*
l2g_sub
=
l2g_t_subscribe
(
lcm
,
,
,
NULL
);
l2g_t
l2g
=
{
.
utime
=
0
,
.
l2g
=
{
1
.
0
,
2
.
0
,
3
.
0
}};
l2g_t_publish
(
lcm
,
,
);
double
start
=
seconds_now
();
while
(
seconds_now
()
-
start
<
0
.
5
)
{
lcm_handle_timeout
(
lcm
,
100
);
}
l2g_t_unsubscribe
(
,
);
lcm_destroy
(
lcm
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment