ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

TristanNoctis's profile - activity

2020-04-02 11:38:20 -0500 marked best answer ros/ros.h No such file or directory

I have been running ROS Melodic in my Ubuntu Bionic system. I already had a previous workspace called 'catkin_ws'. Recently, I tried to create another workspace which I named 'ros'. I then created a directory called 'first_package' inside the 'src' folder using the 'catkin_create_pkg' command. I then coded a small segment which I have attached below and named it hello.cpp inside the 'first_package' which I have attached below.

//This is the ROS standard of "hello, world" program//

//This header defined standard ROS classed//
#include<ros/ros.h>

int main(int argc, char **argv){
//Initialize the ROS system
ros::init(argc, argv, "hello_ros");

//Establish this program as ROS node
ros::NodeHandle nh;

//Send some output as log message
ROS_INFO_STREAM("Hello, ROS!");
}

I have changed both the CMakeLists.txt and Package.xml accordingly, but I still receive this error. Could someone please resolve this issue. The error occurs when I use the command 'catkin_make'

This is the CMakeLists.txt file

cmake_minimum_required(VERSION 2.8.3)
project(first_package)
find_package(catkin REQUIRED COMPONENTS roscpp)
catkin_package()
include_directories()
add_executable(hello hello.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})

The package.xml file is as follows,

<?xml version="1.0"?>
<package format="2">
  <name>first_package</name>
  <version>0.0.0</version>
  <description>The first_package package</description>
<maintainer email="danish@todo.todo">danish</maintainer>


 <license>TODO</license>
      <buildtool_depend>catkin</buildtool_depend>
      <build_depend>roscpp</build_depend>
      <exec_depend>roscpp</exec_depend>

<export>
  </export>
</package>
2020-02-19 04:47:00 -0500 received badge  Famous Question (source)
2020-02-19 04:47:00 -0500 received badge  Notable Question (source)
2019-08-21 07:17:30 -0500 received badge  Popular Question (source)
2019-08-05 12:07:32 -0500 commented answer Not able to publish image to std_msg/Image

Thanks for your help! Really sorry for not responding earlier. I have been a bit busy the last few days.

2019-08-05 12:07:28 -0500 marked best answer Not able to publish image to std_msg/Image

I am trying to run a publisher code that publishes an Image to a topic. But, whenever I run the code, I get an error. The code I have written is below -

#!/usr/bin/env python

import rospy
import numpy as np
import cv2
from sensor_msgs.msg import Image

video_capture = cv2.VideoCapture(0)

def main():
rospy.init_node('Tennis Ball Publisher', anonymous = True)

pub = rospy.Publisher("tennis_ball_image", Image, queue_size = 10)

rate = rospy.Rate(1)

while (True):
    ret, frame = video_capture.read()

    pub.publish(frame)

    rate.sleep()


if __name__=='__main__':
    main()

This is the error that I get on running the code -

Traceback (most recent call last):
  File "tennis_ball_publisher.py", line 26, in <module>
    main()
  File "tennis_ball_publisher.py", line 20, in main
    pub.publish(frame)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 879, in publish
    data = args_kwds_to_message(self.data_class, args, kwds)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/msg.py", line 122, in args_kwds_to_message
    return data_class(*args)

  File "/opt/ros/melodic/lib/python2.7/dist-packages/sensor_msgs/msg/_Image.py", line 78, in __init__
    super(Image, self).__init__(*args, **kwds)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 294, in __init__
    raise TypeError("Invalid number of arguments, args should be %s"%str(self.__slots__)+" args are"+str(args))
TypeError: Invalid number of arguments, args should be ['header', 'height', 'width', 'encoding', 'is_bigendian', 'step', 'data'] args are(None,)

I suspect that the error is in the way I am publishing the frame but I am not able to rectify it. Any help is appreciated.

2019-08-02 11:46:07 -0500 marked best answer No output received for subscriber program

I am running ROS melodic on my Ubuntu Bionic. I have coded a publisher and subcriber program. While the publisher program works correctly, when I run the subscriber program using rosrun I dont receive any output

The publisher code -

//This program publishes randomly generated velocity messages for the turtlesim//

#include<ros/ros.h>
#include<geometry_msgs/Twist.h>
#include<stdlib.h>      //For rand and RAND_MAX

int main(int argc, char **argv){
    //Initialize ROS system and publish a node
    ros::init(argc, argv, "publish_velocity");
    ros::NodeHandle nh;

    //Create publisher object
    ros::Publisher pub = nh.advertise<geometry_msgs::Twist>("turtle1/cmd_vel", 1000);

    //Seed the random number generator
    srand(time(0));

    //Loop at 2Hz until the node is shut down
    ros::Rate rate(2);
    while(ros::ok()){
        //Create and fill in the four fields, the other four fields, which are ignored by turtlesim, default to 0
        geometry_msgs::Twist msg;
        msg.linear.x = double(rand())/double(RAND_MAX);
        msg.angular.z = 2*double(rand())/double(RAND_MAX) - 1;

        //Publish the message
        pub.publish(msg);

        //Send a message to rosout with the details
        ROS_INFO_STREAM("Sending random velocity command:"
        <<" linear="<<msg.linear.x
        <<" angular="<<msg.angular.z);

        //Wait until its time for another iteration
        rate.sleep();

    }
}

and the corresponding subscriber code -

//This program subscribes to /turtle1/pose and displays it on the screen

#include<ros/ros.h>
#include<turtlesim/Pose.h>
#include<iomanip> //for std::setprecision and std::fixed

