{"action":"created","issue":{"url":"https://api.github.com/repos/PX4/Firmware/issues/10320","repository_url":"https://api.github.com/repos/PX4/Firmware","labels_url":"https://api.github.com/repos/PX4/Firmware/issues/10320/labels{/name}","comments_url":"https://api.github.com/repos/PX4/Firmware/issues/10320/comments","events_url":"https://api.github.com/repos/PX4/Firmware/issues/10320/events","html_url":"https://github.com/PX4/Firmware/pull/10320","id":353829140,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNzczNzIw","number":10320,"title":"[WIP] Make DO_SET_SERVO work","user":{"login":"kpetrykin","id":161284,"node_id":"MDQ6VXNlcjE2MTI4NA==","avatar_url":"https://avatars1.githubusercontent.com/u/161284?v=4","gravatar_id":"","url":"https://api.github.com/users/kpetrykin","html_url":"https://github.com/kpetrykin","followers_url":"https://api.github.com/users/kpetrykin/followers","following_url":"https://api.github.com/users/kpetrykin/following{/other_user}","gists_url":"https://api.github.com/users/kpetrykin/gists{/gist_id}","starred_url":"https://api.github.com/users/kpetrykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpetrykin/subscriptions","organizations_url":"https://api.github.com/users/kpetrykin/orgs","repos_url":"https://api.github.com/users/kpetrykin/repos","events_url":"https://api.github.com/users/kpetrykin/events{/privacy}","received_events_url":"https://api.github.com/users/kpetrykin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-08-24T15:26:45Z","updated_at":"2018-09-05T14:11:09Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/PX4/Firmware/pulls/10320","html_url":"https://github.com/PX4/Firmware/pull/10320","diff_url":"https://github.com/PX4/Firmware/pull/10320.diff","patch_url":"https://github.com/PX4/Firmware/pull/10320.patch"},"body":"Hello!\r\n\r\nMy goal was to make the mission command DO_SET_SERVO working with the possibility of triggering the servo with RC switch.\r\n\r\nFirst, I have found that \"vmount\" module (when enabled) publishes its values to actuator_controls_2 topic all the time. This overwrites all other publications to this topic. That is why DO_SET_SERVO is not working.\r\n\r\nI modified \"vmount\" module so that it would publish only if one of the actuator values were changed by RC. In other cases it stays silent.\r\n\r\nSecond, I have found that the formula, which translates PWM value from DO_SET_SERVO command parameters to -1..1 range for uORB, does not match the one which translates it back.\r\n[Original formula:](https://github.com/PX4/Firmware/blob/c997159e32f3870c7fd3202877324b76a62ea610/src/modules/navigator/mission_block.cpp#L433) `actuators.control[(int)item.params[0]] = 1.0f / 2000 * -item.params[1];`\r\n[Formula, which translates value back](https://github.com/4ert/Firmware/blob/397522d3813924380c209984b47b05bf743c3037/src/lib/pwm_limit/pwm_limit.cpp#L211): `effective_pwm[i] = control_value * (max_pwm[i] - min_pwm[i]) / 2 + (max_pwm[i] + min_pwm[i]) / 2;`\r\n[New formula](https://github.com/4ert/Firmware/blob/397522d3813924380c209984b47b05bf743c3037/src/modules/navigator/mission_block.cpp#L440): `actuators.control[(int)item.params[0]] = (float)(((float)item.params[1] - (PWM_DEFAULT_MAX + PWM_DEFAULT_MIN) / 2)/((PWM_DEFAULT_MAX - PWM_DEFAULT_MIN) / 2));`\r\n\r\nI need to discuss two questions about the formula: \r\n- to make it work properly we need to get actual \"max_pwm[i]\" and \"min_pwm[i]\" into navigator module. I have found a [way to get them](https://github.com/PX4/Firmware/blob/c997159e32f3870c7fd3202877324b76a62ea610/src/drivers/px4fmu/fmu.cpp#L1678), but I don't understand how to use it correctly\r\n- when I tested mission with DO_SET_SERVO command, servo works nice only with 1, 3 and 4 aux outputs. The second one for some reason outputs into first. I think there is something wrong with casting here: `(int)item.params[0]`\r\n\r\nI have tested everything with 1.7.3 Firmvare (px4fmu-v2_default), but did not save the flight log.\r\nI will test the last master in a few days."},"comment":{"url":"https://api.github.com/repos/PX4/Firmware/issues/comments/418745410","html_url":"https://github.com/PX4/Firmware/pull/10320#issuecomment-418745410","issue_url":"https://api.github.com/repos/PX4/Firmware/issues/10320","id":418745410,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODc0NTQxMA==","user":{"login":"maitham1","id":15156137,"node_id":"MDQ6VXNlcjE1MTU2MTM3","avatar_url":"https://avatars1.githubusercontent.com/u/15156137?v=4","gravatar_id":"","url":"https://api.github.com/users/maitham1","html_url":"https://github.com/maitham1","followers_url":"https://api.github.com/users/maitham1/followers","following_url":"https://api.github.com/users/maitham1/following{/other_user}","gists_url":"https://api.github.com/users/maitham1/gists{/gist_id}","starred_url":"https://api.github.com/users/maitham1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maitham1/subscriptions","organizations_url":"https://api.github.com/users/maitham1/orgs","repos_url":"https://api.github.com/users/maitham1/repos","events_url":"https://api.github.com/users/maitham1/events{/privacy}","received_events_url":"https://api.github.com/users/maitham1/received_events","type":"User","site_admin":false},"created_at":"2018-09-05T14:11:09Z","updated_at":"2018-09-05T14:11:09Z","author_association":"NONE","body":"@kpetrykin  I'm currently trying to get this to work I've used your commit. So I have my Pixhawk connected to a servo and I'm trying to get the servo to move within the mavproxy shell by running servo set 1 1000. However the message I keep getting back is that the command was acknowledged but is unrecognised (result:3) . I can get the servo moving using nuttx shell, but I really want to be able to send a mavlink command to set the servo pwm is there any way of doing this? "}}
{"actor":{"display_login":"maitham1"}}