# Tạo node I3S\_receiver

Sử dụng code từ beginner \_tutorial, thay đổi receiver

\#include \<ros/ros.h>

\#include \<sensor\_msgs/Joy.h>

\#include \<geometry\_msgs/Twist.h>

\#include \<geometry\_msgs/TwistStamped.h>

\#include \<std\_msgs/Float64.h>

class JoyROV

{

```
public:

  JoyROV\(\);

  void joyCallback\(const sensor\_msgs::Joy::ConstPtr &joy\);



private:

  ros::NodeHandle nh;        



  ros::Subscriber joySub;



  ros::Publisher angVelPub;

  ros::Publisher throttlePub;
```

};

JoyROV::JoyROV(){

```
//nh.setParam\("/mavros/setpoint\_attitude/reverse\_throttle", true\);

joySub = nh.subscribe\("/joy", 10, &JoyROV::joyCallback, this\);



angVelPub = nh.advertise&lt;geometry\_msgs::TwistStamped&gt;\("/mavros/setpoint\_attitude/cmd_vel",10);
```

```
throttlePub = nh.advertise&lt;std\_msgs::Float64&gt;\("/mavros/setpoint\_attitude/att_throttle",10);
```

```
//reserve\_throttlePub = nh.advertise&lt;bool&gt;\("/mavros/setpoint\_attitude/reverse\_throttle",10\);  

    //param::set\("/mavros/setpoint\_attitude/reverse\_throttle", true\);
```

// void ros::param::set("/mavros/setpoint\_attitude/reverse\_throttle", true);

/\*

```
//How to set parameter setpoit\_attitude/reserve\_throttle\(true\) for allowing to send -1.0 throttle???

bool reserve\_throttle\_ok = true;            

nh.setParam\("/mavros/setpoint\_attitude/reserve\_throttle", reserve\_throttle\_ok\);

/\*if \(nh.setParam\("/mavros/setpoint\_attitude/reserve\_throttle", reserve\_throttle\_ok\)\)

{

    ROS\_INFO\("Set sucessful param"\);

};\*/
```

}

void JoyROV::joyCallback(const sensor\_msgs::Joy::ConstPtr \&joy){

```
//ROS\_INFO\("I received: \[%f\]", joy-&gt;axes\[0\]\);    



geometry\_msgs::TwistStamped TwistStampedMsg;

TwistStampedMsg.twist.angular.x = joy-&gt;axes\[2\];// ROS\_INFO\("roll ang.vel received: \[%f\]" , TwistStampedMsg.twist.angular.x\);

TwistStampedMsg.twist.angular.y = joy-&gt;axes\[3\];// ROS\_INFO\("pitch ang.vel received: \[%f\]", TwistStampedMsg.twist.angular.y\);

TwistStampedMsg.twist.angular.z = joy-&gt;axes\[0\]; 

angVelPub.publish\(TwistStampedMsg\);



std\_msgs::Float64 throttleMsg;

throttleMsg.data = joy-&gt;axes\[1\];// ROS\_INFO\("throttle received: \[%f\]", throttleMsg.data\);

throttlePub.publish\(throttleMsg\);        

ROS\_INFO\("Debug: % 1.6f % 1.6f % 1.6f % 1.6f ", TwistStampedMsg.twist.angular.x, TwistStampedMsg.twist.angular.y, TwistStampedMsg.twist.angular.z, throttleMsg.data);
```

}

int main(int argc, char\*\* argv){

```
ros::init\(argc, argv, "I3S\_receiver"\);

JoyROV I3S\_receiver;



ros::spin\(\);

return 0;
```

}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lamhung81-2.gitbook.io/github-basic-tutorial/tao-node-i3sreceiver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