// A calback function that is executed each time a pose message is received
void poseMessageReceived(const turtlesim::Pose &msg){
    ROS_INFO_STREAM(std::setprecision(2) << std::fixed
    << "position=("<< msg.x <<","<< msg.y<< ")"
    << " direction="<< msg.theta);
}

int main(int argc, char **argv){
    //Initialize a ROS system and become a node
    ros::init(argc, argv, "subscribe_to_pose");
    ros::NodeHandle nh;

    //Create a subscriber object
    ros::Subscriber sub = nh.subscribe("turle1/pose", 1000, &poseMessageReceived);

    //Let ROS take over
    ros::spin();
}

Both of these have been saved under the same package. The CMakeLists.txt is-

cmake_minimum_required(VERSION 2.8.3)
project(first_package)
find_package(catkin REQUIRED COMPONENTS roscpp geometry_msgs turtlesim)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(hello hello.cpp)
add_executable(pubvel pubvel.cpp)
add_executable(subpose subpose.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})
target_link_libraries(pubvel ${catkin_LIBRARIES})
target_link_libraries(subpose ${catkin_LIBRARIES})

What could be possible error here. It compiles perfectly when i use catkin_make. Is the error in the code itself or in the CMakeLists.txt?

2019-08-02 11:45:20 -0500 received badge  Famous Question (source)
2019-08-02 11:45:14 -0500 received badge  Famous Question (source)
2019-08-02 11:43:40 -0500 asked a question Not able to publish image to std_msg/Image

Not able to publish image to std_msg/Image I am trying to run a publisher code that publishes an Image to a topic. But,

2019-02-13 05:44:22 -0500 received badge  Famous Question (source)
2019-01-19 23:56:36 -0500 commented answer No output received for subscriber program

Hmm idk. The reason I ask a question is because I want it to be solved. I dont get why someone would not respond after y

2019-01-19 06:52:55 -0500 commented answer No output received for subscriber program

@billy: Yes it seems restarting the roscore was all that I needed to do. Thanks for your help!

2019-01-18 10:12:16 -0500 commented answer No output received for subscriber program

@billy: can you elaborate? I am printing the pose.

2019-01-16 03:58:19 -0500 commented answer No output received for subscriber program

I get it now! But still after making the changes, I dont see any output. Is there any other change i must do?

2019-01-16 02:10:12 -0500 commented answer No output received for subscriber program

Oh sorry I am new to both programming and ROS. By the way, how could this have compiled even though made is mistake?

2019-01-16 02:10:12 -0500 received badge  Commentator
2019-01-16 01:11:24 -0500 commented answer No output received for subscriber program

where exactly is this error?

2019-01-16 01:10:28 -0500 received badge  Enthusiast
2019-01-16 00:45:51 -0500 received badge  Notable Question (source)
2019-01-15 11:25:24 -0500 commented question No output received for subscriber program

I am doing it on simulation. Based on the command velocities being sent, the turtle pose would change right? I want this

2019-01-15 07:15:45 -0500 received badge  Popular Question (source)
2019-01-15 07:15:14 -0500 commented question No output received for subscriber program

Ok I have done it. Can you please open the question and solve it?

2019-01-15 07:14:38 -0500 edited question No output received for subscriber program

No output received for subscriber program I am running ROS melodic on my Ubuntu Bionic. I have coded a publisher and sub

2019-01-15 07:13:20 -0500 edited question No output received for subscriber program

No output received for subscriber program I am running ROS melodic on my Ubuntu Bionic. I have coded a publisher and sub

2019-01-15 07:13:20 -0500 received badge  Editor (source)
2019-01-15 07:06:12 -0500 commented question No output received for subscriber program

Sorry for posting the screenshot. Will i be able to post just the code like i have done for the CMakeLists.txt? Even tho

2019-01-15 04:39:37 -0500 asked a question No output received for subscriber program

No output received for subscriber program I am running ROS melodic on my Ubuntu Bionic. I have coded a publisher and sub

2019-01-14 02:04:27 -0500 received badge  Notable Question (source)
2019-01-13 23:28:01 -0500 commented answer Why isnt my executable compiling?

Your update to the CMakeLists.tst worked! Only problem now is that I have to source the setup.bash each time I open a ne

2019-01-13 23:23:41 -0500 marked best answer Why isnt my executable compiling?

So right now, I have two executables within one package. I had created the first executable a few days back. But after creating the second executable and using the catkin_make command, only the first program gets compiled and not the second. What am I doing wrong? Is it because of the two executables within one package? Also, if I type rosrun package executable2, I get the following error - "Couldn't find executable names executable2"

My Cmake file -

cmake_minimum_required(VERSION 2.8.3)
project(first_package)
find_package(catkin REQUIRED COMPONENTS roscpp geometry_msgs)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(hello hello.cpp pubvel pubvel.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})

I am pretty sure the error is due to the add_executable part of my CMakeLists.txt. hello.cpp is the first executable whereas pubvel.cpp is the second executable.

2019-01-13 14:59:04 -0500 received badge  Popular Question (source)
2019-01-13 09:39:09 -0500 received badge  Student (source)
2019-01-13 09:27:50 -0500 commented question Why isnt my executable compiling?

This is my other workspace that I have created other than the 'catkin_ws'. And yes I have sourced it before using the ca

2019-01-13 09:26:26 -0500 commented question Why isnt my executable compiling?

Hey I have updated my CMakeLists.txt. Can you please check?