Ask Your Question

renanmb's profile - activity

2019-06-27 08:51:57 -0600 received badge  Famous Question (source)
2019-04-08 11:43:29 -0600 received badge  Notable Question (source)
2019-01-24 10:21:54 -0600 received badge  Famous Question (source)
2019-01-17 02:54:02 -0600 received badge  Famous Question (source)
2018-10-15 02:00:08 -0600 received badge  Notable Question (source)
2018-10-14 06:22:51 -0600 marked best answer How to use message from another package

So I am trying to use a custom msg (Drive.msg) that I created in the boat_controller project inside the same workspace. This message is necessary for connecting boat_hw with boat_controller.

Github: in the same workspace I have the following projects:

boat_hw : https://github.com/renanmb/boat_hw

boat_controller : https://github.com/renanmb/boat_pid_c...

VESC : https://github.com/renanmb/VESC

So how do I do it on the CMakefile.txt , It really got me confused. Message is in boat_controller and I wanna build it in boat_hw.

This is the error shown by the Terminal:

[ 96%] Building CXX object boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o
[ 96%] Building CXX object boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o
In file included from /home/renan/rostest_ws/src/boat_hw/src/boat_hw.cpp:1:0:
/home/renan/rostest_ws/src/boat_hw/src/boat_hw.h:5:37: fatal error: boat_controller/Drive.msg: No such file or directory
compilation terminated.
boat_hw/CMakeFiles/robot.dir/build.make:86: recipe for target 'boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o' failed
make[2]: *** [boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/renan/rostest_ws/src/boat_hw/src/robot.cpp:1:0:
/home/renan/rostest_ws/src/boat_hw/src/boat_hw.h:5:37: fatal error: boat_controller/Drive.msg: No such file or directory
compilation terminated.
boat_hw/CMakeFiles/robot.dir/build.make:62: recipe for target 'boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o' failed
make[2]: *** [boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o] Error 1
CMakeFiles/Makefile2:4519: recipe for target 'boat_hw/CMakeFiles/robot.dir/all' failed
make[1]: *** [boat_hw/CMakeFiles/robot.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j6 -l6" failed

This is my CMakelist.txt

cmake_minimum_required(VERSION 2.8.3)
project(boat_hw)


find_package(catkin REQUIRED COMPONENTS vesc_driver vesc_msgs controller_manager)

## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
  CATKIN_DEPENDS vesc_driver vesc_msgs boat_controller

)

include_directories(
  include
  ${Boost_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)


add_executable(robot
                        src/robot.cpp
                        src/boat_hw.cpp
                        src/boat_driver.cpp
              )

add_dependencies(robot ${catkin_EXPORTED_TARGETS})
target_link_libraries(robot
  ${catkin_LIBRARIES}
  vesc_driver_nodelet
  ${boat_controller}
#  add_library(${PROJECT_NAME}
  src/${boat_controller}/Drive.msg
  #controller_manager
)
2018-10-14 05:44:18 -0600 received badge  Popular Question (source)
2018-10-14 05:44:01 -0600 commented question How to use message from another package

and I am pretty confused, I know I could just create a message folder. I want to use messages from other packages withou

2018-10-14 05:41:13 -0600 edited question How to use message from another package

How to use message from another package So I am trying to use a custom msg (Drive.msg) that I created in the boat_contro

2018-10-14 05:32:40 -0600 commented answer How to use message from another package

so do I have to create a new mg folder in every single package every time I want to use a new custom message? I thought

2018-10-14 05:31:02 -0600 edited question How to use message from another package

How to use message from another package So I am trying to use a custom msg (Drive.msg) that I created in the boat_contro

2018-10-13 21:23:30 -0600 asked a question How to use message from another package

How to link roscpp to other package library So I am trying to use a custom msg (Drive.msg) that I created in the boat_co

2018-10-12 05:47:14 -0600 commented answer Rospy Parameter KeyError

It was about the launch file, this forum was giving a server error to post another question. I also tried to use the ros

2018-10-12 05:42:52 -0600 marked best answer Rospy Parameter KeyError

I cannot get my code to get the parameters on my config file. I just do like it is on the tutorials but it does not work and I do not understand why. I believe it might be a namespace problem with rospy. I have never had this problem with C++.

My Github with the whole code: https://github.com/renanmb/boat_pid_c...

throttle_interpolator.py

#!/usr/bin/env python
import rospy

from std_msgs.msg import Float64
from boat_controller.msg import Drive

# import some utils.
import numpy as np
import copy as copy

class InterpolateThrottle:
    def __init__(self):
        self.rpm_input_topic   = rospy.get_param('~rpm_input_topic', '/vesc/commands/motor/unsmoothed_speed')
        self.rpm_output_left_topic  = rospy.get_param('~rpm_output_left_topic', '/vesc/commands/motor/speed_left')
        self.rpm_output_right_topic  = rospy.get_param('~rpm_output_right_topic', '/vesc/commands/motor/speed_right')

        self.servo_input_topic   = rospy.get_param('~servo_input_topic', '/vesc/commands/servo/unsmoothed_position')
        self.servo_output_topic  = rospy.get_param('~servo_output_topic', '/vesc/commands/servo/position')

        self.max_rpm_acceleration = rospy.get_param('/vesc/max_rpm_acceleration')
        self.max_rpm = rospy.get_param('/vesc/vesc_driver/speed_max')
        self.min_rpm = rospy.get_param('/vesc/vesc_driver/speed_min')
        self.throttle_smoother_rate = rospy.get_param('/vesc/throttle_smoother_rate')
        self.rpm_to_erpm_gain = rospy.get_param('/vesc/rpm_to_erpm_gain')

        self.max_servo_speed = rospy.get_param('/vesc/max_servo_speed')
        self.steering_angle_to_servo_gain = rospy.get_param('/vesc/steering_angle_to_servo_gain')
        self.servo_smoother_rate = rospy.get_param('/vesc/servo_smoother_rate')
        self.max_servo = rospy.get_param('/vesc/vesc_driver/servo_max')
        self.min_servo = rospy.get_param('/vesc/vesc_driver/servo_min')

        self.last_rpm = 0
        self.desired_rpm = self.last_rpm

        self.last_servo = rospy.get_param('/vesc/steering_angle_to_servo_offset')
        self.desired_servo_position = self.last_servo

        self.rpm_output_left = rospy.Publisher(self.rpm_output_left_topic, Float64,queue_size=1)
        self.rpm_output_right = rospy.Publisher(self.rpm_output_right_topic, Float64,queue_size=1)
        self.servo_output = rospy.Publisher(self.servo_output_topic, Float64,queue_size=1)

        rospy.Subscriber(self.rpm_input_topic, Drive, self._process_throttle_command)
        rospy.Subscriber(self.servo_input_topic, Float64, self._process_servo_command)

        self.max_delta_servo = abs(self.steering_angle_to_servo_gain * self.max_servo_speed / self.servo_smoother_rate)
        rospy.Timer(rospy.Duration(1.0/self.servo_smoother_rate), self._publish_servo_command)

        self.max_delta_rpm = abs(self.rpm_to_erpm_gain * self.max_rpm_acceleration / self.throttle_smoother_rate) 

        rospy.Timer(rospy.Duration(1.0/self.max_delta_rpm), self._publish_throttle_left_command)
        rospy.Timer(rospy.Duration(1.0/self.max_delta_rpm), self._publish_throttle_right_command)

        self._run()

    def _run(self):
        rospy.spin()

    def _publish_throttle_left_command(self, evt):
        desired_delta = self.desired_rpm_left-self.last_rpm_left
        clipped_delta = max(min(desired_delta, self.max_delta_rpm), -self.max_delta_rpm)
        smoothed_rpm = self.last_rpm_left + clipped_delta
        self.last_rpm_left = smoothed_rpm
        self.rpm_output_left.publish(Float64(smoothed_rpm))

    def _publish_throttle_right_command(self, evt):
        desired_delta = self.desired_rpm_right-self.last_rpm_right
        clipped_delta = max(min(desired_delta, self.max_delta_rpm), -self.max_delta_rpm)
        smoothed_rpm = self.last_rpm_right + clipped_delta
        self.last_rpm_right = smoothed_rpm
        self.rpm_output_right.publish(Float64(smoothed_rpm))

    def _process_throttle_command(self,msg):
        input_rpm_left = msg.data
        input_rpm_right = msg.data
        input_rpm_left = min(max(input_rpm_left, self.min_rpm), self.max_rpm)
        input_rpm_right = min(max(input_rpm_right, self.min_rpm), self.max_rpm)
        self.desired_rpm_left = input_rpm_left
        self.desired_rpm_right = input_rpm_right

    def _publish_servo_command(self, evt):
        desired_delta = self.desired_servo_position-self.last_servo
        clipped_delta = max(min(desired_delta, self.max_delta_servo), -self.max_delta_servo)
        smoothed_servo = self.last_servo + clipped_delta
        self.last_servo = smoothed_servo         
        self.servo_output.publish(Float64(smoothed_servo))

    def _process_servo_command(self,msg):
        input_servo = msg.data
        input_servo = min(max(input_servo, self.min_servo), self.max_servo)
        self.desired_servo_position = input_servo


if __name__ == '__main__':
    try:
        rospy.init_node('Throttle_Interpolator')
            p = InterpolateThrottle()
        rospy.spin()
    except rospy.ROSInterruptException:
        pass

Error message:

Traceback (most recent call last):
  File "/home/renan/rostest_ws/src/boat_controller/src/throttle_interpolator.py", line 136, in <module>
    p = InterpolateThrottle()
  File "/home/renan/rostest_ws/src/boat_controller/src/throttle_interpolator.py", line 28 ...
(more)
2018-10-11 10:54:25 -0600 commented answer Rospy Parameter KeyError

You did not answer my question, because it still does not work. I tried to use roslaunch to set all parameter and I cre

2018-10-11 01:58:55 -0600 received badge  Notable Question (source)
2018-10-10 13:31:50 -0600 marked best answer cannot get multiple nodes running

I wrote a package with 2 nodes in python exactly how I have always done before, and it compiles without errors with catkin_make, but one of the nodes does not work. It does not publish or subscribe anything or give errors at all.

This is really confusing for me. I am posting my github: https://github.com/renanmb/boat_pid_c...

All the code is there, I just want to get the throttle_interpolator.py to work

The node throttle_interpolator.py should simply get the messages from pid_controller.py and make it compatible to VESC and respect the motor limits.

I would appreciate any help.

pid_controller.py

#!/usr/bin/env python

# Python
import sys
from math import pi

# ROS
import rospy
import tf
from dynamic_reconfigure.server import Server 
#from boat_controller.cfg import *
from boat_controller.cfg import YawDynamicConfig
from boat_controller.cfg import TwistDynamicConfig

from boat_controller.msg import Diagnose
#from boat_pid_controller.msg import *

from geometry_msgs.msg import Vector3
from geometry_msgs.msg import Twist
from std_msgs.msg import Float64
from nav_msgs.msg import Odometry 
from boat_controller.msg import Drive
from boat_controller.msg import Course
from sensor_msgs.msg import Imu 
#from std_srvs.srv import SetBool, SetBoolResponse, SetBoolRequest
from std_srvs.srv import Empty, EmptyResponse

# BSB
import pypid

class Node():
    def __init__(self, engaged=False, yaw_cntrl=True,vel_cntrl=True):
        # Detup Yaw Pid
        self.engaged = engaged
        self.yaw_cntrl = yaw_cntrl
        self.vel_cnrtl = vel_cntrl
        self.ypid = pypid.Pid(0.0, 0.0, 0.0)
        self.ypid.set_setpoint(0.0)
        #self.[id.set_inputisangle(True,pi)
        self.ypid.set_derivfeedback(True)
        fc = 20; #cutoff freq in Hz
        wc = fc*(2.0*pi) #cutoff freq in rad/s
        self.ypid.set_derivfilter(1, wc)
        self.ypid.set_maxIout(1.0)
        # Setup Velocity Pid
        self.vpid = pypid.Pid(0.0, 0.0, 0.0)
        self.vpid.set_setpoint(0.0)
        self.vpid.set_maxIout(1.0)
        #self.pid.set_inputisangle(Truempi)
        self.vpid.set_derivfeedback(True)
        fc = 20; # cutoff freq in Hz
        wc = fc*(2.0*pi) # cutoff freq in rad/s
        self.vpid.set_derivfilter(1,wc)
        # Initialize as none for now
        self.drivemsg = None
        self.publisher = None
        self.lasttime = None
        # For tuning PID
        self.vpubdebug = None
        self.ypubdebug = None

        # Type of yaw control
        self.yaw_type = 'yaw'

    def toggle_engaged_callback(self,req):
        self.engaged = not self.engaged
        rospy.loginfo('Toggling engaged status - new status is...')
        rospy.loginfo(self.engaged)

        if self.engaged:
            self.ypid.I = 0.0
            self.vpid.I = 0.0
        return EmptyResponse()

    def twist_callback(self,msg):
        self.vpid.set_setpoint(msg.linear.x)
        self.ypid.set_setpoint(msg.angular.z)

    def course_callback(self,msg):
        self.ypid.set_setpoint(msg.yaw)
        self.vpid.set_setpoint(msg.speed)

    def odom_callback(self,msg):
        # calculate time step
        now = rospy.get_time()
        if self.lasttime is None:
            self.lasttime = now
            return
        dt = now-self.lasttime
        self.lasttime = now
        # Yaw control
        if self.yaw_cntrl:
            if self.yaw_type=='yaw_rate':
                yaw_fdbk = msg,twist.twist.angular.z
            elif self.yaw_type=='yaw':
                euler = tf.transformations.euler_from_quaternion(
(msg.pose.pose.orientation.x,
msg.pose.pose.orientation.y,
msg.pose.pose.orientation.z,
msg.pose.pose.orientation.w))
                yaw_fdbk = euler[2] # yaw
            yout = self.ypid.execute(dt,yaw_fdbk)
            torque = yout ...
(more)
2018-10-10 13:30:09 -0600 received badge  Famous Question (source)
2018-10-10 13:22:53 -0600 commented answer Rospy Parameter KeyError

I found this: http://docs.ros.org/indigo/api/rospy/html/rospy.client-pysrc.html#get_param But it is pretty much what I

2018-10-10 12:56:39 -0600 received badge  Popular Question (source)
2018-10-10 12:23:10 -0600 commented answer Rospy Parameter KeyError

please, I would appreciate if you could provide the source of this information, so I can study it more. To be honest I d

2018-10-10 11:16:52 -0600 commented answer Rospy Parameter KeyError

please, I would appreciate if you could provide the source of this information, so I can study it more.

2018-10-10 10:57:59 -0600 commented question Rospy Parameter KeyError

My other nodes loads its parameters just fine. I tried the command rosparam load and it does not work. It says the file

2018-10-10 10:17:44 -0600 asked a question Rospy Parameter KeyError

Rospy Parameter KeyError I cannot get my code to get the parameters on my config file. I just do like it is on the tutor

2018-10-10 07:45:22 -0600 commented question cannot get multiple nodes running

According to http://wiki.ros.org/rospy_tutorials/Tutorials/Parameters dos not seem to have a problem. I am setting a glo

2018-10-10 07:06:47 -0600 edited question cannot get multiple nodes running

cannot get multiple nodes running I wrote a package with 2 nodes in python exactly how I have always done before, and it

2018-10-09 20:20:02 -0600 received badge  Notable Question (source)
2018-10-09 12:27:43 -0600 commented question cannot get multiple nodes running

I simply does know what I made wrong. It should be working. I also see that there are better ways to create a controller

2018-10-09 12:25:46 -0600 edited question cannot get multiple nodes running

cannot get multiple nodes running I wrote a package with 2 nodes in python exactly how I have always done before, and it

2018-10-08 01:29:15 -0600 received badge  Popular Question (source)
2018-10-07 14:04:24 -0600 commented question cannot get multiple nodes running

In my opinion github makes the post much clear. But yeah, thanks. rospy.spin() is not the answer

2018-10-06 07:51:21 -0600 asked a question cannot get multiple nodes running

cannot get multiple nodes running I wrote a package with 2 nodes in python exactly how I have always done before, and it

2018-09-26 04:19:32 -0600 commented question Issues with ros_lib for Arduino

I figure it out. There is an order for making the whole thing work. The challenge is that there is no documentation or m

2018-09-23 19:00:16 -0600 commented answer How to properly create a Joy Node or any node.

Later on I solved the problem by trial and error and making a controller mapping. I was writing a teleop node for the l

2018-09-23 18:57:02 -0600 marked best answer How to properly create a Joy Node or any node.

I made this post because I couldn`t find any detailed explanation on the web about how to build a node from scratch and it may help anyone trying to self-learn ROS. I tried to build a node for controlling the Turtle sim using my PS4 joystick using different buttons and axis with learning purpose for later applying at my robot.

However while trying to run I receive back the message:

couldn`t find executable named teleop_joy below /home/rmb/workspace1/src/test_node

My code: https://github.com/renanmb/SURP

It happens using rosrun and roslaunch. I don`t understand why since I tryied to keep the code very similar to the code found at the Ros Joy Tutorial ( http://wiki.ros.org/joy/Tutorials/Wri... ).

I also used as example the code found at JetsonHacks https://github.com/jetsonhacks/jetson...

Thanks for the support.

2018-09-23 18:56:06 -0600 commented answer Developing on Windows using Eclipse?????

It is true. Windows does not work very well. Virtual Machine works fine for most of the time.

2018-09-23 18:53:55 -0600 marked best answer Developing on Windows using Eclipse?????

I wish I could develop ROS on an IDE like Eclipse on Windows. However I did not found any reference to install on windows.

Does that work??? because it would be much more practical than having to use a Virtual Machine.

2018-09-23 04:36:11 -0600 received badge  Popular Question (source)
2018-09-22 18:50:14 -0600 asked a question Issues with ros_lib for Arduino

Issues with ros_lib for Arduino Please, I need help to review the code at the bottom of the post, there is something ver

2018-08-25 12:24:03 -0600 received badge  Taxonomist
2018-04-30 23:09:02 -0600 received badge  Famous Question (source)
2018-03-19 02:29:18 -0600 received badge  Famous Question (source)
2018-03-04 02:49:06 -0600 received badge  Famous Question (source)
2018-01-23 18:08:45 -0600 received badge  Famous Question (source)