ROS

Discussions about all things Bitcraze
Post Reply
zhanghaijason
Member
Posts: 52
Joined: Fri Jul 28, 2017 9:07 pm

ROS

Post by zhanghaijason »

Hello,
I am new to ROS and crazyflie. For the demo given by the ROS readme file. Can someone help me check if my understanding is correct or not?
for hovering at (0,0,1) using VICON.
1. The node crazyflie_server is used to get the position data from VICON or Optitrack; to subscribe to "cmd_vel" to get the 'x,y,z and yaw' data published from controller.cpp. After getting the "x,y,z and yaw", with function cmdVelChanged, the four data is transformed into "roll,pitch, yaw and thrust", which are similar to a joystick. So the crazyflie can be controlled to hover at desired altitude.
2. But the example is run with some python scripts, if I want to control my crazyflie to do similar task, I need to write my own launch file?
3. In the launch file "hover_vicon.launch", it used a node named "joy", where is the source file of this node? I did not find it in either crazyflie_ros or the default ros(lunar) packages.

Thanks for your time
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: ROS

Post by whoenig »

1. Correct.
2. You would likely need a custom launch file and python script.
3. It is referring to joy-node (http://wiki.ros.org/joy), which needs to be installed separately.

You can find more details in "Flying Multiple UAVs Using ROS", in Springer Book on Robot Operating System (ROS) (a preprint is available at act.usc.edu). Also, if you are just starting out I recommend looking into the Crazyswarm project, even for a single CF as it comes with a much better controller (http://crazyswarm.readthedocs.io/en/latest/).
zhanghaijason
Member
Posts: 52
Joined: Fri Jul 28, 2017 9:07 pm

Re: ROS

Post by zhanghaijason »

Thank you!
zhanghaijason
Member
Posts: 52
Joined: Fri Jul 28, 2017 9:07 pm

Re: ROS

Post by zhanghaijason »

Hi whoenig,
I read the code again recently and still have several questions.
For the hovering problem:
1. How could ROS know CF's position? I know it should be related to targetDrone,

Code: Select all

tf::StampedTransform transform;
                m_listener.lookupTransform(m_worldFrame, m_frame, ros::Time(0), transform);

                geometry_msgs::PoseStamped targetWorld;
                targetWorld.header.stamp = transform.stamp_;
                targetWorld.header.frame_id = m_worldFrame;
                targetWorld.pose = m_goal.pose;

                geometry_msgs::PoseStamped targetDrone;
                m_listener.transformPose(m_frame, targetWorld, targetDrone);

                tfScalar roll, pitch, yaw;
                tf::Matrix3x3(                                       //tf namespace, Matrix3x3, class
                    tf::Quaternion(                                  //tf namespace, Quaternion, class
                        targetDrone.pose.orientation.x,
                        targetDrone.pose.orientation.y,
                        targetDrone.pose.orientation.z,
                        targetDrone.pose.orientation.w
                    )).getRPY(roll, pitch, yaw);
Which sentence actually gets the CF's position? How could it get the position data? In my understanding, the vicon/optitrack node should publish the position data to a topic A and the controller.cpp subscribes to topic A to get the position data. But I did not find such publisher in vicon's code, either the subscriber in controller.cpp
2. For the PID controller
The input to these controllers are the desired hover position and the current feedback. Is it realistic to get the desired control input(pitch, roll, yaw rate, thrust) from the error one to one?(I mean control input roll is generated only from x position error, desired control input pitch is generated only from y position error... ).

Thanks
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: ROS

Post by whoenig »

For future reference: this is being discussed in https://github.com/whoenig/crazyflie_ros/issues/63.
Post Reply