Skip to content

Commit

Permalink
Merge branch 'ros2' into daisukes/super-linter
Browse files Browse the repository at this point in the history
  • Loading branch information
daisukes authored Apr 17, 2024
2 parents 73c91a7 + dea3305 commit c84a503
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 15 additions & 10 deletions cabot_debug/src/print_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
parser.add_option("-s", "--start", type=float, help="start time from the begining", default=0.0)
parser.add_option("-d", "--duration", type=float, help="duration from the start time", default=99999999999999)
parser.add_option("-t", "--topic", type=str, action="append", default=[], help="topics to be printed")
parser.add_option("-p", "--plot", type=str, default="", help="plot data")
parser.add_option("-p", "--plot", type=str, action="append", default=[], help="plot data")
parser.add_option("-P", "--publish", action="store_true", help="publish topic")
parser.add_option("-i", "--info", action="store_true", help="print info")
parser.add_option("-1", "--once", action="store_true", help="print only one message")
Expand Down Expand Up @@ -134,8 +134,9 @@ def _getattr(obj, attr):
reader.set_filter_by_topics(options.topic)
reader.set_filter_by_options(options) # filter by start and duration

ts = []
ds = []
NUM_OF_DATA = 100
ts = tuple([[] for i in range(NUM_OF_DATA)])
ds = tuple([[] for i in range(NUM_OF_DATA)])
while reader.has_next():
try:
(topic, msg, t, st) = reader.serialize_next()
Expand Down Expand Up @@ -169,16 +170,20 @@ def _getattr(obj, attr):
break

if options.plot:
val = get_nested_attr(msg, options.plot)
if val is not None:
ts.append(st)
ds.append(val)
else:
logging.error(f"cannot get attribute {options.plot} in {msg}")
for index, plot in enumerate(options.plot):
val = get_nested_attr(msg, plot)
if val is not None:
ts[index].append(st)
ds[index].append(val)
else:
logging.error(f"cannot get attribute {options.plot} in {msg}")


if options.plot:
plt.plot(ts, ds)
plt.figure(figsize=(24, 18))
for index, plot in enumerate(options.plot):
plt.plot(ts[index], ds[index], label=plot)
plt.legend()
plt.show()

if options.publish:
Expand Down
4 changes: 4 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ ln -snf "$host_ros_log_dir" "$host_ros_log/latest"
blue "log dir is : $host_ros_log_dir"
mkdir -p "$host_ros_log_dir"
cp "$scriptdir/.env" "$host_ros_log_dir/env-file"
# save vcs log and diff for debugging
vcs log --nested --limit 1 > "$host_ros_log_dir/vcs-log.txt" &
vcs diff --nested > "$host_ros_log_dir/vcs-diff.txt" &


## if network interface name for Cyclone DDS is not specified, set autoselect as true
if [[ -n $CYCLONEDDS_URI ]]; then
Expand Down

0 comments on commit c84a503

Please sign in to comment.