# Cookbook

## How to set up timer for periodic tasks?

`rclcpp:rclcpp::Node` class has a method called `create_wall_timer`, which can be used to create period signal. The following two c++ functions are usually used with the `create_wall_timer` method.

* [std::bind](https://en.cppreference.com/w/cpp/utility/functional/bind)
* [std::placeholders::\_1](https://en.cppreference.com/w/cpp/utility/functional/placeholders)

## How to get the current time?

If we are inside a node, we can use the following code to get the current time.

```
this->get_clock()->now()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnros2.com/ros/cookbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
