how can i solve this error regarding Float and vector3?
hey guys i am using a Jetson nano and a Jetracer Ai Kit as my robot for implementing ros navigation stack. I am able to control the robot with ros using teleop_gamepad.py. by the way the robot is a 4 wheel drive with two rare dc motors without encoders and servo for the steering in front.
on the python script for my robot i tried subscribing to the topic /cmd_vel from move_base but i keep getting these errors...
[INFO] [1663341529.061724]: /cmd_vel: x: -0.1
y: 0.0
z: 0.0
[ERROR] [1663341529.091765]: bad callback: <function callback_cmd at 0x7f8fdd17b8>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/user/catkin_ws/src/cytron_jetracer/scripts/racecar.py", line 32, in callback_cmd
car.throttle = cmd.linear
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 585, in __set__
self.set(obj, value)
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 559, in set
new_value = self._validate(obj, value)
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 591, in _validate
value = self.validate(obj, value)
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 1976, in validate
self.error(obj, value)
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 625, in error
raise TraitError(e)
traitlets.traitlets.TraitError: The 'throttle' trait of a NvidiaRacecar instance must be a float, but a value of x: -0.1
y: 0.0
z: 0.0 <class 'geometry_msgs.msg._Vector3.Vector3'> was specified.
This is what the python code for my robot looks like...
import rospy
from jetracer.nvidia_racecar import NvidiaRacecar
from std_msgs.msg import Float64
from nav_msgs.msg import Odometry
from geometry_msgs.msg import Point, Twist, Vector3
from math import atan2
#Initialize car variable and tune settings
car = NvidiaRacecar()
car.steering_gain = 0.65
car.steering_offset = 0.0
car.throttle_gain = 0.8
car.throttle = 0.0
#Throttle
def callback_throttle(throt):
car.throttle = throt.data
rospy.loginfo("Throttle: %s", str(throt.data))
#Steering
def callback_steering(steer):
car.steering = steer.data
rospy.loginfo("Steering: %s", str(steer.data))
#cmd_vel
def callback_cmd(cmd):
rospy.loginfo("/cmd_vel: %s", str(cmd.linear))
car.throttle = cmd.linear
#Setup node and topics subscription
def racecar():
rospy.init_node('racecar', anonymous=True)
rospy.Subscriber("throttle", Float64, callback_throttle)
rospy.Subscriber("steering", Float64, callback_steering)
rospy.Subscriber("/cmd_vel", Twist, callback_cmd)
rospy.spin()
if __name__ == '__main__':
print("Running racecar.py")
racecar()
Because of this i haven't been able to move the robot after clicking 2D Nav Goal on Rviz. Any idea how to solve this issue?
Thanks in advance.