# ROS2 in 5 Days C++ ERROR in Unit 5

**URL:** <https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274>\
**Category:** ROS2 in 5 Days C++\
**Created:** [May 13, 2022, 7:55am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274 "2022-05-13T07:55:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman.smid](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@roman.smid](https://get-help.theconstruct.ai/u/roman.smid)\
**Post date:** [May 13, 2022, 7:55am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274/1 "2022-05-13T07:55:58Z")

</div>

I am getting this error when I want to echo the /counter topic

 ![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/4/4a2396282bebd9297cfd3c6b9d250f66366c6b26.png)

Same error pops up when I want to pub on the topic. Any idea what that might be?

---

<div class="post-metadata">

**Author:** ![mtorres](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/mtorres/32/6971_2.png) [@mtorres](https://get-help.theconstruct.ai/u/mtorres)\
**Post date:** [May 13, 2022, 8:03am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274/2 "2022-05-13T08:03:13Z")

</div>

Try with:  
ros2 topic echo /counter std\_msgs/Int32

And verify that the topic is available:  
ros2 topic list

---

<div class="post-metadata">

**Author:** ![roman.smid](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@roman.smid](https://get-help.theconstruct.ai/u/roman.smid)\
**Post date:** [May 13, 2022, 8:03am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274/3 "2022-05-13T08:03:46Z")

</div>

Found the issue, just needed to use a terminal with the /opt/ros/foxy/setup.bash sourced instead of the ros2\_ws setup file sourced. Not sure if this was the root cause of the issue but works now.

---

<div class="post-metadata">

**Author:** ![roman.smid](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@roman.smid](https://get-help.theconstruct.ai/u/roman.smid)\
**Post date:** [May 13, 2022, 8:04am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274/4 "2022-05-13T08:04:08Z")

</div>

thanks @mtorres for chipping in. Found the solution now.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [May 13, 2022, 9:12am UTC](https://get-help.theconstruct.ai/t/ros2-in-5-days-c-error-in-unit-5/17274/5 "2022-05-13T09:12:49Z")

</div>


