Asctec_autopilot problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Asctec_autopilot problem

JaMora
Hello,

So far I've been able to use ROS to poll data from my pelican, but haven't been able to send commands via serial.

This is the procedure I'm using:

1. In terminal:
$ roscore
$ sudo chmod 777 /dev/ttyUSB0
$ roslaunch asctec_autopilot autopilot.launch

2. Enable serial interface switch (Channel G Futaba Control)

3. Run a file that should publish the command input structure:
$ rosrun asctec_proc talker

4. Check the structure is being published:
$ rostopic echo /asctec/CTRL_INPUT

Which returns messages likes this:

---
header: 
  seq: 2409
  stamp: 
    secs: 0
    nsecs: 0
  frame_id: ''
pitch: 0
roll: 0
yaw: -2048
thrust: 0
ctrl: 255
chksum: -23639
---

Here is the "talker.cpp" file:

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

	ros::init(argc, argv, "talker");
	ros::NodeHandle n;	

	ros::Publisher thrust_pub = n.advertise<asctec_msgs::CtrlInput>("/asctec/CTRL_INPUT", 1);

	ros::Rate loop_rate(30);

while (ros::ok())
  {
	  asctec_msgs::CtrlInput msg;
	  msg.pitch = 0;
	ROS_INFO("pitch", msg.pitch);
	  msg.roll = 0;
ROS_INFO("roll", msg.roll);
	  msg.thrust = 0;
ROS_INFO("thrust", msg.thrust);
	  msg.yaw = -2048;
ROS_INFO("yaw", msg.yaw);
	  msg.ctrl = 0xF;
ROS_INFO("ctrl", msg.ctrl);
	  msg.chksum = msg.pitch
		     + msg.roll + msg.yaw
		     + msg.thrust + msg.ctrl + (short)0xAAAA;
ROS_INFO("chksum", msg.chksum);
	  thrust_pub.publish(msg);

	ros::spinOnce();

	loop_rate.sleep();

  }
return 0;
} 

And here is the autopilot ".launch" file:

<launch>

  #### Asctec Autopilot ###################################

  <node pkg="asctec_autopilot" type="autopilot_node" name="AutoPilotNode" output="screen">

    <remap from="/asctec/ESTOP" to="/mav/estop"/>  

    <param name="port" type="string" value="/dev/ttyUSB0"/>
    <param name="speed" type="int" value="57600"/>

    <param name="freq" type="double" value="30.0"/>

    <param name="enable_IMU_CALCDATA" type="bool" value="false"/>
    <param name="interval_IMU_CALCDATA" type="int" value="1"/>
    <param name="offset_IMU_CALCDATA" type="int" value="0"/>

    <param name="enable_LL_STATUS" type="bool" value="false"/>
    <param name="interval_LL_STATUS" type="int" value="2"/>
    <param name="offset_LL_STATUS" type="int" value="0"/>

  </node>

  #### Asctec Proc ########################################

  <node pkg="asctec_proc" type="asctec_proc_node" name="AsctecProcNode" output="screen">

    <param name="enable_state_changes" type="bool" value="true"/>
    <param name="enable_ctrl_thrust"   type="bool" value="true"/>
    <param name="enable_ctrl_yaw"      type="bool" value="true"/>

  </node>

</launch>

I would appreciate any kind of suggestions or ideas of what could be wrong.

Thank you,
Reply | Threaded
Open this post in threaded view
|

Re: Asctec_autopilot problem

JaMora
In case anybody needs this, the problem was a parameter missing for the autopilot node:

<param name="enable_CONTROL" type="bool" value="true"/>

After adding this line to the launch file, it works.
Reply | Threaded
Open this post in threaded view
|

Re: Asctec_autopilot problem

Lucas Proenca
Could you also share the header files you included in talker.cpp ?

Thank you!